Skip to content

Commit 2bdfd28

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup/cpuset: Fix "suspicious RCU usage" lockdep warning
It was found that a "suspicious RCU usage" lockdep warning was issued with the rcu_read_lock() call in update_sibling_cpumasks(). It is because the update_cpumasks_hier() function may sleep. So we have to release the RCU lock, call update_cpumasks_hier() and reacquire it afterward. Also add a percpu_rwsem_assert_held() in update_sibling_cpumasks() instead of stating that in the comment. Fixes: 4716909 ("cpuset: Track cpusets that use parent's effective_cpus") Signed-off-by: Waiman Long <longman@redhat.com> Tested-by: Phil Auld <pauld@redhat.com> Reviewed-by: Phil Auld <pauld@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 24f6008 commit 2bdfd28

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

kernel/cgroup/cpuset.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,19 +1550,29 @@ static void update_sibling_cpumasks(struct cpuset *parent, struct cpuset *cs,
15501550
struct cpuset *sibling;
15511551
struct cgroup_subsys_state *pos_css;
15521552

1553+
percpu_rwsem_assert_held(&cpuset_rwsem);
1554+
15531555
/*
15541556
* Check all its siblings and call update_cpumasks_hier()
15551557
* if their use_parent_ecpus flag is set in order for them
15561558
* to use the right effective_cpus value.
1559+
*
1560+
* The update_cpumasks_hier() function may sleep. So we have to
1561+
* release the RCU read lock before calling it.
15571562
*/
15581563
rcu_read_lock();
15591564
cpuset_for_each_child(sibling, pos_css, parent) {
15601565
if (sibling == cs)
15611566
continue;
15621567
if (!sibling->use_parent_ecpus)
15631568
continue;
1569+
if (!css_tryget_online(&sibling->css))
1570+
continue;
15641571

1572+
rcu_read_unlock();
15651573
update_cpumasks_hier(sibling, tmp);
1574+
rcu_read_lock();
1575+
css_put(&sibling->css);
15661576
}
15671577
rcu_read_unlock();
15681578
}

0 commit comments

Comments
 (0)