Skip to contentSkip to conversation

nohz: delay going tickless under CPU load to favor deeper C states

PATCH In review Kevin Hilman 2 participants 5 messages Apr 7, 2011 Nohz, dynticks support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nohz: delay going tickless under CPU load to favor deeper C states

From: Nicole Chalhoub <[email protected]>

While there is CPU load, continue the periodic tick in order to give CPUidle another opportunity to pick a deeper C-state instead of spending potentially long idle times in a shallow C-state.

Long winded version:

When going idle with a high load average, CPUidle menu governor will decide to pick a shallow C-state since one of the guiding principles of the menu governor is "The busier the system, the less impact of C states is acceptable" (taken from cpuidle/governors/menu.c.) That makes perfect sense.

However, there are missed power-saving opportunities for bursty workloads with long idle times (e.g. MP3 playback.) Given such a workload, because of the load average, CPUidle tends to pick a shallow C-state. Because we also go tickless, this shallow C-state is used for the duration of the idle period. If the idle period is long, a deeper C state would've resulted in better power savings.

This patch delays going tickless when there is a load such that on the next tick, the CPUidle governor will have another opportunity to to pick a deeper C-state. Since the system will have been idle for potentially a full tick, the load average will drop and a deeper C state will most likely be chosen.

Delaying NOHZ decisions until the load is zero improved the load estimation on our ARM/OMAP4 platform where HZ=128 and increased the time spent in deep C-states (~50% of idle time in C-states deeper than C1). A power saving of ~20mA at battery level is observed during MP3 playback on OMAP4/Blaze board.

Cc Arjan van de Ven <[email protected]>
Cc Thomas Gleixner <[email protected]>
[[email protected]: rework changelog]
---
 kernel/time/tick-sched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/time/tick-sched.c +1 -1
index d5097c4..418066c 100644
@@ -324,7 +324,7 @@ void tick_nohz_stop_sched_tick(int inidle)
 	} while (read_seqretry(&xtime_lock, seq));
 
 	if (rcu_needs_cpu(cpu) || printk_needs_cpu(cpu) ||
-	    arch_needs_cpu(cpu)) {
+	    arch_needs_cpu(cpu) || this_cpu_load()) {
 		next_jiffies = last_jiffies + 1;
 		delta_jiffies = 1;
 	} else {
Signature · 1 line
1.7.4
#1 lore raw
Quoted 5 lines · Kevin Hilman

From: Nicole Chalhoub<[email protected]>

While there is CPU load, continue the periodic tick in order to give CPUidle another opportunity to pick a deeper C-state instead of spending potentially long i

so I don't really like this patch. It's actually a pretty bad hack (I'm sure it'll work somewhat)
[and I mean that in the most positive sense of the word ;-) ]

what we really need instead, and this is inside cpuidle, is the option to set a timer when we enter the non-deepest C state,
so that if that timer fires we then reevaluate.
The duration of that timer will be dependent on the C state (so should come from the C state structure of the state we pick).

For the most shallow one this will be a relatively short time, but for the deepest-but-one this might be a lot longer time.

your patch abuses a completely different, unrelated timer for this, with a pretty much unspecified frequency, that also has other side effects that we probably don't want.

it shouldn't be hard to do the right thing instead and make it a separate timer with a per C state timeout.

(and I would say a default timeout of 10x the break even time that we already have in the structure)

#4 lore raw
In reply to Kevin Hilman
Quoted 5 lines · Kevin Hilman

From: Nicole Chalhoub<[email protected]>

While there is CPU load, continue the periodic tick in order to give CPUidle another opportunity to pick a deeper C-state instead of spending potentially long i

so I don't really like this patch. It's actually a pretty bad hack (I'm sure it'll work somewhat)
[and I mean that in the most positive sense of the word ;-) ]

what we really need instead, and this is inside cpuidle, is the option to set a timer when we enter the non-deepest C state,
so that if that timer fires we then reevaluate.
The duration of that timer will be dependent on the C state (so should come from the C state structure of the state we pick).

For the most shallow one this will be a relatively short time, but for the deepest-but-one this might be a lot longer time.

your patch abuses a completely different, unrelated timer for this, with a pretty much unspecified frequency, that also has other side effects that we probably don't want.

it shouldn't be hard to do the right thing instead and make it a separate timer with a per C state timeout.

(and I would say a default timeout of 10x the break even time that we already have in the structure)

