Skip to content

sched_ext: Fix deadlock in scx_claim_exit() by deferring descendant propagation

Cheng-Yang Chou lkml sched-ext 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest1 patch 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1sched_ext: Fix deadlock in scx_claim_exit() by deferring descendant propagationkernel/sched/ext.c+26 -170 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/1] sched_ext: Fix deadlock in scx_claim_exit() by deferring descendant propagation

While testing scx_rustland under vng, the locking dependency checker reported a circular locking dependency:

[   31.801757] ======================================================
[   31.801786] WARNING: possible circular locking dependency detected
[   31.801812] 7.0.0-rc2+ #31 Tainted: G            E
[   31.801835] ------------------------------------------------------
[   31.801860] swapper/7/0 is trying to acquire lock:
[   31.801884] ffffffffa4ac1638 (scx_sched_lock){-...}-{2:2}, at: scx_claim_exit+0x7a/0x180
[   31.801923]
[   31.801923] but task is already holding lock:
[   31.801951] ffff8ce0bcbc5ca0 (&rq->__lock){-.-.}-{2:2}, at: raw_spin_rq_lock_nested+0x28/0xc0
[   31.801990]
[   31.801990] which lock already depends on the new lock.
[   31.801990]
[   31.802021]
[   31.802021] the existing dependency chain (in reverse order) is:
[   31.802050]
[   31.802050] -> #1 (&rq->__lock){-.-.}-{2:2}:
[   31.802079]        _raw_spin_lock_nested+0x2d/0x50
[   31.802103]        raw_spin_rq_lock_nested+0x28/0xc0
[   31.802128]        scx_bypass+0x14e/0x4e0
[   31.802147]        scx_root_enable_workfn+0x2ce/0xa10
[   31.802171]        kthread_worker_fn+0xbf/0x3c0
[   31.802199]        kthread+0x109/0x140
[   31.802218]        ret_from_fork+0x3fd/0x490
[   31.802242]        ret_from_fork_asm+0x1a/0x30
[   31.802267]
[   31.802267] -> #0 (scx_sched_lock){-...}-{2:2}:
[   31.802296]        __lock_acquire+0x172e/0x2830
[   31.802320]        lock_acquire+0xd5/0x330
[   31.802339]        _raw_spin_lock_irqsave+0x49/0x80
[   31.802363]        scx_claim_exit+0x7a/0x180
[   31.802387]        scx_vexit+0x3a/0xd0
[   31.802406]        scx_exit+0x50/0x80
[   31.802425]        scx_tick+0x114/0x120
[   31.802445]        sched_tick+0x12e/0x3a0
[   31.802464]        update_process_times+0x90/0xf0
[   31.802488]        tick_nohz_handler+0x97/0x1b0
[   31.802512]        __hrtimer_run_queues+0xac/0x3a0
[   31.802539]        hrtimer_interrupt+0x116/0x280
[   31.802564]        __sysvec_apic_timer_interrupt+0x6b/0x1e0
[   31.802589]        sysvec_apic_timer_interrupt+0x9b/0xc0
[   31.802613]        asm_sysvec_apic_timer_interrupt+0x1b/0x20
[   31.802642]        pv_native_safe_halt+0xb/0x10
[   31.802669]        arch_cpu_idle+0x9/0x10
[   31.802687]        default_idle_call+0x7c/0x220
[   31.802713]        do_idle+0x211/0x260
[   31.802732]        cpu_startup_entry+0x29/0x30
[   31.802756]        start_secondary+0x12d/0x170
[   31.802780]        common_startup_64+0x13e/0x141
[   31.802804]
[   31.802804] other info that might help us debug this:
[   31.802804]
[   31.802834]  Possible unsafe locking scenario:
[   31.802834]
[   31.802859]        CPU0                    CPU1
[   31.802879]        ----                    ----
[   31.802899]   lock(&rq->__lock);
[   31.802918]                                lock(scx_sched_lock);
[   31.802949]                                lock(&rq->__lock);
[   31.802978]   lock(scx_sched_lock);
[   31.802997]
[   31.802997]  *** DEADLOCK ***

Link to full log:

        https://gist.github.com/EricccTaiwan/bc7d8eac7a9a31af36a2e9f0a295da7c

Thanks,
Cheng-Yang

---

Cheng-Yang Chou (1):
sched_ext: Fix deadlock in scx_claim_exit() by deferring descendant
propagation

 kernel/sched/ext.c | 43 ++++++++++++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 17 deletions(-)
Signature · 1 line
2.48.1