mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 05:31:08 -04:00
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) <[email protected]> Tested-by: Don Hiatt <[email protected]> Tested-by: Hongyu Ning <[email protected]> Tested-by: Vincent Guittot <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
This commit is contained in:
1 parent
6e33cad0af
commit
85dd3f6120
3 files changed
+11
No files matched your search
@@ -2181,8 +2181,10 @@ const struct cpumask *sched_trace_rd_span(struct root_domain *rd);
|
||||
|
||||
#ifdef CONFIG_SCHED_CORE
|
||||
extern void sched_core_free(struct task_struct *tsk);
|
||||
extern void sched_core_fork(struct task_struct *p);
|
||||
#else
|
||||
static inline void sched_core_free(struct task_struct *tsk) { }
|
||||
static inline void sched_core_fork(struct task_struct *p) { }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -2251,6 +2251,8 @@ static __latent_entropy struct task_struct *copy_process(
|
||||
|
||||
klp_copy_process(p);
|
||||
|
||||
sched_core_fork(p);
|
||||
|
||||
spin_lock(¤t->sighand->siglock);
|
||||
|
||||
/*
|
||||
@@ -2338,6 +2340,7 @@ static __latent_entropy struct task_struct *copy_process(
|
||||
return p;
|
||||
|
||||
bad_fork_cancel_cgroup:
|
||||
sched_core_free(p);
|
||||
spin_unlock(¤t->sighand->siglock);
|
||||
write_unlock_irq(&tasklist_lock);
|
||||
cgroup_cancel_fork(p, args);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user