Re: [PATCH] idle/tick-broadcast: Exit cpu idle poll loop when cleared from tick_broadcast_force_mask

From: Thomas Gleixner
Date: Tue Jan 20 2015 - 06:21:56 EST


On Mon, 19 Jan 2015, Preeti U Murthy wrote:
> An idle cpu enters cpu_idle_poll() if it is set in the tick_broadcast_force_mask.
> This is so that it does not incur the overhead of entering idle states when it is expected
> to be woken up anytime then through a broadcast IPI. The condition that forces an exit out
> of the idle polling is the check on setting of the TIF_NEED_RESCHED flag for the idle thread.
>
> When the broadcast IPI does arrive, it is not guarenteed that the handler sets the
> TIF_NEED_RESCHED flag. Hence although the cpu is cleared in the tick_broadcast_force_mask,
> it continues to loop in cpu_idle_poll unnecessarily wasting power. Hence exit the idle
> poll loop if the tick_broadcast_force_mask gets cleared and enter idle states.
>
> Of course if the cpu has entered cpu_idle_poll() on being asked to poll explicitly,
> it continues to poll till it is asked to reschedule.
>
> Signed-off-by: Preeti U Murthy <preeti@xxxxxxxxxxxxxxxxxx>
> ---
>
> kernel/sched/idle.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
> index c47fce7..aaf1c1d 100644
> --- a/kernel/sched/idle.c
> +++ b/kernel/sched/idle.c
> @@ -47,7 +47,8 @@ static inline int cpu_idle_poll(void)
> rcu_idle_enter();
> trace_cpu_idle_rcuidle(0, smp_processor_id());
> local_irq_enable();
> - while (!tif_need_resched())
> + while (!tif_need_resched() &&
> + (cpu_idle_force_poll || tick_check_broadcast_expired()))

You explain the tick_check_broadcast_expired() bit, but what about the
cpu_idle_force_poll part?

Thanks,

tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/