From 580788d5df0b6349f2e76a0ad135cc3612cb7ecd Mon Sep 17 00:00:00 2001 From: Satya Durga Srinivasu Prabhala Date: Mon, 5 Oct 2020 21:18:10 -0700 Subject: [PATCH] sched: fix suspicious RCU usage warning Below warning is observed during boot when lockdep is enabled: [ 0.233539] ============================= [ 0.237668] WARNING: suspicious RCU usage [ 0.241798] 5.4.57-qgki-debug-g003be53-dirty #2 Not tainted [ 0.247528] ----------------------------- [ 0.251657] include/linux/cgroup.h:488 suspicious rcu_dereference_check() usage! [ 0.259250] [ 0.259250] other info that might help us debug this: [ 0.259250] [ 0.267467] [ 0.267467] rcu_scheduler_active = 1, debug_locks = 1 [ 0.274179] 2 locks held by swapper/0/0: [ 0.278222] #0: ffffff800b7b89b0 (&p->pi_lock){....}, at: wake_up_new_task+0x44/0x1f4 [ 0.286367] #1: ffffff8179306018 (&rq->lock){-.-.}, at: __task_rq_lock+0x60/0xd8 [ 0.294061] [ 0.294061] stack backtrace: [ 0.298544] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.4.57-qgki-debug-g003be53-dirty #2 [ 0.306946] Hardware name: Qualcomm Technologies, Inc. LahainaP MTP (DT) [ 0.313828] Call trace: [ 0.316353] dump_backtrace.cfi_jt+0x0/0x4 [ 0.320569] show_stack+0x18/0x24 [ 0.323989] dump_stack+0xe0/0x160 [ 0.327496] lockdep_rcu_suspicious+0x138/0x154 [ 0.332155] task_fits_max+0x11c/0x290 [ 0.336015] enqueue_task_fair+0x104/0x268 [ 0.340230] enqueue_task+0x154/0x1c8 [ 0.344003] wake_up_new_task+0xd4/0x1f4 [ 0.348048] _do_fork+0x264/0x37c [ 0.351469] kernel_thread+0x50/0x78 [ 0.355156] rest_init+0x2c/0x1f0 [ 0.358577] start_kernel+0x0/0x424 [ 0.362168] start_kernel+0x3ac/0x424 Fix the issue by adding RCU lock while dereferencing css for the task. Change-Id: I1f690dcf93a3bc3c39b401942654cc4f3b302346 Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/sched/sched.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 79b175a65e0e..82d911ecc095 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3056,14 +3056,21 @@ extern struct walt_sched_cluster *rq_cluster(struct rq *rq); #ifdef CONFIG_UCLAMP_TASK_GROUP static inline bool task_sched_boost(struct task_struct *p) { - struct cgroup_subsys_state *css = task_css(p, cpu_cgrp_id); + struct cgroup_subsys_state *css; struct task_group *tg; + bool sched_boost_enabled; - if (!css) + rcu_read_lock(); + css = task_css(p, cpu_cgrp_id); + if (!css) { + rcu_read_unlock(); return false; + } tg = container_of(css, struct task_group, css); + sched_boost_enabled = tg->wtg.sched_boost_enabled; + rcu_read_unlock(); - return tg->wtg.sched_boost_enabled; + return sched_boost_enabled; } extern int sync_cgroup_colocation(struct task_struct *p, bool insert);