Skip to content

Commit

Permalink
ANDROID: cgroup/cpuset: Fix suspicous RCU usage WARNING
Browse files Browse the repository at this point in the history
task_cs() is called from cpuset_cpus_allowed_fallback() without
holding the read_rcu_lock() causing the below splat.

Fix by holding the rcu_read_lock().

[    0.090199] =============================
[    0.090399] WARNING: suspicious RCU usage
[    0.090600] 5.10.19-00939-gc3bf09a68b63-dirty torvalds#368 Not tainted
[    0.090837] -----------------------------
[    0.091000] include/linux/cgroup.h:494 suspicious rcu_dereference_check() usage!
[    0.091246]
[    0.091246] other info that might help us debug this:
[    0.091246]
[    0.091499]
[    0.091499] rcu_scheduler_active = 1, debug_locks = 1
[    0.091738] 4 locks held by swapper/0/1:
[    0.091902]  #0: ffff800014e3f510 (cpu_add_remove_lock){+.+.}-{3:3}, at: cpu_up+0x100/0x190
[    0.092726]  #1: ffff800014e3f6b0 (cpu_hotplug_lock){++++}-{0:0}, at: _cpu_up+0x4c/0x1c8
[    0.093540]  #2: ffff800014e47478 (smpboot_threads_lock){+.+.}-{3:3}, at: smpboot_create_threads+0x34/0xc0
[    0.094399]  #3: ffff0008001d0878 (&p->pi_lock){....}-{2:2}, at: try_to_wake_up+0x58/0x828
[    0.095199]
[    0.095199] stack backtrace:
[    0.095425] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.19-00939-gc3bf09a68b63-dirty torvalds#368
[    0.095670] Hardware name: Foundation-v8A (DT)
[    0.095834] Call trace:
[    0.096099]  dump_backtrace+0x0/0x1a8
[    0.096353]  show_stack+0x18/0x68
[    0.096571]  dump_stack+0xf8/0x168
[    0.096817]  lockdep_rcu_suspicious+0xe4/0xf8
[    0.097063]  cpuset_cpus_allowed_fallback+0x184/0x1f8
[    0.097299]  select_fallback_rq+0x24c/0x2c0
[    0.097526]  try_to_wake_up+0x1e4/0x828
[    0.097740]  wake_up_process+0x18/0x28
[    0.097999]  kthread_park+0x74/0xc8
[    0.098209]  __smpboot_create_thread.part.0+0x90/0x168
[    0.098486]  smpboot_create_threads+0x84/0xc0
[    0.098699]  cpuhp_invoke_callback+0xe8/0xe50
[    0.098947]  _cpu_up+0xe0/0x1c8
[    0.099126]  cpu_up+0x120/0x190
[    0.099399]  bringup_nonboot_cpus+0x94/0xd0
[    0.099659]  smp_init+0x30/0x8c
[    0.099873]  kernel_init_freeable+0x1d4/0x328
[    0.100099]  kernel_init+0x14/0x118
[    0.100339]  ret_from_fork+0x10/0x34

Bug: 178507149
Fixes: 210463b ("FROMLIST: cpuset: Don't use the cpu_possible_mask as a last resort for cgroup v1")
Signed-off-by: Qais Yousef <qais.yousef@arm.com>
Change-Id: Ib7688e7d0c37cbf119d806ce79157a467b9e35f6
  • Loading branch information
Qais Yousef authored and Will Deacon committed Mar 3, 2021
1 parent e6ceb18 commit ab6e10d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kernel/cgroup/cpuset.c
Original file line number Diff line number Diff line change
Expand Up @@ -3341,14 +3341,17 @@ void cpuset_cpus_allowed(struct task_struct *tsk, struct cpumask *pmask)

void cpuset_cpus_allowed_fallback(struct task_struct *tsk)
{
const struct cpumask *cs_mask = task_cs(tsk)->cpus_allowed;
const struct cpumask *possible_mask = task_cpu_possible_mask(tsk);
const struct cpumask *cs_mask;

rcu_read_lock();
cs_mask = task_cs(tsk)->cpus_allowed;

if (!is_in_v2_mode() || !cpumask_subset(cs_mask, possible_mask))
return; /* select_fallback_rq will try harder */
goto unlock; /* select_fallback_rq will try harder */

rcu_read_lock();
do_set_cpus_allowed(tsk, cs_mask);
unlock:
rcu_read_unlock();

/*
Expand Down

0 comments on commit ab6e10d

Please sign in to comment.