Re: [PATCH 2/5] rcu/nocb: Perform deferred wake up before last idle's need_resched() check

From: Peter Zijlstra
Date: Mon Feb 08 2021 - 09:51:27 EST


On Mon, Feb 01, 2021 at 12:05:45AM +0100, Frederic Weisbecker wrote:

> diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
> index 305727ea0677..b601a3aa2152 100644
> --- a/kernel/sched/idle.c
> +++ b/kernel/sched/idle.c
> @@ -55,6 +55,7 @@ __setup("hlt", cpu_idle_nopoll_setup);
> static noinline int __cpuidle cpu_idle_poll(void)
> {
> trace_cpu_idle(0, smp_processor_id());
> + rcu_nocb_flush_deferred_wakeup();
> stop_critical_timings();
> rcu_idle_enter();
> local_irq_enable();
> @@ -173,6 +174,8 @@ static void cpuidle_idle_call(void)
> struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
> int next_state, entered_state;
>
> + rcu_nocb_flush_deferred_wakeup();
> +
> /*
> * Check if the idle task must be rescheduled. If it is the
> * case, exit the function after re-enabling the local irq.

Ok if I do this instead?

--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -55,7 +55,6 @@ __setup("hlt", cpu_idle_nopoll_setup);
static noinline int __cpuidle cpu_idle_poll(void)
{
trace_cpu_idle(0, smp_processor_id());
- rcu_nocb_flush_deferred_wakeup();
stop_critical_timings();
rcu_idle_enter();
local_irq_enable();
@@ -174,8 +173,6 @@ static void cpuidle_idle_call(void)
struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
int next_state, entered_state;

- rcu_nocb_flush_deferred_wakeup();
-
/*
* Check if the idle task must be rescheduled. If it is the
* case, exit the function after re-enabling the local irq.
@@ -288,6 +285,7 @@ static void do_idle(void)
}

arch_cpu_idle_enter();
+ rcu_nocb_flush_deferred_wakeup();

/*
* In poll mode we reenable interrupts and spin. Also if we