Messages in this thread Patch in this message | | | From | Frederic Weisbecker <> | Subject | [PATCH 4/4] ACPI: processor: Fix missing need_resched() check after rcu_idle_enter() | Date | Mon, 4 Jan 2021 16:20:58 +0100 |
| |
Entering RCU idle mode may cause a deferred wake up of an RCU NOCB_GP kthread (rcuog) to be serviced.
Usually a wake up happening while running the idle task is spotted in one of the need_resched() checks carefully placed within the idle loop that can break to the scheduler.
Unfortunately within acpi_idle_enter_bm() the call to rcu_idle_enter() is already beyond the last generic need_resched() check. The cpu idle implementation happens to be ok because it ends up calling mwait_idle_with_hints() or acpi_safe_halt() which both perform their own need_resched() checks. But the suspend to idle implementation doesn't so it may suspend the CPU with a resched request unhandled, leaving the task hanging.
Fix this with performing a last minute need_resched() check after calling rcu_idle_enter().
Reported-by: Paul E. McKenney <paulmck@kernel.org> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Fixes: 1fecfdbb7acc (ACPI: processor: Take over RCU-idle for C3-BM idle) Cc: stable@vger.kernel.org Cc: Len Brown <lenb@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar<mingo@kernel.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> --- drivers/acpi/processor_idle.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index d93e400940a3..c4939c49d972 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -604,8 +604,14 @@ static int acpi_idle_enter_bm(struct cpuidle_driver *drv, } rcu_idle_enter(); - - acpi_idle_do_entry(cx); + /* + * Last need_resched() check must come after rcu_idle_enter() + * which may wake up RCU internal tasks. mwait_idle_with_hints() + * and acpi_safe_halt() have their own checks but s2idle + * implementation doesn't. + */ + if (!need_resched()) + acpi_idle_do_entry(cx); rcu_idle_exit(); -- 2.25.1
| |