Skip to content

Commit 5577273

Browse files
Waiman-Longgregkh
authored andcommitted
cgroup/cpuset: Fix "suspicious RCU usage" lockdep warning
commit 2bdfd28 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f1f7d1a commit 5577273

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
@@ -1481,19 +1481,29 @@ static void update_sibling_cpumasks(struct cpuset *parent, struct cpuset *cs,
14811481
struct cpuset *sibling;
14821482
struct cgroup_subsys_state *pos_css;
14831483

1484+
percpu_rwsem_assert_held(&cpuset_rwsem);
1485+
14841486
/*
14851487
* Check all its siblings and call update_cpumasks_hier()
14861488
* if their use_parent_ecpus flag is set in order for them
14871489
* to use the right effective_cpus value.
1490+
*
1491+
* The update_cpumasks_hier() function may sleep. So we have to
1492+
* release the RCU read lock before calling it.
14881493
*/
14891494
rcu_read_lock();
14901495
cpuset_for_each_child(sibling, pos_css, parent) {
14911496
if (sibling == cs)
14921497
continue;
14931498
if (!sibling->use_parent_ecpus)
14941499
continue;
1500+
if (!css_tryget_online(&sibling->css))
1501+
continue;
14951502

1503+
rcu_read_unlock();
14961504
update_cpumasks_hier(sibling, tmp);
1505+
rcu_read_lock();
1506+
css_put(&sibling->css);
14971507
}
14981508
rcu_read_unlock();
14991509
}

0 commit comments

Comments
 (0)