Re: [PATCH 1/1] sched/debug: fix potential deadlock when write to sched_features

From: Dietmar Eggemann
Date: Tue Jul 31 2018 - 07:38:13 EST


On 07/31/2018 12:34 PM, Peter Zijlstra wrote:
>
> Leaving a lot of quoted crud for Viresh..
>
> On Tue, Jul 31, 2018 at 06:22:19PM +0900, jiada_wang@xxxxxxxxxx wrote:
>> From: Jiada Wang <jiada_wang@xxxxxxxxxx>
>>
>> Following lockdep report can be triggered by write to
>> /sys/kernel/debug/sched_features
>
> Only if you're using this dt_cpufreq thing of course.. I wonder why this
> hasn't been reported before.
>

[...]

>
> I don't much care for all the _cpuslocked renaming done, but otherwise I
> suppose this is the easiest fix.
>
> Note however that this doesn't apply, you're missing that match_string()
> patch. Please use tip/sched/core or something.

With the patch tweaked onto tip/sched/core.

w/o the patch:

root@h960:~# echo NO_LB_BIAS > /sys/kernel/debug/sched_features
[ 293.052451]
[ 293.053978] ======================================================
[ 293.060166] WARNING: possible circular locking dependency detected
[ 293.066358] 4.18.0-rc5-00064-gae48698275b3 #1 Tainted: G S
[ 293.073153] ------------------------------------------------------
[ 293.079340] bash/3490 is trying to acquire lock:
[ 293.083966] 00000000155b9437 (cpu_hotplug_lock.rw_sem){++++}, at: static_key_disable+0x1c/0x38
[ 293.092620]
[ 293.092620] but task is already holding lock:
[ 293.098459] 0000000084a95e1c (&sb->s_type->i_mutex_key#3){+.+.}, at: sched_feat_write+0xc4/0x1e0
[ 293.107277]
[ 293.107277] which lock already depends on the new lock.
...

w/ the patch:

root@h960:~# echo NO_LB_BIAS > /sys/kernel/debug/sched_features
root@h960:~#

Tested-by: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>