diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sched.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 2fe98ed474da..3f2e502d609b 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -605,10 +605,10 @@ static inline int cpu_of(struct rq *rq) | |||
605 | /* | 605 | /* |
606 | * Return the group to which this tasks belongs. | 606 | * Return the group to which this tasks belongs. |
607 | * | 607 | * |
608 | * We use task_subsys_state_check() and extend the RCU verification | 608 | * We use task_subsys_state_check() and extend the RCU verification with |
609 | * with lockdep_is_held(&p->pi_lock) because cpu_cgroup_attach() | 609 | * pi->lock and rq->lock because cpu_cgroup_attach() holds those locks for each |
610 | * holds that lock for each task it moves into the cgroup. Therefore | 610 | * task it moves into the cgroup. Therefore by holding either of those locks, |
611 | * by holding that lock, we pin the task to the current cgroup. | 611 | * we pin the task to the current cgroup. |
612 | */ | 612 | */ |
613 | static inline struct task_group *task_group(struct task_struct *p) | 613 | static inline struct task_group *task_group(struct task_struct *p) |
614 | { | 614 | { |
@@ -616,7 +616,8 @@ static inline struct task_group *task_group(struct task_struct *p) | |||
616 | struct cgroup_subsys_state *css; | 616 | struct cgroup_subsys_state *css; |
617 | 617 | ||
618 | css = task_subsys_state_check(p, cpu_cgroup_subsys_id, | 618 | css = task_subsys_state_check(p, cpu_cgroup_subsys_id, |
619 | lockdep_is_held(&p->pi_lock)); | 619 | lockdep_is_held(&p->pi_lock) || |
620 | lockdep_is_held(&task_rq(p)->lock)); | ||
620 | tg = container_of(css, struct task_group, css); | 621 | tg = container_of(css, struct task_group, css); |
621 | 622 | ||
622 | return autogroup_task_group(p, tg); | 623 | return autogroup_task_group(p, tg); |
@@ -2200,6 +2201,16 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu) | |||
2200 | !(task_thread_info(p)->preempt_count & PREEMPT_ACTIVE)); | 2201 | !(task_thread_info(p)->preempt_count & PREEMPT_ACTIVE)); |
2201 | 2202 | ||
2202 | #ifdef CONFIG_LOCKDEP | 2203 | #ifdef CONFIG_LOCKDEP |
2204 | /* | ||
2205 | * The caller should hold either p->pi_lock or rq->lock, when changing | ||
2206 | * a task's CPU. ->pi_lock for waking tasks, rq->lock for runnable tasks. | ||
2207 | * | ||
2208 | * sched_move_task() holds both and thus holding either pins the cgroup, | ||
2209 | * see set_task_rq(). | ||
2210 | * | ||
2211 | * Furthermore, all task_rq users should acquire both locks, see | ||
2212 | * task_rq_lock(). | ||
2213 | */ | ||
2203 | WARN_ON_ONCE(debug_locks && !(lockdep_is_held(&p->pi_lock) || | 2214 | WARN_ON_ONCE(debug_locks && !(lockdep_is_held(&p->pi_lock) || |
2204 | lockdep_is_held(&task_rq(p)->lock))); | 2215 | lockdep_is_held(&task_rq(p)->lock))); |
2205 | #endif | 2216 | #endif |