mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
sched_ext: Abort directly from the hardlockup handler
scx_hardlockup() defers the abort to an irq_work because exit claiming used
to take scx_sched_lock and couldn't run from NMI. The deferral is now
unnecessary - claiming is NMI-safe and asserting ->aborting is exactly what
breaks the live-locks that hard-lock CPUs. Call handle_lockup() directly and
drop the irq_work. This also makes the self-detected case recoverable: the
perf watchdog fires on the hard-locked CPU itself, where a queued irq_work
never runs with IRQs off.
Also fix the return value: %true used to be returned whenever sched_ext was
loaded, suppressing the kernel's hardlockup report even when the abort was
refused. Return %true only when this call initiated the abort.
Fixes: bd2d76455b ("sched_ext: Defer scx_hardlockup() out of NMI")
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
This commit is contained in:
parent
e06ece82d7
commit
3c4b380649
|
|
@ -5390,25 +5390,6 @@ void scx_softlockup(u32 dur_s)
|
|||
cpu, dur_s);
|
||||
}
|
||||
|
||||
/*
|
||||
* scx_hardlockup() runs from NMI and eventually calls scx_claim_exit(),
|
||||
* which takes scx_sched_lock. scx_sched_lock isn't NMI-safe and grabbing
|
||||
* it from NMI context can lead to deadlocks. Defer via irq_work; the
|
||||
* disable path runs off irq_work anyway.
|
||||
*/
|
||||
static atomic_t scx_hardlockup_cpu = ATOMIC_INIT(-1);
|
||||
|
||||
static void scx_hardlockup_irq_workfn(struct irq_work *work)
|
||||
{
|
||||
int cpu = atomic_xchg(&scx_hardlockup_cpu, -1);
|
||||
|
||||
if (cpu >= 0 && handle_lockup(cpu, "hard lockup - CPU %d", cpu))
|
||||
printk_deferred(KERN_ERR "sched_ext: Hard lockup - CPU %d, disabling BPF scheduler\n",
|
||||
cpu);
|
||||
}
|
||||
|
||||
static DEFINE_IRQ_WORK(scx_hardlockup_irq_work, scx_hardlockup_irq_workfn);
|
||||
|
||||
/**
|
||||
* scx_hardlockup - sched_ext hardlockup handler
|
||||
* @cpu: the target CPU
|
||||
|
|
@ -5418,19 +5399,21 @@ static DEFINE_IRQ_WORK(scx_hardlockup_irq_work, scx_hardlockup_irq_workfn);
|
|||
* Try kicking out the current scheduler in an attempt to recover the system to
|
||||
* a good state before taking more drastic actions.
|
||||
*
|
||||
* Queues an irq_work; the handle_lockup() call happens in IRQ context (see
|
||||
* scx_hardlockup_irq_workfn).
|
||||
* Called from NMI. Aborting the scheduler sets ->aborting throughout the
|
||||
* hierarchy before returning, which is what breaks the dispatch-path live-locks
|
||||
* that can hard-lock CPUs.
|
||||
*
|
||||
* Returns %true if sched_ext is enabled and the work was queued, %false
|
||||
* otherwise.
|
||||
* Returns %true if sched_ext is enabled and abort was initiated, which may
|
||||
* resolve the lockup. %false if sched_ext is not enabled or abort was already
|
||||
* initiated by someone else.
|
||||
*/
|
||||
bool scx_hardlockup(int cpu)
|
||||
{
|
||||
if (!rcu_access_pointer(scx_root))
|
||||
if (!handle_lockup(cpu, "hard lockup - CPU %d", cpu))
|
||||
return false;
|
||||
|
||||
atomic_cmpxchg(&scx_hardlockup_cpu, -1, cpu);
|
||||
irq_work_queue(&scx_hardlockup_irq_work);
|
||||
printk_deferred(KERN_ERR "sched_ext: Hard lockup - CPU %d, disabling BPF scheduler\n",
|
||||
cpu);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user