Hi Greg or Thomas, 0e576acbc1d9600cf2d9b4a141a2554639959d50 nohz: Fix another inconsistency between CONFIG_NO_HZ=n and nohz=off
This fixed an inconsistency about nohz. Without this patch, When we boot with nohz=off and CONFIG_NO_HZ=Y, and the system is idle, powertop shows the cpu is always in polling state. It can affect the performance in some cases. *without patch* PowerTOP version 1.13 (C) 2007 Intel Corporation Cn Avg residency P-states (frequencies) C0 (cpu running) ( 0.0%) Turbo Mode 0.0% polling 70.3ms (100.3%) 2.40 Ghz 0.0% C1 mwait 0.0ms ( 0.0%) 2.27 Ghz 0.0% C2 mwait 0.0ms ( 0.0%) 2.14 Ghz 0.0% C3 mwait 0.0ms ( 0.0%) 1.60 Ghz 100.0% *with patch* PowerTOP version 1.13 (C) 2007 Intel Corporation Cn Avg residency P-states (frequencies) C0 (cpu running) ( 0.3%) Turbo Mode 0.0% polling 0.0ms ( 0.0%) 2.40 Ghz 0.0% C1 mwait 0.0ms ( 0.0%) 2.27 Ghz 0.0% C2 mwait 0.0ms ( 0.0%) 2.14 Ghz 0.0% C3 mwait 3.9ms (99.7%) 1.60 Ghz 100.0% This patch looks applicable to stable-3.4 and stable 3.10. It can be applyed to 3.10 cleanly, but should be added some adjustment for 3.4. And what do you think? Thanks, Rui ----------------------- From: Thomas Gleixner <t...@linutronix.de> commit 0e576acbc1d9600cf2d9b4a141a2554639959d50 upstream If CONFIG_NO_HZ=n tick_nohz_get_sleep_length() returns NSEC_PER_SEC/HZ. If CONFIG_NO_HZ=y and the nohz functionality is disabled via the command line option "nohz=off" or not enabled due to missing hardware support, then tick_nohz_get_sleep_length() returns 0. That happens because ts->sleep_length is never set in that case. Set it to NSEC_PER_SEC/HZ when the NOHZ mode is inactive. Reported-by: Michal Hocko <mho...@suse.cz> Reported-by: Borislav Petkov <b...@alien8.de> Signed-off-by: Thomas Gleixner <t...@linutronix.de> [xr: Backported to 3.4: - applied the change to tick_nohz_stop_sched_tick() instead of can_stop_idle_tick] Signed-off-by: Rui Xiang <rui.xi...@huawei.com> --- kernel/time/tick-sched.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 638dadf..67106f8 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -296,8 +296,10 @@ static void tick_nohz_stop_sched_tick(struct tick_sched *ts) tick_do_timer_cpu = TICK_DO_TIMER_NONE; } - if (unlikely(ts->nohz_mode == NOHZ_MODE_INACTIVE)) + if (unlikely(ts->nohz_mode == NOHZ_MODE_INACTIVE)) { + ts->sleep_length = (ktime_t) { .tv64 = NSEC_PER_SEC/HZ }; return; + } if (need_resched()) return; -- -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html