#2 lore raw
In reply to Arjan van de Ven

Hi Arjan,

Quoted 11 lines · Arjan van de Ven
Quoted 5 lines · Kevin Hilman

From: Nicole Chalhoub<[email protected]>

While there is CPU load, continue the periodic tick in order to give CPUidle another opportunity to pick a deeper C-state instead of spending potentially long i

so I don't really like this patch. It's actually a pretty bad hack (I'm sure it'll work somewhat)
[and I mean that in the most positive sense of the word ;-) ]

I'll take it as a complement then. :)

I agree though, it did feel somewhat like we were attempting to fix the problem in the wrong place.

Quoted 5 lines

what we really need instead, and this is inside cpuidle, is the option to set a timer when we enter the non-deepest C state,
so that if that timer fires we then reevaluate.
The duration of that timer will be dependent on the C state (so should come from the C state structure of the state we pick).

OK, this sounds like a good idea. Will experiment.

Of course, setting new timers can affect the governors decision. To avoid that, I guess this timer will need to be one-shot, and only set after the CPUidle governor has made a decision, otherwise that timer itself will affect tick_nohz_get_sleep_length() which the governor uses to pick a C-state.

Quoted 6 lines

For the most shallow one this will be a relatively short time, but for the deepest-but-one this might be a lot longer time.

your patch abuses a completely different, unrelated timer for this, with a pretty much unspecified frequency, that also has other side effects that we probably don't want.

What side effects come to mind? The only side effects that I could think of were (potentially) unwanted wakeups from C1. However, since C1 is presumably cheap to enter (and exit), it seemed like a worthwhile cost since you're almost certain to pick a deeper C state after wakeup.

That being said, your idea of per C-state timer is much better than relying on the scheduler tick. On most ARM systems, HZ is still pretty low (around 100), the time between ticks is relatively long, but on a HZ=1000 setup, I could see the extra wakeups having a penalty of their own.

Quoted 2 lines

it shouldn't be hard to do the right thing instead and make it a separate timer with a per C state timeout.

Agreed. Will give it a try.

Quoted 2 lines

(and I would say a default timeout of 10x the break even time that we already have in the structure)

OK.

Thanks for the review and suggestions,

Kevin

#3 lore raw
In reply to Arjan van de Ven

Hi Arjan,

Quoted 11 lines · Arjan van de Ven
Quoted 5 lines · Kevin Hilman

From: Nicole Chalhoub<[email protected]>

While there is CPU load, continue the periodic tick in order to give CPUidle another opportunity to pick a deeper C-state instead of spending potentially long i

so I don't really like this patch. It's actually a pretty bad hack (I'm sure it'll work somewhat)
[and I mean that in the most positive sense of the word ;-) ]

I'll take it as a complement then. :)

I agree though, it did feel somewhat like we were attempting to fix the problem in the wrong place.

Quoted 5 lines

what we really need instead, and this is inside cpuidle, is the option to set a timer when we enter the non-deepest C state,
so that if that timer fires we then reevaluate.
The duration of that timer will be dependent on the C state (so should come from the C state structure of the state we pick).

OK, this sounds like a good idea. Will experiment.

Of course, setting new timers can affect the governors decision. To avoid that, I guess this timer will need to be one-shot, and only set after the CPUidle governor has made a decision, otherwise that timer itself will affect tick_nohz_get_sleep_length() which the governor uses to pick a C-state.

Quoted 6 lines

For the most shallow one this will be a relatively short time, but for the deepest-but-one this might be a lot longer time.

your patch abuses a completely different, unrelated timer for this, with a pretty much unspecified frequency, that also has other side effects that we probably don't want.

What side effects come to mind? The only side effects that I could think of were (potentially) unwanted wakeups from C1. However, since C1 is presumably cheap to enter (and exit), it seemed like a worthwhile cost since you're almost certain to pick a deeper C state after wakeup.

That being said, your idea of per C-state timer is much better than relying on the scheduler tick. On most ARM systems, HZ is still pretty low (around 100), the time between ticks is relatively long, but on a HZ=1000 setup, I could see the extra wakeups having a penalty of their own.

Quoted 2 lines

it shouldn't be hard to do the right thing instead and make it a separate timer with a per C state timeout.

Agreed. Will give it a try.

Quoted 2 lines

(and I would say a default timeout of 10x the break even time that we already have in the structure)

OK.

Thanks for the review and suggestions,

Kevin