nohz: Clarify magic in tick_nohz_stop_sched_tick()
PATCH 1/1 nohz: Clarify magic in tick_nohz_stop_sched_tick()
While going through the nohz code I got stumped by some of it.
This patch adds a few comments clarifying the code; based on discussion with Thomas.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>
---
kernel/time/tick-sched.c +18 -2
@@ -603,15 +603,31 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,/* * If the tick is due in the next period, keep it ticking or -* restart it proper. +* force prod the timer. */ delta = next_tick - basemono;if (delta <= (u64 )TICK_NSEC ) { tick.tv64 =0 ; +/* +* We've not stopped the tick yet, and there's a timer in the +* next period, so no point in stopping it either, bail. +*/ if (!ts->tick_stopped) goto out; + +/* +* If, OTOH, we did stop it, but there's a pending (expired) +* timer reprogram the timer hardware to fire now. +* +* We will not restart the tick proper, just prod the timer +* hardware into firing an interrupt to process the pending +* timers. Just like tick_irq_exit() will not restart the tick +* for 'normal' interrupts. +* +* Only once we exit the idle loop will we re-enable the tick, +* see tick_nohz_idle_exit(). +*/ if (delta ==0 ) { -/* Tick is stopped, but required now. Enforce it */ tick_nohz_restart (ts, now); goto out; }
tip-bot for Peter Zijlstra
merge botnohz: Clarify magic in tick_nohz_stop_sched_tick()
Commit-ID: 82bbe34b3d895fb026b2fc0e7da2e641797bfaed Gitweb: http://git.kernel.org/tip/82bbe34b3d895fb026b2fc0e7da2e641797bfaed Author: Peter Zijlstra <[email protected]> AuthorDate: Thu, 19 Nov 2015 17:21:06 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Wed, 25 Nov 2015 22:37:27 +0100
nohz: Clarify magic in tick_nohz_stop_sched_tick()
While going through the nohz code I got stumped by some of it.
This patch adds a few comments clarifying the code; based on discussion with Thomas.
Signed-off-by Peter Zijlstra (Intel) <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Signed-off-by Thomas Gleixner <[email protected]>
--- kernel/time/tick-sched.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
kernel/time/tick-sched.c +18 -2
@@ -603,15 +603,31 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,/* * If the tick is due in the next period, keep it ticking or -* restart it proper. +* force prod the timer. */ delta = next_tick - basemono;if (delta <= (u64 )TICK_NSEC ) { tick.tv64 =0 ; +/* +* We've not stopped the tick yet, and there's a timer in the +* next period, so no point in stopping it either, bail. +*/ if (!ts->tick_stopped) goto out; + +/* +* If, OTOH, we did stop it, but there's a pending (expired) +* timer reprogram the timer hardware to fire now. +* +* We will not restart the tick proper, just prod the timer +* hardware into firing an interrupt to process the pending +* timers. Just like tick_irq_exit() will not restart the tick +* for 'normal' interrupts. +* +* Only once we exit the idle loop will we re-enable the tick, +* see tick_nohz_idle_exit(). +*/ if (delta ==0 ) { -/* Tick is stopped, but required now. Enforce it */ tick_nohz_restart (ts, now); goto out; }