summaryrefslogtreecommitdiff
path: root/kernel/sched/core_sched.c
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2021-03-29 15:18:35 +0200
committerPeter Zijlstra <peterz@infradead.org>2021-05-12 11:43:31 +0200
commit85dd3f61203c5cfa72b308ff327b5fbf3fc1ce5e (patch)
treeace8780b1ed4212015463c4566c075d08259d46c /kernel/sched/core_sched.c
parent6e33cad0af49336952e5541464bd02f5b5fd433e (diff)
sched: Inherit task cookie on fork()
Note that sched_core_fork() is called from under tasklist_lock, and not from sched_fork() earlier. This avoids a few races later. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Don Hiatt <dhiatt@digitalocean.com> Tested-by: Hongyu Ning <hongyu.ning@linux.intel.com> Tested-by: Vincent Guittot <vincent.guittot@linaro.org> Link: https://lkml.kernel.org/r/20210422123308.980003687@infradead.org
Diffstat (limited to 'kernel/sched/core_sched.c')
-rw-r--r--kernel/sched/core_sched.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/sched/core_sched.c b/kernel/sched/core_sched.c
index 8d0869a9eb8c..dcbbeaefaaa3 100644
--- a/kernel/sched/core_sched.c
+++ b/kernel/sched/core_sched.c
@@ -103,6 +103,12 @@ static unsigned long sched_core_clone_cookie(struct task_struct *p)
return cookie;
}
+void sched_core_fork(struct task_struct *p)
+{
+ RB_CLEAR_NODE(&p->core_node);
+ p->core_cookie = sched_core_clone_cookie(current);
+}
+
void sched_core_free(struct task_struct *p)
{
sched_core_put_cookie(p->core_cookie);