CFS idle injection
Subsystems (4)
cover CFS idle injection
Hi Peter and all,
A while ago, we had discussion about how powerclamp is broken in the sense of turning off idle ticks in the forced idle period.
https://lkml.org/lkml/2014/12/18/369
It was suggested to replace the current kthread play idle loop with a timer based runqueue throttling scheme. I finally got around to implement this and code is much simpler. I also have good test results in terms of efficiency, scalability, etc.
http://events.linuxfoundation.org/sites/events/files/slides/LinuxCon_Japan_2015_idle_injection1_0.pdf
slide #18+ shows the data on client and server.
I have two choices for this code:
1) be part of existing powerclamp driver but require exporting some sched APIs.
2) be part of sched since the genernal rule applies when it comes down to sycnhronized idle time for best power savings.
The patches below are for #2. There is a known problem with LOW RES timer mode that I am working on. But I am hoping to get review earlier.
We are entering a very power limited environment on client side, frequency scaling can only be efficient at certain range. e.g. on SKL, upto ~900MHz, anything below, it is increasingly more efficient to do C-states insertion if coordinated.
Looking forward, there are use case beyond thermal/power capping. I think we can consolidate ballanced partial busy workload that are evenly distributed among CPUs.
Please let me know what you think.
Thanks,
Jacob Pan (3):
ktime: add a roundup function
timer: relax tick stop in idle entry
sched: introduce synchronized idle injection
include/linux/ktime.h | 10 ++ include/linux/sched.h | 12 ++ include/linux/sched/sysctl.h | 5 + include/trace/events/sched.h | 23 +++ init/Kconfig | 8 + kernel/sched/fair.c | 345 +++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 3 + kernel/sysctl.c | 20 +++ kernel/time/tick-sched.c | 2 +- 9 files changed, 427 insertions(+), 1 deletion(-)
Signature · 1 line
1.9.1
RFC PATCH 1/3 ktime: add a roundup function
ktime roundup function can be used to keep timer aligned and prevent drift for recurring timeouts.
--- include/linux/ktime.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/linux/ktime.h +10 -0
@@ -233,6 +233,16 @@ static inline ktime_t ktime_sub_us(const ktime_t kt, const u64 usec)extern ktime_t ktime_add_safe (const ktime_t lhs,const ktime_t rhs); +static inline ktime_t ktime_roundup (ktime_t x,ktime_t y) +{ +u64 temp_tv64; + + temp_tv64 = x.tv64 + y.tv64 -1 ; + temp_tv64 =div64_u64 (temp_tv64, y.tv64); + x.tv64 = temp_tv64 * y.tv64; + +return x; +}/** * ktime_to_timespec_cond - convert a ktime_t variable to timespec * format only if the variable contains data
Signature · 1 line
1.9.1
RFC PATCH 2/3 timer: relax tick stop in idle entry
In reply to Jacob PanUpon entering idle, we can turn off tick if the next timeout is exactly one tick away. Otherwise, we could enter inner idle loop with tick still enabled, without resched set, the tick will continue during idle therefore less optimal in terms of energy savings.
--- kernel/time/tick-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/tick-sched.c +1 -1
@@ -606,7 +606,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,* restart it proper. */ delta = next_tick - basemono; -if (delta <= (u64 )TICK_NSEC ) { +if (delta < (u64 )TICK_NSEC ) { tick.tv64 =0 ;if (!ts->tick_stopped) goto out;
Signature · 1 line
1.9.1
RFC PATCH 3/3 sched: introduce synchronized idle injection
In reply to Jacob PanWith increasingly constrained power and thermal budget, it's often necessary to cap power via throttling. Throttling individual CPUs or devices at random times can help power capping but may not be optimal in terms of energy efficiency.
In general, the optimal solution in terms of energy efficiency is to align idle periods such that more shared circuits can be power gated to enter lower power states.
This patch introduces a scheduler based idle injection method, it works by blocking CFS runqueue synchronously and periodically. The actions on all online CPUs are orchestrated by per CPU hrtimers.
Two sysctl knobs are given to the userspce for selecting the percentage of idle time as well as the forced idle duration for each idle period injected.
Since only CFS class is targeted, other high priority tasks are not affected, such as RT and interrupts.
--- include/linux/sched.h | 12 ++ include/linux/sched/sysctl.h | 5 + include/trace/events/sched.h | 23 +++ init/Kconfig | 8 + kernel/sched/fair.c | 345 +++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 3 + kernel/sysctl.c | 20 +++ 7 files changed, 416 insertions(+)
include/linux/sched.h +12 -0
@@ -3181,3 +3181,15 @@ static inline unsigned long rlimit_max(unsigned int limit) }#endif + +#ifdef CONFIG_CFS_IDLE_INJECT +extern int proc_sched_cfs_idle_inject_pct_handler (struct ctl_table *table, +int write, +void __user *buffer, +size_t *length,loff_t *ppos); +extern int proc_sched_cfs_idle_inject_duration_handler (struct ctl_table *table, +int write, +void __user *buffer, +size_t *length,loff_t *ppos); + +#endif
include/linux/sched/sysctl.h +5 -0
@@ -81,6 +81,11 @@ extern unsigned int sysctl_sched_cfs_bandwidth_slice;extern unsigned int sysctl_sched_autogroup_enabled;#endif +#ifdef CONFIG_CFS_IDLE_INJECT +extern unsigned int sysctl_sched_cfs_idle_inject_pct; +extern unsigned int sysctl_sched_cfs_idle_inject_duration; +#endif +extern int sched_rr_timeslice; extern int sched_rr_handler(struct ctl_table *table, int write,
include/trace/events/sched.h +23 -0
@@ -566,6 +566,29 @@ TRACE_EVENT(sched_wake_idle_without_ipi,TP_printk ("cpu=%d" , __entry->cpu) ); + +/* +* Tracepoint for idle injection +*/ +TRACE_EVENT (sched_cfs_idle_inject, + + TP_PROTO(int cpu, int throttled), + +TP_ARGS (cpu, throttled), + +TP_STRUCT__entry ( + __field(int, cpu) +__field (int, throttled) + ), + +TP_fast_assign ( + __entry->cpu = cpu; + __entry->throttled = throttled; + ), + +TP_printk ("cpu=%d throttled=%d" , __entry->cpu, __entry->throttled) +); +#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */
init/Kconfig +8 -0
@@ -1086,6 +1086,14 @@ menuconfig CGROUP_SCHED bandwidth allocation to such task groups. It uses cgroups to group tasks. +config CFS_IDLE_INJECT + bool "Synchronized CFS idle injection" + default n + help + This option allows users to inject synchronized idle time across all CPUs. + The feature will align idle time such that the entire CPU package can be duty + cycled by going into the deepest/lowest power states. + if CGROUP_SCHED config FAIR_GROUP_SCHED bool "Group scheduling for SCHED_OTHER"
kernel/sched/fair.c +345 -0
366 lines not on this page · raw message
kernel/sched/sched.h +3 -0
@@ -417,6 +417,9 @@ struct cfs_rq {struct list_head throttled_list;#endif /* CONFIG_CFS_BANDWIDTH */ #endif /* CONFIG_FAIR_GROUP_SCHED */ +#ifdef CONFIG_CFS_IDLE_INJECT +int force_throttled; +#endif };static inline int rt_bandwidth_enabled (void )
kernel/sysctl.c +20 -0
@@ -433,6 +433,26 @@ static struct ctl_table kern_table[] = { .extra1 = &one, },#endif +#ifdef CONFIG_CFS_IDLE_INJECT + { + .procname = "sched_cfs_idle_inject_pct", + .data = &sysctl_sched_cfs_idle_inject_pct, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_sched_cfs_idle_inject_pct_handler, + .extra1 = &zero, + .extra2 = &one_hundred, + }, + { + .procname = "sched_cfs_idle_inject_duration", + .data = &sysctl_sched_cfs_idle_inject_duration, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_sched_cfs_idle_inject_duration_handler, + .extra1 = &four, + .extra2 = &one_hundred, + }, +#endif #ifdef CONFIG_PROVE_LOCKING { .procname = "prove_locking",
Signature · 1 line
1.9.1
Peter Zijlstra
maintainerRe: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 7 lines
kernel/sched/fair.c +3
-0@@ -5136,6 +5148,16 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev)struct task_struct *p;int new_tasks; +#ifdef CONFIG_CFS_IDLE_INJECT + if (cfs_rq->force_throttled && + !idle_cpu(cpu_of(rq)) &&
kernel/sched/fair.c pick_next_task_fair(struct rq *rq, struct task_struct *prev) · line 5163
Quoted 10 lines
kernel/sched/fair.c +7
-0+ !unlikely(local_softirq_pending())) { +/* forced idle, pick no task */ +trace_sched_cfs_idle_inject (cpu_of (rq),1 ); +update_curr (cfs_rq); +return NULL ; + } +#endif again:#ifdef CONFIG_FAIR_GROUP_SCHED if (!cfs_rq->nr_running)
So this is horrible...
This is a fast path, and you just put at least one cachemiss in it, a branch (without hint) and some goofy code (wth are we checking softirqs?).
How about you frob things such that cfs_rq->nr_running == 0 and we'll hit the idle: path, at that point you can test if we're forced idle and skip the load-balancing attempt.
There's probably a fair number of icky cases to deal with if you frob cfs_rq->nr_running, like the enqueue path which will add to it. We'll have to come up with something to not slow that down either.
The thing is, both schedule and enqueue are very hot and this is code that will 'never' run.
Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 20 lines · On Tue, 3 Nov 2015 14:31:20 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 7 lines
kernel/sched/fair.c +3
-0@@ -5136,6 +5148,16 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev) struct task_struct *p;int new_tasks; +#ifdef CONFIG_CFS_IDLE_INJECT + if (cfs_rq->force_throttled && + !idle_cpu(cpu_of(rq)) &&kernel/sched/fair.c pick_next_task_fair(struct rq *rq, struct · line 5163
Quoted 10 lines
kernel/sched/fair.c +7
-0+ !unlikely(local_softirq_pending())) { +/* forced idle, pick no task */ +trace_sched_cfs_idle_inject (cpu_of (rq),1 ); +update_curr (cfs_rq); +return NULL ; + } +#endif again:#ifdef CONFIG_FAIR_GROUP_SCHED if (!cfs_rq->nr_running)So this is horrible...
Quoted 4 lines
This is a fast path, and you just put at least one cachemiss in it, a branch (without hint) and some goofy code (wth are we checking softirqs?).
softirq is checked here since it is one of the conditions to stop sched tick. can_stop_idle_tick(). but we don't have to check here, you are right.
Quoted 10 lines
How about you frob things such that
cfs_rq->nr_running== 0 and we'll hit the idle: path, at that point you can test if we're forced idle and skip the load-balancing attempt.There's probably a fair number of icky cases to deal with if you frob
cfs_rq->nr_running, like the enqueue path which will add to it. We'll have to come up with something to not slow that down either.The thing is, both schedule and enqueue are very hot and this is code that will 'never' run.
Fair enough, I will give that a try. I understand we don't want to sacrifice the hot patch for some code almost 'never' run. But I also have follow up plan to use this code for consolidating/synchronizing idle during balanced semi-active workload. In that case, it may run more often. e.g.
Before:
CPU0 ______||| || |___________| || || |_____ CPU1 _________||| || |_______| || |_______
After:
CPU0 ______||| || |___________| || || |_____ CPU1 ______||| || |___________| || |_______
The goal is to have overlapping idle time if the load is already balanced. The energy saving can be significant.
Jacob
Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection
In reply to Peter ZijlstraQuoted 20 lines · On Tue, 3 Nov 2015 14:31:20 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 7 lines
kernel/sched/fair.c +3
-0@@ -5136,6 +5148,16 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev) struct task_struct *p;int new_tasks; +#ifdef CONFIG_CFS_IDLE_INJECT + if (cfs_rq->force_throttled && + !idle_cpu(cpu_of(rq)) &&kernel/sched/fair.c pick_next_task_fair(struct rq *rq, struct · line 5163
Quoted 10 lines
kernel/sched/fair.c +7
-0+ !unlikely(local_softirq_pending())) { +/* forced idle, pick no task */ +trace_sched_cfs_idle_inject (cpu_of (rq),1 ); +update_curr (cfs_rq); +return NULL ; + } +#endif again:#ifdef CONFIG_FAIR_GROUP_SCHED if (!cfs_rq->nr_running)So this is horrible...
Quoted 4 lines
This is a fast path, and you just put at least one cachemiss in it, a branch (without hint) and some goofy code (wth are we checking softirqs?).
softirq is checked here since it is one of the conditions to stop sched tick. can_stop_idle_tick(). but we don't have to check here, you are right.
Quoted 10 lines
How about you frob things such that
cfs_rq->nr_running== 0 and we'll hit the idle: path, at that point you can test if we're forced idle and skip the load-balancing attempt.There's probably a fair number of icky cases to deal with if you frob
cfs_rq->nr_running, like the enqueue path which will add to it. We'll have to come up with something to not slow that down either.The thing is, both schedule and enqueue are very hot and this is code that will 'never' run.
Fair enough, I will give that a try, I guess it would be costly and hard to scale if we were to dequeue/enqueue every se for every period of injection plus locking. Let me get some data first.
I understand we don't want to sacrifice the hot patch for some code almost 'never' run. But I also have follow up plan to use this code for consolidating/synchronizing idle during balanced semi-active workload. In that case, it may run more often. e.g.
Before:
CPU0 ______||| || |___________| || || |_____ CPU1 _________||| || |_______| || |_______
After:
CPU0 ______||| || |___________| || || |_____ CPU1 ______||| || |___________| || |_______
The goal is to have overlapping idle time if the load is already balanced. The energy saving can be significant.
Jacob
Peter Zijlstra
maintainerRe: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 3 lines · Jacob Pan
Fair enough, I will give that a try, I guess it would be costly and hard to scale if we were to dequeue/enqueue every se for every period of injection plus locking. Let me get some data first.
Yeah, don't go dequeue/enqueue everything, the regular throttle code doesn't do that either.
Throttling the root is more interesting though, becuase you can simply dequeue the child group representative, whereas you cannot dequeue the root (for being the root means there is no parent to dequeue from).
Quoted 9 lines
I understand we don't want to sacrifice the hot patch for some code almost 'never' run. But I also have follow up plan to use this code for consolidating/synchronizing idle during balanced semi-active workload. In that case, it may run more often. e.g.
Before:
CPU0 ______||| || |___________| || || |_____ CPU1 _________||| || |_______| || |_______
Quoted 7 lines
After:
CPU0 ______||| || |___________| || || |_____ CPU1 ______||| || |___________| || |_______The goal is to have overlapping idle time if the load is already balanced. The energy saving can be significant.
I can see such a scheme having a fairly big impact on latency, esp. with forced idleness such as this. That's not going to be popular for many workloads.
Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 3 lines · Peter Zijlstra
I can see such a scheme having a fairly big impact on latency, esp. with forced idleness such as this. That's not going to be popular for many workloads.
idle injection is a last ditch effort in thermal management, before this gets used the hardware already has clamped you to a low frequency, reduced memory speeds, probably dimmed your screen etc etc.
at this point there are 3 choices
1) Shut off the device
2) do uncoordinated idle injection for 40% of the time
3) do coordinated idle injection for 5% of the time
as much as force injecting idle in a synchronized way sucks, the alternatives are worse.
Quoted 1 line
Peter Zijlstra
maintainerRe: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 10 lines · Arjan van de Ven
Quoted 3 lines · Peter Zijlstra
I can see such a scheme having a fairly big impact on latency, esp. with forced idleness such as this. That's not going to be popular for many workloads.
idle injection is a last ditch effort in thermal management, before this gets used the hardware already has clamped you to a low frequency, reduced memory speeds, probably dimmed your screen etc etc.
Quoted 6 lines
at this point there are 3 choices
1) Shut off the device
2) do uncoordinated idle injection for 40% of the time
3) do coordinated idle injection for 5% of the timeas much as force injecting idle in a synchronized way sucks, the alternatives are worse.
OK, it wasn't put that way. I figured it was a way to use less power on any workload with idle time on.
That said; what kind of devices are we talking about here; mobile with pittyful heat dissipation? Surely a well designed server or desktop class system should never get into this situation in the first place.
Peter Zijlstra
maintainerRe: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 1 line · Peter Zijlstra
Quoted 1 line
idle injection is a last ditch effort in thermal management
It just grates at me a bit that we have to touch hot paths for such scenarios :/
Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection
In reply to Peter ZijlstraQuoted 16 lines · Peter Zijlstra
Quoted 15 lines · Arjan van de Ven
Quoted 3 lines · Peter Zijlstra
I can see such a scheme having a fairly big impact on latency, esp. with forced idleness such as this. That's not going to be popular for many workloads.
idle injection is a last ditch effort in thermal management, before this gets used the hardware already has clamped you to a low frequency, reduced memory speeds, probably dimmed your screen etc etc.
at this point there are 3 choices
1) Shut off the device
2) do uncoordinated idle injection for 40% of the time
3) do coordinated idle injection for 5% of the time
Quoted 4 lines
Quoted 1 line
as much as force injecting idle in a synchronized way sucks, the alternatives are worse.
OK, it wasn't put that way. I figured it was a way to use less power on any workload with idle time on.
so idle injection (as with pretty much every thermal management feature) is NOT a way to save on battery life. Every known method pretty much ends up sacrificing more in terms of performance than you gain in instant power that over time you end up using more (drain battery basically).
idle injection, if synchronized, is one of the more effective ones, e.g. give up the least efficiency compared to, say, unsynchronized or even inserting idle cycles in the CPU (T-states)... not even speaking of just turning the system off.
Quoted 4 lines
That said; what kind of devices are we talking about here; mobile with pittyful heat dissipation? Surely a well designed server or desktop class system should never get into this situation in the first place.
a well designed server may not, but the datacenter it is in may.
for example if the AC goes out, but also, sometimes the datacenter's peak heat dissapation
can exceed the AC capacity (which is outside temperature dependent.. yay global warming),
which may require an urgent reduction over a series of machines for the duration of the peak load/peak temperature (usually just inserting a little bit, say 1%, over all servers will do)
Quoted 1 line
It just grates at me a bit that we have to touch hot paths for such
scenarios :/
well we have this as a driver right now that does not touch hot paths, but it seems you and tglx also hate that approach with a passion....
Peter Zijlstra
maintainerRe: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 2 lines · Arjan van de Ven
well we have this as a driver right now that does not touch hot paths, but it seems you and tglx also hate that approach with a passion....
The current code is/was broken, but when I tried fixing it, tglx objected to the entire approach yes...
Thomas, no arm twisting can convince you to reconsider the fake idle task approach?
Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 9 lines · Peter Zijlstra
Quoted 2 lines · Arjan van de Ven
well we have this as a driver right now that does not touch hot paths, but it seems you and tglx also hate that approach with a passion....
The current code is/was broken, but when I tried fixing it, tglx objected to the entire approach yes...
Thomas, no arm twisting can convince you to reconsider the fake idle task approach?
As long as the thing just calls mwait or whatever twisting might be successful, but I'm not going to change my mind on something calling into the idle related routines (timers, rcu, etc..) and violates all sensible assumptions we make in that code. It's complex enough already and we really do not need subtle wreckage by half baken and unreviewed drivers to add more complexity.
Thanks,
tglx
Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection
In reply to Arjan van de VenQuoted 7 lines · Arjan van de Ven
Quoted 1 line · Peter Zijlstra
It just grates at me a bit that we have to touch hot paths for such
scenarios :/
well we have this as a driver right now that does not touch hot paths, but it seems you and tglx also hate that approach with a passion....
Right. It's a horror to deal with tasks which try to impersonate idle while actually running as highest priority task in the system. We really want the scheduler to know about it. Yes, we probably have to pay the price for some extra check in the hot path, but that's way more sensible than figuring out how 'want to be idle' RT tasks wreckage the world and some more.
Thanks,
tglx
Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection
In reply to Peter ZijlstraQuoted 7 lines · On Thu, 5 Nov 2015 15:33:32 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 6 lines · Arjan van de Ven
Quoted 3 lines · Peter Zijlstra
I can see such a scheme having a fairly big impact on latency, esp. with forced idleness such as this. That's not going to be popular for many workloads.
Quoted 5 lines
Quoted 5 lines
idle injection is a last ditch effort in thermal management, before this gets used the hardware already has clamped you to a low frequency, reduced memory speeds, probably dimmed your screen etc etc.
Just to clarify, the low frequency here is not necessarily the minimum frequency. It is usually the Pe (max efficiency).
Quoted 8 lines
Quoted 7 lines
at this point there are 3 choices
1) Shut off the device
2) do uncoordinated idle injection for 40% of the time
3) do coordinated idle injection for 5% of the timeas much as force injecting idle in a synchronized way sucks, the alternatives are worse.
Quoted 6 lines
OK, it wasn't put that way. I figured it was a way to use less power on any workload with idle time on.
That said; what kind of devices are we talking about here; mobile with pittyful heat dissipation? Surely a well designed server or desktop class system should never get into this situation in the first place.
Yes, Mobile devices, especially fan-less, are the targets. On one side we all desire high performance, but it does not come free. The performance tax might limit the ability to scale at the low end. e.g. on skylake-y P1 is 1.5GHz, Pe(max efficiency, dynamic) is ~900MHz, Pmin is 400Mhz.
When thermal limit occurs, there are two options
1. limit freq to Pmin 400Mhz and run 100%
2. let CPU run at ~800Mhz but inject idle at 50%
#2 option provides better performance per watt since it can scale nearly linearly, i.e. 50% performance at 50% power. For my own limited testing and this can vary greatly by parts, running at Pmin vs Pe can lose 30% perf per watt.
Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 10 lines · Jacob Pan
Quoted 7 lines · On Thu, 5 Nov 2015 15:33:32 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 6 lines · Arjan van de Ven
Quoted 3 lines · Peter Zijlstra
I can see such a scheme having a fairly big impact on latency, esp. with forced idleness such as this. That's not going to be popular for many workloads.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
idle injection is a last ditch effort in thermal management, before this gets used the hardware already has clamped you to a low frequency, reduced memory speeds, probably dimmed your screen etc etc.
Just to clarify, the low frequency here is not necessarily the minimum frequency. It is usually the Pe (max efficiency).
to translate that from Intelese to English:
The system already is at the lowest frequency that's relatively efficient. To go even lower in instant power consumption (e.g. heat) by even a little bit, a LOT of frequency needs to be sacrificed.
Idle injection sucks. But it's more efficient (at the point that it would get used) than any other methods, so it also sucks less than those other methods for the same amount of reduction in heat generation. It only gets used if the system HAS to reduce the heat generation, either because it's a mobile device with little cooling capacity, or because the airconditioning in your big datacenter is currently not able to keep up.
Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection
In reply to Peter ZijlstraQuoted 9 lines · On Thu, 5 Nov 2015 11:09:22 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 9 lines
Before:
CPU0 ______||| || |___________| || || |_____ CPU1 _________||| || |_______| || |_______After:
CPU0 ______||| || |___________| || || |_____ CPU1 ______||| || |___________| || |_______
Quoted 6 lines
Quoted 2 lines
The goal is to have overlapping idle time if the load is already balanced. The energy saving can be significant.
I can see such a scheme having a fairly big impact on latency, esp. with forced idleness such as this. That's not going to be popular for many workloads.
agreed, it would be for limited workload. the key is to identify such workloads at runtime. I am thinking to use the load average of the busiest CPU as reference for consolidation, will not go beyond that.
For the patch I have today and if you play a game like this one
http://www.agame.com/game/cut-the-rope
Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 18 lines · On Thu, 5 Nov 2015 11:27:32 -0800 Jacob Pan <[email protected]>…
Quoted 9 lines · On Thu, 5 Nov 2015 11:09:22 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 9 lines
Before:
CPU0 ______||| || |___________| || || |_____ CPU1 _________||| || |_______| || |_______After:
CPU0 ______||| || |___________| || || |_____ CPU1 ______||| || |___________| || |_______Quoted 6 lines
Quoted 2 lines
The goal is to have overlapping idle time if the load is already balanced. The energy saving can be significant.
I can see such a scheme having a fairly big impact on latency, esp. with forced idleness such as this. That's not going to be popular for many workloads.
Quoted 6 lines
agreed, it would be for limited workload. the key is to identify such workloads at runtime. I am thinking to use the load average of the busiest CPU as reference for consolidation, will not go beyond that.
For the patch I have today and if you play a game like this one
http://www.agame.com/game/cut-the-rope
sorry, hit the wrong button before finishing the email.
and set duration to 5, and 20% idle, it does not affect user experience much. It saves ~15% power on my BDW ultrabook. Other unbalanced workload such as video playback don't benefit, should be avoided.
Peter Zijlstra
maintainerRe: [RFC PATCH 3/3] sched: introduce synchronized idle injection
In reply to Peter ZijlstraQuoted 4 lines · Peter Zijlstra
Quoted 4 lines
(quoted diff) +0
-0@@ -5136,6 +5148,16 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev) struct task_struct *p; int new_tasks;
Quoted 15 lines
Review pick_next_task_fair(struct rq *rq, struct task_struct *prev) · line 5163
Quoted 13 lines
(quoted diff) +10
-0+#ifdef CONFIG_CFS_IDLE_INJECT + if (cfs_rq->force_throttled && + !idle_cpu(cpu_of(rq)) && + !unlikely(local_softirq_pending())) { + /* forced idle, pick no task */ + trace_sched_cfs_idle_inject(cpu_of(rq), 1); + update_curr(cfs_rq); + return NULL; + } +#endif again: #ifdef CONFIG_FAIR_GROUP_SCHED if (!cfs_rq->nr_running)So this is horrible...
So this isn't ideal either (I rather liked the previous approach of a random task assuming idle, but tglx hated that). This should at least not touch extra cachelines in the hot paths, although it does add a few extra instructions :/
Very limited testing didn't show anything horrible.
Your throttle would:
raw_spin_lock_irqsave(&rq->lock, flags); rq->cfs.forced_idle = true; resched = rq->cfs.runnable; rq->cfs.runnable = false; raw_spin_unlock_irqrestore(&rq->lock, flags); if (resched) resched_cpu(cpu_of(rq));
And your unthrottle:
raw_spin_lock_irqsave(&rq->lock, flags); rq->cfs.forced_idle = false; resched = rq->cfs.runnable = !!rq->cfs.nr_running; raw_spin_unlock_irqrestore(&rq->lock, flags); if (resched) resched_cpu(cpu_of(rq));
--- kernel/sched/fair.c | 13 +++++++++---- kernel/sched/sched.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-)
kernel/sched/fair.c +9 -4
@@ -2341,7 +2341,8 @@ account_entity_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se)list_add (&se->group_node, &rq->cfs_tasks); }#endif - cfs_rq->nr_running++; +if (!cfs_rq->nr_running++ && !cfs_rq->forced_idle) + cfs_rq->runnable = true; } static void
@@ -2354,7 +2355,8 @@ account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se)account_numa_dequeue (rq_of (cfs_rq),task_of (se));list_del_init (&se->group_node); } - cfs_rq->nr_running--; +if (!--cfs_rq->nr_running && !cfs_rq->forced_idle) + cfs_rq->runnable = false; }#ifdef CONFIG_FAIR_GROUP_SCHED
@@ -5204,7 +5206,7 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev) again:#ifdef CONFIG_FAIR_GROUP_SCHED -if (!cfs_rq->nr_running) +if (!cfs_rq->runnable) goto idle;if (prev->sched_class != &fair_sched_class)
@@ -5283,7 +5285,7 @@ simple: cfs_rq = &rq->cfs;#endif -if (!cfs_rq->nr_running) +if (!cfs_rq->runnable) goto idle;put_prev_task (rq, prev);
@@ -5302,6 +5304,9 @@ simple:return p; idle: +if (cfs_rq->forced_idle) +return NULL ; +/* * This is OK, because current is on_cpu, which avoids it being picked * for load-balance and preemption/IRQs are still disabled avoiding
kernel/sched/sched.h +1 -0
@@ -347,6 +347,7 @@ struct cfs_bandwidth { };struct cfs_rq {struct load_weight load;unsigned int nr_running, h_nr_running; +unsigned int runnable, forced_idle;u64 exec_clock;u64 min_vruntime;
Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 21 lines · On Thu, 5 Nov 2015 14:59:52 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Peter Zijlstra
Quoted 4 lines
(quoted diff) +0
-0@@ -5136,6 +5148,16 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev) struct task_struct *p; int new_tasks;Quoted 15 lines
Review pick_next_task_fair(struct rq *rq, struct · line 5163
Quoted 13 lines
(quoted diff) +10
-0+#ifdef CONFIG_CFS_IDLE_INJECT + if (cfs_rq->force_throttled && + !idle_cpu(cpu_of(rq)) && + !unlikely(local_softirq_pending())) { + /* forced idle, pick no task */ + trace_sched_cfs_idle_inject(cpu_of(rq), 1); + update_curr(cfs_rq); + return NULL; + } +#endif again: #ifdef CONFIG_FAIR_GROUP_SCHED if (!cfs_rq->nr_running)So this is horrible...
Quoted 7 lines
So this isn't ideal either (I rather liked the previous approach of a random task assuming idle, but tglx hated that). This should at least not touch extra cachelines in the hot paths, although it does add a few extra instructions :/
Very limited testing didn't show anything horrible.
I did some testing with the code below, it shows random
[ 150.442597] NOHZ: local_softirq_pending 02 [ 153.032673] NOHZ: local_softirq_pending 202 [ 153.203785] NOHZ: local_softirq_pending 202 [ 153.206486] NOHZ: local_softirq_pending 282
I recalled that was why i checked for local_softirq_pending in the initial patch, still trying to find out how we can avoid that. These also causes non stop sched ticks in the inner idle loop.
Quoted 82 lines
Your throttle would:
raw_spin_lock_irqsave(&rq->lock, flags); rq->cfs.forced_idle = true; resched = rq->cfs.runnable; rq->cfs.runnable = false; raw_spin_unlock_irqrestore(&rq->lock, flags); if (resched) resched_cpu(cpu_of(rq));And your unthrottle:
raw_spin_lock_irqsave(&rq->lock, flags); rq->cfs.forced_idle = false; resched = rq->cfs.runnable = !!rq->cfs.nr_running; raw_spin_unlock_irqrestore(&rq->lock, flags); if (resched) resched_cpu(cpu_of(rq));--- kernel/sched/fair.c | 13 +++++++++---- kernel/sched/sched.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-)kernel/sched/fair.c +9
-4@@ -2341,7 +2341,8 @@ account_entity_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se) list_add(&se->group_node, &rq->cfs_tasks); }#endif - cfs_rq->nr_running++; +if (!cfs_rq->nr_running++ && !cfs_rq->forced_idle) + cfs_rq->runnable = true; } static void@@ -2354,7 +2355,8 @@ account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se) account_numa_dequeue(rq_of(cfs_rq),task_of (se ));list_del_init (&se->group_node); } - cfs_rq->nr_running--; +if (!--cfs_rq->nr_running && !cfs_rq->forced_idle) + cfs_rq->runnable = false; }#ifdef CONFIG_FAIR_GROUP_SCHED @@ -5204,7 +5206,7 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev) again: #ifdef CONFIG_FAIR_GROUP_SCHED -if (!cfs_rq->nr_running) +if (!cfs_rq->runnable) goto idle;if (prev->sched_class != &fair_sched_class)@@ -5283,7 +5285,7 @@ simple: cfs_rq = &rq->cfs;#endif -if (!cfs_rq->nr_running) +if (!cfs_rq->runnable) goto idle;put_prev_task (rq, prev);@@ -5302,6 +5304,9 @@ simple:return p; idle: +if (cfs_rq->forced_idle) +return NULL ; +/* * This is OK, because current is on_cpu, which avoids it being picked
* for load-balance and preemption/IRQs are still disabled
avoiding diff --gita/kernel/sched/sched.hb/kernel/sched/sched.hindex efd3bfc..33d355d 100644
kernel/sched/sched.h struct cfs_bandwidth { }; · line 353
Quoted 7 lines
kernel/sched/sched.h +1
-0@@ -347,6 +347,7 @@ struct cfs_bandwidth { };struct cfs_rq {struct load_weight load;unsigned int nr_running, h_nr_running; +unsigned int runnable, forced_idle;u64 exec_clock;u64 min_vruntime;
[Jacob Pan]
Peter Zijlstra
maintainerRe: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 8 lines · Jacob Pan
I did some testing with the code below, it shows random
[ 150.442597] NOHZ: local_softirq_pending 02 [ 153.032673] NOHZ: local_softirq_pending 202 [ 153.203785] NOHZ: local_softirq_pending 202 [ 153.206486] NOHZ: local_softirq_pending 282I recalled that was why i checked for
local_softirq_pendingin the initial patch, still trying to find out how we can avoid that. These also causes non stop sched ticks in the inner idle loop.
Check the softirq stuff before calling throttle ?
Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 11 lines · On Fri, 6 Nov 2015 08:45:10 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 8 lines · Jacob Pan
I did some testing with the code below, it shows random
[ 150.442597] NOHZ: local_softirq_pending 02 [ 153.032673] NOHZ: local_softirq_pending 202 [ 153.203785] NOHZ: local_softirq_pending 202 [ 153.206486] NOHZ: local_softirq_pending 282I recalled that was why i checked for
local_softirq_pendingin the initial patch, still trying to find out how we can avoid that. These also causes non stop sched ticks in the inner idle loop.
Quoted 1 line
Check the softirq stuff before calling throttle ?
yes, played with it but it seems there are other cases causing pending softirq in idle in addition to throttle. I still haven't figure it out, this problem only shows up in heavy irq, network load. e.g. compile kernel over NFS. Debugging.
Re: [RFC PATCH 3/3] sched: introduce synchronized idle injection
Quoted 6 lines · On Fri, 6 Nov 2015 15:49:29 -0800 Jacob Pan <[email protected]>…
Quoted 1 line
Check the softirq stuff before calling throttle ?
yes, played with it but it seems there are other cases causing pending softirq in idle in addition to throttle. I still haven't figure it out, this problem only shows up in heavy irq, network load. e.g. compile kernel over NFS. Debugging.
ok, I added a check for softirq_pending and a retry. seems to work. Now idle injection will allow softirq and softirqd to run. The caveat is that during that injection period, if softirqd does not run for the entire duration, other normal tasks would also run during forced idle. But just for that period. I guess we have to strike for the right balance for QoS and overhead. For most workload, pending softirq is rare so the tasks slip under softirqd are also rare. Will send out V2 soon.
Thanks,
Jacob
Hello Jacob,
Quoted 13 lines · Jacob Pan
Hi Peter and all,
A while ago, we had discussion about how powerclamp is broken in the sense of turning off idle ticks in the forced idle period.
https://lkml.org/lkml/2014/12/18/369It was suggested to replace the current kthread play idle loop with a timer based runqueue throttling scheme. I finally got around to implement this and code is much simpler. I also have good test results in terms of efficiency, scalability, etc.
http://events.linuxfoundation.org/sites/events/files/slides/LinuxCon_Japan_2015_idle_injection1_0.pdf
slide #18+ shows the data on client and server.
Quoted 9 lines
I have two choices for this code:
1) be part of existing powerclamp driver but require exporting some sched APIs.
2) be part of sched since the genernal rule applies when it comes down to sycnhronized idle time for best power savings.The patches below are for #2. There is a known problem with LOW RES timer mode that I am working on. But I am hoping to get review earlier.
I also like #2 too. Specially now that it is not limited to a specific platform. One question though, could you still keep the cooling device support of it? In some systems, it might make sense to enable / disable idle injections based on temperature.
Was there any particular reason you dropped the cooling device support?
BR,
Eduardo Valentin
Quoted 38 lines
We are entering a very power limited environment on client side, frequency scaling can only be efficient at certain range. e.g. on SKL, upto ~900MHz, anything below, it is increasingly more efficient to do C-states insertion if coordinated.
Looking forward, there are use case beyond thermal/power capping. I think we can consolidate ballanced partial busy workload that are evenly distributed among CPUs.
Please let me know what you think.
Thanks,
Jacob Pan (3):
ktime: add a roundup function
timer: relax tick stop in idle entry
sched: introduce synchronized idle injectioninclude/linux/ktime.h | 10 ++ include/linux/sched.h | 12 ++ include/linux/sched/sysctl.h | 5 + include/trace/events/sched.h | 23 +++ init/Kconfig | 8 + kernel/sched/fair.c | 345 +++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 3 + kernel/sysctl.c | 20 +++ kernel/time/tick-sched.c | 2 +- 9 files changed, 427 insertions(+), 1 deletion(-)Signature · 7 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Quoted 27 lines · On Tue, 3 Nov 2015 22:06:55 -0800 Eduardo Valentin <[email protected]> wrote:
Hello Jacob,
Quoted 19 lines · Jacob Pan
Hi Peter and all,
A while ago, we had discussion about how powerclamp is broken in the sense of turning off idle ticks in the forced idle period.
https://lkml.org/lkml/2014/12/18/369It was suggested to replace the current kthread play idle loop with a timer based runqueue throttling scheme. I finally got around to implement this and code is much simpler. I also have good test results in terms of efficiency, scalability, etc.
http://events.linuxfoundation.org/sites/events/files/slides/LinuxCon_Japan_2015_idle_injection1_0.pdf
slide #18+ shows the data on client and server.I have two choices for this code:
1) be part of existing powerclamp driver but require exporting some sched APIs.
2) be part of sched since the genernal rule applies when it comes down to sycnhronized idle time for best power savings.Quoted 4 lines
The patches below are for #2. There is a known problem with LOW RES timer mode that I am working on. But I am hoping to get review earlier.
Quoted 5 lines
I also like #2 too. Specially now that it is not limited to a specific platform. One question though, could you still keep the cooling device support of it? In some systems, it might make sense to enable / disable idle injections based on temperature.
One of the key difference between 1 and 2 is that #2 is open loop control, since we don't have CPU c-states info baked into scheduler. To close the loop, perhaps we can export some internal APIs to the thermal subsystem then the thermal governors can pick the condition to inject idle.
Quoted 3 lines
Was there any particular reason you dropped the cooling device support?
I did sysctl instead of thermal sysfs to conform the rest of the sched tuning knobs. We could also have a proxy cooling device to call internal APIs mentioned above.
Another reason is that, I intend to extend beyond thermal. Where we can consolidate/sync idle work in semi-active and balanced workload.
Thanks for the suggestions,
Jacob
Quoted 43 lines
BR,
Eduardo Valentin
Quoted 38 lines
We are entering a very power limited environment on client side, frequency scaling can only be efficient at certain range. e.g. on SKL, upto ~900MHz, anything below, it is increasingly more efficient to do C-states insertion if coordinated.
Looking forward, there are use case beyond thermal/power capping. I think we can consolidate ballanced partial busy workload that are evenly distributed among CPUs.
Please let me know what you think.
Thanks,
Jacob Pan (3):
ktime: add a roundup function
timer: relax tick stop in idle entry
sched: introduce synchronized idle injectioninclude/linux/ktime.h | 10 ++ include/linux/sched.h | 12 ++ include/linux/sched/sysctl.h | 5 + include/trace/events/sched.h | 23 +++ init/Kconfig | 8 + kernel/sched/fair.c | 345 +++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 3 + kernel/sysctl.c | 20 +++ kernel/time/tick-sched.c | 2 +- 9 files changed, 427 insertions(+), 1 deletion(-)Signature · 7 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[Jacob Pan]
Quoted 40 lines · Jacob Pan
Quoted 27 lines · On Tue, 3 Nov 2015 22:06:55 -0800 Eduardo Valentin <[email protected]> wrote:
Hello Jacob,
Quoted 19 lines · Jacob Pan
Hi Peter and all,
A while ago, we had discussion about how powerclamp is broken in the sense of turning off idle ticks in the forced idle period.
https://lkml.org/lkml/2014/12/18/369It was suggested to replace the current kthread play idle loop with a timer based runqueue throttling scheme. I finally got around to implement this and code is much simpler. I also have good test results in terms of efficiency, scalability, etc.
http://events.linuxfoundation.org/sites/events/files/slides/LinuxCon_Japan_2015_idle_injection1_0.pdf
slide #18+ shows the data on client and server.I have two choices for this code:
1) be part of existing powerclamp driver but require exporting some sched APIs.
2) be part of sched since the genernal rule applies when it comes down to sycnhronized idle time for best power savings.Quoted 4 lines
The patches below are for #2. There is a known problem with LOW RES timer mode that I am working on. But I am hoping to get review earlier.
Quoted 5 lines
I also like #2 too. Specially now that it is not limited to a specific platform. One question though, could you still keep the cooling device support of it? In some systems, it might make sense to enable / disable idle injections based on temperature.
One of the key difference between 1 and 2 is that #2 is open loop control, since we don't have CPU c-states info baked into scheduler. To close the loop, perhaps we can export some internal APIs to the thermal subsystem then the thermal governors can pick the condition to inject idle.
Quoted 6 lines
Quoted 3 lines
Was there any particular reason you dropped the cooling device support?
I did sysctl instead of thermal sysfs to conform the rest of the sched tuning knobs. We could also have a proxy cooling device to call internal APIs mentioned above.
I think we should have cooling device as we are already using this cooling device. Once it pass RFC stage,I think we should consider add this.
Thanks,
Srinivas
Quoted 52 lines
Another reason is that, I intend to extend beyond thermal. Where we can consolidate/sync idle work in semi-active and balanced workload.
Thanks for the suggestions,
Jacob
Quoted 43 lines
BR,
Eduardo Valentin
Quoted 38 lines
We are entering a very power limited environment on client side, frequency scaling can only be efficient at certain range. e.g. on SKL, upto ~900MHz, anything below, it is increasingly more efficient to do C-states insertion if coordinated.
Looking forward, there are use case beyond thermal/power capping. I think we can consolidate ballanced partial busy workload that are evenly distributed among CPUs.
Please let me know what you think.
Thanks,
Jacob Pan (3):
ktime: add a roundup function
timer: relax tick stop in idle entry
sched: introduce synchronized idle injectioninclude/linux/ktime.h | 10 ++ include/linux/sched.h | 12 ++ include/linux/sched/sysctl.h | 5 + include/trace/events/sched.h | 23 +++ init/Kconfig | 8 + kernel/sched/fair.c | 345 +++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 3 + kernel/sysctl.c | 20 +++ kernel/time/tick-sched.c | 2 +- 9 files changed, 427 insertions(+), 1 deletion(-)Signature · 7 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/[Jacob Pan]
Hello Jacob, Srinivas,
Quoted 1 line · Srinivas Pandruvada
On Wed, 2015-11-04 at 08:58 -0800, Jacob Pan wrote:
<cut>
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 10 lines
I have two choices for this code:
1) be part of existing powerclamp driver but require exporting some sched APIs.
2) be part of sched since the genernal rule applies when it comes down to sycnhronized idle time for best power savings.The patches below are for #2. There is a known problem with LOW RES timer mode that I am working on. But I am hoping to get review earlier.
I also like #2 too. Specially now that it is not limited to a specific platform. One question though, could you still keep the cooling device support of it? In some systems, it might make sense to enable / disable idle injections based on temperature.
Quoted 5 lines
Quoted 5 lines
One of the key difference between 1 and 2 is that #2 is open loop control, since we don't have CPU c-states info baked into scheduler. To close the loop, perhaps we can export some internal APIs to the thermal subsystem then the thermal governors can pick the condition to inject idle.
Jacob,
I also like this direction. Having the proper APIs exported, creating a cooling device that use them would be natural path. Then, one could create a thermal zone plugging a governor and the idle injection cooling device that uses the exported APIs.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Was there any particular reason you dropped the cooling device support?
I did sysctl instead of thermal sysfs to conform the rest of the sched tuning knobs. We could also have a proxy cooling device to call internal APIs mentioned above.
Agreed here then.
Quoted 3 lines
I think we should have cooling device as we are already using this cooling device. Once it pass RFC stage,I think we should consider add this.
Srinivas,
Yes, that seens to be a good path to follow. Thanks.
Quoted 5 lines
Thanks,
SrinivasQuoted 3 lines
Another reason is that, I intend to extend beyond thermal. Where we can consolidate/sync idle work in semi-active and balanced workload.
I see.
BR,
Eduardo Valentin
Peter Zijlstra
maintainerPeople, trim your emails!
Quoted 7 lines · Jacob Pan
Quoted 4 lines
I also like #2 too. Specially now that it is not limited to a specific platform. One question though, could you still keep the cooling device support of it? In some systems, it might make sense to enable / disable idle injections based on temperature.
One of the key difference between 1 and 2 is that #2 is open loop control, since we don't have CPU c-states info baked into scheduler.
_yet_, there's people working on that. The whole power aware scheduling stuff needs that.
Quoted 3 lines
To close the loop, perhaps we can export some internal APIs to the thermal subsystem then the thermal governors can pick the condition to inject idle.
I would much rather that all be part of the power aware stuff, such that the scheduler itself is aware of thermal limits and can migrate load away if needed.
Quoted 15 lines · Peter Zijlstra
People, trim your emails!
Quoted 7 lines · Jacob Pan
Quoted 4 lines
I also like #2 too. Specially now that it is not limited to a specific platform. One question though, could you still keep the cooling device support of it? In some systems, it might make sense to enable / disable idle injections based on temperature.
One of the key difference between 1 and 2 is that #2 is open loop control, since we don't have CPU c-states info baked into scheduler.
_yet_, there's people working on that. The whole power aware scheduling stuff needs that.
Quoted 7 lines
Quoted 3 lines
To close the loop, perhaps we can export some internal APIs to the thermal subsystem then the thermal governors can pick the condition to inject idle.
I would much rather that all be part of the power aware stuff, such that the scheduler itself is aware of thermal limits and can migrate load away if needed.
I was wondering if we could use cpu capacity as the interface between the thermal sub-system and the scheduler. This would be better than dealing with frequency caps and idle injection percentages directly in the scheduler.
We've been playing with making the scheduler respect capacity caps due to thermal constraints and have tasks migrated away to less capped cores.
It would be great if in addition to the frequency caps, we could add idle injection to the arsenal. This would allow building policies on top such as -
* pure idle injection where frequency capping is unsuitable (or unavailable)
* a smooth continuum of capacities using a combination of frequency and capacity capping
* idle injection once frequencies have been capped to the lowest feasible values (as suggested in the cover letter)
One question about the implementation in these patches - should the implementation hook into pick_next_task in core instead of CFS? Higher priority tasks might get in the way of idle injection.
Quoted 4 lines
-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 3 lines · On Fri, 06 Nov 2015 16:50:15 +0000 Punit Agrawal <[email protected]> wrote:
* idle injection once frequencies have been capped to the lowest feasible values (as suggested in the cover letter)
actually, I was suggesting to start considering idle injection once frequency capped to the energy efficient point, which can be much higher than the lowest frequency. The idea being, deep idle power is negligible compared to running power which allows near linear power-perf scaling for balanced workload.
Below energy efficient frequency, continuous lowering frequency may lose disproportion performance vs. power. i.e. worse than linear.
Quoted 3 lines
One question about the implementation in these patches - should the implementation hook into
pick_next_taskin core instead of CFS? Higher priority tasks might get in the way of idle injection.
My take is that RT and throttling will never go well together since they are conflicting in principle.
Quoted 6 lines · Jacob Pan
Quoted 3 lines · On Fri, 06 Nov 2015 16:50:15 +0000 Punit Agrawal <[email protected]> wrote:
* idle injection once frequencies have been capped to the lowest feasible values (as suggested in the cover letter)
Quoted 8 lines
actually, I was suggesting to start considering idle injection once frequency capped to the energy efficient point, which can be much higher than the lowest frequency. The idea being, deep idle power is negligible compared to running power which allows near linear power-perf scaling for balanced workload.
Below energy efficient frequency, continuous lowering frequency may lose disproportion performance vs. power. i.e. worse than linear.
I agree. I was making that assumption that with the ability to inject idle states, there wouldn't be a need to expose the inefficient frequency states.
Do you still see a reason to do that?
Quoted 5 lines
Quoted 3 lines
One question about the implementation in these patches - should the implementation hook into
pick_next_taskin core instead of CFS? Higher priority tasks might get in the way of idle injection.My take is that RT and throttling will never go well together since they are conflicting in principle.
I am not sure I follow. If RT (or other higher priority classes) can't be throttled then the CPUs are not able to contribute towards constraining power consumption and hence temperature.
This is especially true in certain platforms where tasks belong to the RT class to maintain user experience, e.g., audio and video.
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Peter Zijlstra
maintainerQuoted 10 lines · Punit Agrawal
Quoted 2 lines · Jacob Pan
My take is that RT and throttling will never go well together since they are conflicting in principle.
I am not sure I follow. If RT (or other higher priority classes) can't be throttled then the CPUs are not able to contribute towards constraining power consumption and hence temperature.
This is especially true in certain platforms where tasks belong to the RT class to maintain user experience, e.g., audio and video.
Audio/Video playback generally doesn't take a _lot_ of time these days. What is important though is _when_ it happens.
And media playback typically already has a very well defined and stable cadence (24Hz or whatnot). What you want is for your idle injector to sync up with that, not disrupt it.
For other workloads, missing a deadline is about as bad as destroying the chip, complete system shutdown might be safer than getting delayed. (The very tired scenario of a saw, a laser and your finger; you want to shut down the entire machine rather than just cut off your finger.)
Quoted 12 lines · On Mon, 9 Nov 2015 15:15:34 +0100 Peter Zijlstra <[email protected]> wrote:
Quoted 10 lines · Punit Agrawal
Quoted 2 lines · Jacob Pan
My take is that RT and throttling will never go well together since they are conflicting in principle.
I am not sure I follow. If RT (or other higher priority classes) can't be throttled then the CPUs are not able to contribute towards constraining power consumption and hence temperature.
This is especially true in certain platforms where tasks belong to the RT class to maintain user experience, e.g., audio and video.
Quoted 7 lines
Audio/Video playback generally doesn't take a _lot_ of time these days. What is important though is _when_ it happens.
And media playback typically already has a very well defined and stable cadence (24Hz or whatnot). What you want is for your idle injector to sync up with that, not disrupt it.
Agreed, i have tested idle injection on video playback (mostly one cpu busy, no sync with gpu), it does not do well to improve energy efficiency. With the video playback being offloaded, there is no thermal condition either. So outside the scope of this first patchst trying to solve. The ability to sync with external pattern, could be the next step. kind of like pll in hw :).
Quoted 8 lines
For other workloads, missing a deadline is about as bad as destroying the chip, complete system shutdown might be safer than getting delayed. (The very tired scenario of a saw, a laser and your finger; you want to shut down the entire machine rather than just cut off your finger.)
Hi,
Quoted 12 lines · Peter Zijlstra
Quoted 10 lines · Punit Agrawal
Quoted 2 lines · Jacob Pan
My take is that RT and throttling will never go well together since they are conflicting in principle.
I am not sure I follow. If RT (or other higher priority classes) can't be throttled then the CPUs are not able to contribute towards constraining power consumption and hence temperature.
This is especially true in certain platforms where tasks belong to the RT class to maintain user experience, e.g., audio and video.
Quoted 7 lines
Audio/Video playback generally doesn't take a _lot_ of time these days. What is important though is _when_ it happens.
And media playback typically already has a very well defined and stable cadence (24Hz or whatnot). What you want is for your idle injector to sync up with that, not disrupt it.
Do you think that using SCHED_DEADLINE here would be completely foolish? I mean, we would have the duty_cycle/period thing for free, it would be know to the scheduler (as to maybe address Thomas' concerns) and we could think to make idle injection part of system analysis (for the soft-RT use cases).
Thanks,
- Juri
Quoted 12 lines
For other workloads, missing a deadline is about as bad as destroying the chip, complete system shutdown might be safer than getting delayed. (The very tired scenario of a saw, a laser and your finger; you want to shut down the entire machine rather than just cut off your finger.)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Peter Zijlstra
maintainerQuoted 5 lines · Juri Lelli
Do you think that using
SCHED_DEADLINEhere would be completely foolish? I mean, we would have the duty_cycle/period thing for free, it would be know to the scheduler (as to maybe address Thomas' concerns) and we could think to make idle injection part of system analysis (for the soft-RT use cases).
DEADLINE would be awesome, but I think we need work on two fronts before we can really sell it as the awesome that it is ;-)
- greedy and or statistical bounds
- !priv
The first is such that we can better deal with the erratic nature of media decode without going full worst case on it, and the second just makes it so much more accessible.
Quoted 10 lines · Peter Zijlstra
Quoted 5 lines · Juri Lelli
Do you think that using
SCHED_DEADLINEhere would be completely foolish? I mean, we would have the duty_cycle/period thing for free, it would be know to the scheduler (as to maybe address Thomas' concerns) and we could think to make idle injection part of system analysis (for the soft-RT use cases).DEADLINE would be awesome, but I think we need work on two fronts before we can really sell it as the awesome that it is ;-)
Quoted 7 lines
- greedy and or statistical bounds
- !privThe first is such that we can better deal with the erratic nature of media decode without going full worst case on it, and the second just makes it so much more accessible.
Right. For the first point I think we just need to make our off-line calculation right, not that we need to modify implementation. On the second point we need more work yes. Also, another thing that is missing is frequency (uarch) scaling for reservations parameters, something alike what we are doing for CFS; this last point might be solved sooner :-).
Thanks,
- Juri
Quoted 9 lines · On Mon, 09 Nov 2015 11:56:51 +0000 Punit Agrawal <[email protected]> wrote:
Quoted 8 lines
actually, I was suggesting to start considering idle injection once frequency capped to the energy efficient point, which can be much higher than the lowest frequency. The idea being, deep idle power is negligible compared to running power which allows near linear power-perf scaling for balanced workload.
Below energy efficient frequency, continuous lowering frequency may lose disproportion performance vs. power. i.e. worse than linear.
Quoted 5 lines
I agree. I was making that assumption that with the ability to inject idle states, there wouldn't be a need to expose the inefficient frequency states.
Do you still see a reason to do that?
yes, but it is up to a governor or management sw to decide when to to pick what mechanism. there may be certain workload scale better with frequency change. e.g. unbalanced workload, we don't want to inject idle to all cpus if just one is busy. but it is also unlikely to run into thermal issue in this case.
Dietmar Eggemann
reviewerQuoted 10 lines · Peter Zijlstra
People, trim your emails!
Quoted 4 lines · Jacob Pan
Quoted 4 lines
I also like #2 too. Specially now that it is not limited to a specific platform. One question though, could you still keep the cooling device support of it? In some systems, it might make sense to enable / disable idle injections based on temperature.
Quoted 5 lines
Quoted 2 lines
One of the key difference between 1 and 2 is that #2 is open loop control, since we don't have CPU c-states info baked into scheduler.
_yet_, there's people working on that. The whole power aware scheduling stuff needs that.
Isn't the idle state information (rq->idle_state) already used in find_idlest_cpu()?
What we use in energy aware scheduling is quite similar but since we're interested in the index information of the c-state (to access the right element of the idle_state vectors of the energy model, we added rq->idle_state_idx.
[...]
Quoted 18 lines · On Fri, 6 Nov 2015 18:30:01 +0000 Dietmar Eggemann <[email protected]>…
Quoted 10 lines · Peter Zijlstra
People, trim your emails!
Quoted 4 lines · Jacob Pan
Quoted 4 lines
I also like #2 too. Specially now that it is not limited to a specific platform. One question though, could you still keep the cooling device support of it? In some systems, it might make sense to enable / disable idle injections based on temperature.
Quoted 6 lines
Quoted 3 lines
One of the key difference between 1 and 2 is that #2 is open loop control, since we don't have CPU c-states info baked into scheduler.
_yet_, there's people working on that. The whole power aware scheduling stuff needs that.
Quoted 8 lines
Isn't the idle state information (
rq->idle_state) already used infind_idlest_cpu()?What we use in energy aware scheduling is quite similar but since we're interested in the index information of the c-state (to access the right element of the
idle_statevectors of the energy model, we addedrq->idle_state_idx.
what i am interested is not per cpu idle state but rather at the package level or domain. It must be an indication for the overlapped idle time. Usually has to come from HW counters.
Dietmar Eggemann
reviewerQuoted 24 lines · Jacob Pan
Quoted 21 lines · On Fri, 6 Nov 2015 18:30:01 +0000 Dietmar Eggemann <[email protected]>…
Quoted 10 lines · Peter Zijlstra
People, trim your emails!
Quoted 4 lines · Jacob Pan
Quoted 4 lines
I also like #2 too. Specially now that it is not limited to a specific platform. One question though, could you still keep the cooling device support of it? In some systems, it might make sense to enable / disable idle injections based on temperature.
Quoted 6 lines
Quoted 3 lines
One of the key difference between 1 and 2 is that #2 is open loop control, since we don't have CPU c-states info baked into scheduler.
_yet_, there's people working on that. The whole power aware scheduling stuff needs that.
Isn't the idle state information (
rq->idle_state) already used infind_idlest_cpu()?
Quoted 8 lines
Quoted 5 lines
What we use in energy aware scheduling is quite similar but since we're interested in the index information of the c-state (to access the right element of the
idle_statevectors of the energy model, we addedrq->idle_state_idx.what i am interested is not per cpu idle state but rather at the package level or domain. It must be an indication for the overlapped idle time. Usually has to come from HW counters.
I see. We have a similar problem with the Energy Model (EM) on cluster level (sched domain level DIE). We iterate over the cpus of a sched group and declare the shallowest cpu idle state as the cluster idle state to index our EM. On a typical ARM system we have (active, WFI, cpu-off and cluster-off). But I guess for you the idle state index is only for core idle states and you can't draw any conclusions from this for the package idle states.
Quoted 11 lines · On Fri, 6 Nov 2015 21:55:49 +0000 Dietmar Eggemann <[email protected]>…
Quoted 3 lines
what i am interested is not per cpu idle state but rather at the package level or domain. It must be an indication for the overlapped idle time. Usually has to come from HW counters.
I see. We have a similar problem with the Energy Model (EM) on cluster level (sched domain level DIE). We iterate over the cpus of a sched group and declare the shallowest cpu idle state as the cluster idle state to index our EM. On a typical ARM system we have (active, WFI, cpu-off and cluster-off). But I guess for you the idle state index is only for core idle states and you can't draw any conclusions from this for the package idle states.
what is WFI?
For Intel, idle states are hints to the HW. The FW decides how far the idle can go based on many factors, device states included, some are visible to the OS some are not. We just to help mature such deep idle conditions.
Peter Zijlstra
maintainerQuoted 1 line · Jacob Pan
what is WFI?
Wait For Interrupt; very like the x86 HLT thing.
Quoted 4 lines
For Intel, idle states are hints to the HW. The FW decides how far the idle can go based on many factors, device states included, some are visible to the OS some are not. We just to help mature such deep idle conditions.
On some ARM you have to manually orchestrate cluster idle, which is clustered idle states in cpuidle. The up-side is that you explicitly know about them, the down side is that its cross CPU bits and a freak show (think doing cross CPU atomics while a CPU isn't in the coherency domain yet).