Queue work on power efficient wq
Subsystems (10)
v5 cover Queue work on power efficient wq
This patchset was called: "Create sched_select_cpu() and use it for workqueues" for the first three versions.
Earlier discussions over v3, v2 and v1 can be found here:
https://lkml.org/lkml/2013/3/18/364
http://lists.linaro.org/pipermail/linaro-dev/2012-November/014344.html
http://www.mail-archive.com/[email protected]/msg13342.html
V4 is here:
https://lkml.org/lkml/2013/3/31/55
Workqueues can be performance or power oriented. For performance we may want to keep them running on a single cpu, so that it remains cache hot. For power we can give scheduler the liberty to choose target cpu for running work handler.
Later one (Power oriented WQ) can be achieved if the workqueue is allocated with WQ_UNBOUND flag. Enabling CONFIG_WQ_POWER_EFFICIENT will set 'wq_power_efficient' to 'true'. Setting 'power_efficient' boot param will override value of 'wq_power_efficient' variable. When 'wq_power_efficient' is set to 'true', we will convert WQ_POWER_EFFICIENT flag to WQ_UNBOUND on wq allocation. And so scheduler will have the liberty to choose where to run this work.
Here we are migrating few users of workqueues to WQ_POWER_EFFICIENT. These drivers are found to be very much active on idle or lightly busy system and using WQ_POWER_EFFICIENT for these gave impressive results.
These would be used in power saving mode only if relevant configs are enabled at compile time or in bootargs. Otherwise behavior is unchanged.
Setup:
-----
- ARM Vexpress TC2 - big.LITTLE CPU
- Core 0-1: A15, 2-4: A7
- rootfs: linaro-ubuntu-devel
This patchset has been tested on a big LITTLE system (heterogeneous) but is useful for all other homogeneous systems as well. During these tests audio was played in background using aplay.
Results:
-------
Cluster A15 Energy Cluster A7 Energy Total
------------------------- ----------------------- ------
Without this patchset (Energy in Joules):
---------------------------------------------------
0.151162 2.183545 2.334707 0.223730 2.687067 2.910797 0.289687 2.732702 3.022389 0.454198 2.745908 3.200106 0.495552 2.746465 3.242017
Average:
0.322866 2.619137 2.942003
With this patchset (Energy in Joules):
-----------------------------------------------
0.226421 2.283658 2.510079 0.151361 2.236656 2.388017 0.197726 2.249849 2.447575 0.221915 2.229446 2.451361 0.347098 2.257707 2.604805
Average:
0.2289042 2.2514632 2.4803674
Above tests are repeated multiple times and events are tracked using trace-cmd and analysed using kernelshark. And it was easily noticeable that idle time for many cpus has increased considerably, which eventually saved some power.
V4->V5:
-------
- Created new wq flag: WQ_POWER_EFFICIENT, config option:
CONFIG_WQ_POWER_EFFICIENT and kernel param workqueue.power_efficient.
- Created few system wide workqueues aligned towards power saving.
V3->V4:
-------
- Dropped changes to kernel/sched directory and hence sched_select_non_idle_cpu().
- Dropped queue_work_on_any_cpu()
- Created system_freezable_unbound_wq
- Changed all patches accordingly.
V2->V3:
-------
- Dropped changes into core queue_work() API, rather create *_on_any_cpu() APIs
- Dropped running timers migration patch as that was broken
- Migrated few users of workqueues to use *_on_any_cpu() APIs.
Viresh Kumar (5):
workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented
workqueues
workqueue: Add system wide power_efficient workqueues
PHYLIB: queue work on system_power_efficient_wq
block: queue work on power efficient wq
fbcon: queue work on power efficient wq
Documentation/kernel-parameters.txt | 17 +++++++++++++++++ block/blk-core.c | 3 ++- block/blk-ioc.c | 3 ++- block/genhd.c | 12 ++++++++---- drivers/net/phy/phy.c | 9 +++++---- drivers/video/console/fbcon.c | 2 +- include/linux/workqueue.h | 10 ++++++++++ kernel/power/Kconfig | 19 +++++++++++++++++++ kernel/workqueue.c | 24 +++++++++++++++++++++++- 9 files changed, 87 insertions(+), 12 deletions(-)
Signature · 1 line
1.7.12.rc2.18.g61b472e
PATCH v5 1/5 workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
Workqueues can be performance or power oriented. For performance we may want to keep them running on a single cpu, so that it remains cache hot. For power we can give scheduler the liberty to choose target cpu for running work handler.
Later one (Power oriented WQ) can be achieved if the workqueue is allocated with WQ_UNBOUND flag. Enabling CONFIG_WQ_POWER_EFFICIENT will set 'wq_power_efficient' to 'true'. Setting 'power_efficient' boot param will override value of 'wq_power_efficient' variable. When 'wq_power_efficient' is set to 'true', we will convert WQ_POWER_EFFICIENT flag to WQ_UNBOUND on wq allocation. And so scheduler will have the liberty to choose where to run this work.
--- Documentation/kernel-parameters.txt | 17 +++++++++++++++++ include/linux/workqueue.h | 3 +++ kernel/power/Kconfig | 19 +++++++++++++++++++ kernel/workqueue.c | 11 +++++++++++ 4 files changed, 50 insertions(+)
Documentation/kernel-parameters.txt +17 -0
@@ -3312,6 +3312,23 @@ bytes respectively. Such letter suffixes can also be entirely omitted. that this also can be controlled per-workqueue for workqueues visible under /sys/bus/workqueue/. + workqueue.power_efficient + Workqueues can be performance or power oriented. For + performance we may want to keep them running on a single + cpu, so that it remains cache hot. For power we can give + scheduler the liberty to choose target cpu for running + work handler. + + Later one (Power oriented WQ) can be achieved if the + workqueue is allocated with WQ_UNBOUND flag. Enabling + CONFIG_WQ_POWER_EFFICIENT will set 'wq_power_efficient' + to 'true'. Setting 'power_efficient' boot param will + override value of 'wq_power_efficient' variable. When + 'wq_power_efficient' is set to 'true', we will convert + WQ_POWER_EFFICIENT flag to WQ_UNBOUND on wq allocation. + And so scheduler will have the liberty to choose where + to run this work. + x2apic_phys [X86-64,APIC] Use x2apic physical mode instead of default x2apic cluster mode on platforms supporting x2apic.
include/linux/workqueue.h +3 -0
@@ -302,6 +302,9 @@ enum {WQ_HIGHPRI =1 <<4 ,/* high priority */ WQ_CPU_INTENSIVE =1 <<5 ,/* cpu instensive workqueue */ WQ_SYSFS =1 <<6 ,/* visible in sysfs, see wq_sysfs_register() */ +WQ_POWER_EFFICIENT =1 <<7 ,/* WQ_UNBOUND, for power +* saving, if wq_power_efficient is +* enabled. Unused otherwise. */ __WQ_DRAINING =1 <<16 ,/* internal: workqueue is draining */ __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */
kernel/power/Kconfig +19 -0
@@ -263,6 +263,25 @@ config PM_GENERIC_DOMAINS bool depends on PM +config WQ_POWER_EFFICIENT + bool "Workqueue allocated as UNBOUND (by default) for power efficiency" + depends on PM + help + Workqueues can be performance or power oriented. For performance we + may want to keep them running on a single cpu, so that it remains + cache hot. For power we can give scheduler the liberty to choose + target cpu for running work handler. + + Later one (Power oriented WQ) can be achieved if the workqueue is + allocated with WQ_UNBOUND flag. Enabling CONFIG_WQ_POWER_EFFICIENT + will set 'wq_power_efficient' to 'true'. Setting 'power_efficient' + boot param will override value of 'wq_power_efficient' variable. When + 'wq_power_efficient' is set to 'true', we will convert + WQ_POWER_EFFICIENT flag to WQ_UNBOUND on wq allocation. And so + scheduler will have the liberty to choose where to run this work. + + If in doubt, say N. + config PM_GENERIC_DOMAINS_SLEEP def_bool y depends on PM_SLEEP && PM_GENERIC_DOMAINS
kernel/workqueue.c +11 -0
@@ -272,6 +272,14 @@ static cpumask_var_t *wq_numa_possible_cpumask;static bool wq_disable_numa;module_param_named (disable_numa, wq_disable_numa, bool,0444 ); +#ifdef CONFIG_WQ_POWER_EFFICIENT +static bool wq_power_efficient = true; +#else +static bool wq_power_efficient; +#endif + +module_param_named (power_efficient, wq_power_efficient, bool,0444 ); +static bool wq_numa_enabled;/* unbound NUMA affinity enabled */ /* buf for wq_update_unbound_numa_attrs(), protected by CPU hotplug exclusion */
@@ -4085,6 +4093,9 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt,struct workqueue_struct *wq;struct pool_workqueue *pwq; +if ((flags &WQ_POWER_EFFICIENT ) && wq_power_efficient) + flags |=WQ_UNBOUND ; +/* allocate wq and format name */ if (flags &WQ_UNBOUND ) tbl_size = wq_numa_tbl_len *sizeof (wq->numa_pwq_tbl[0 ]);
Signature · 1 line
1.7.12.rc2.18.g61b472e
Re: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
Quoted 3 lines · Viresh Kumar
Workqueues can be performance or power oriented. For performance we may want to keep them running on a single cpu, so that it remains cache hot. For power we can give scheduler the liberty to choose target cpu for running work handler.
Consider the following rewording:
Workqueues can be performance or power-oriented. Currently, most workqueues are bound to the CPU they were created on. This gives good performance (due to cache effects) at the cost of potentially waking up otherwise idle cores just to process some work. To save power, we can allow the work to be rescheduled on a core that is already awake.
Quoted 7 lines
Later one (Power oriented WQ) can be achieved if the workqueue is allocated with
WQ_UNBOUNDflag. EnablingCONFIG_WQ_POWER_EFFICIENTwill set 'wq_power_efficient' to 'true'. Setting 'power_efficient' boot param will override value of 'wq_power_efficient' variable. When 'wq_power_efficient' is set to 'true', we will convertWQ_POWER_EFFICIENTflag toWQ_UNBOUNDon wq allocation. And so scheduler will have the liberty to choose where to run this work.
Consider the following rewording which is easier to understand IMO:
Workqueues created with the WQ_UNBOUND flag will allow some power savings. However, we don't change the default behaviour of the system. To enable power-saving behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT needs to be turned on. This option can also be overridden by the workqueue.power_efficient boot parameter.
Quoted 23 lines
Signed-off-by Viresh Kumar <[email protected]>--- Documentation/kernel-parameters.txt | 17 +++++++++++++++++ include/linux/workqueue.h | 3 +++ kernel/power/Kconfig | 19 +++++++++++++++++++ kernel/workqueue.c | 11 +++++++++++ 4 files changed, 50 insertions(+)Documentation/kernel-parameters.txt +7
-0@@ -3312,6 +3312,23 @@ bytes respectively. Such letter suffixes can also be entirely omitted. that this also can be controlled per-workqueue for workqueues visible under /sys/bus/workqueue/. + workqueue.power_efficient + Workqueues can be performance or power oriented. For + performance we may want to keep them running on a single + cpu, so that it remains cache hot. For power we can give + scheduler the liberty to choose target cpu for running + work handler. +
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3331
Quoted 10 lines
Documentation/kernel-parameters.txt +10
-0+ Later one (Power oriented WQ) can be achieved if the + workqueue is allocated with WQ_UNBOUND flag. Enabling + CONFIG_WQ_POWER_EFFICIENT will set 'wq_power_efficient' + to 'true'. Setting 'power_efficient' boot param will + override value of 'wq_power_efficient' variable. When + 'wq_power_efficient' is set to 'true', we will convert + WQ_POWER_EFFICIENT flag to WQ_UNBOUND on wq allocation. + And so scheduler will have the liberty to choose where + to run this work. +
Rewrite as above.
Quoted 22 lines
Documentation/kernel-parameters.txt +0
-0x2apic_phys [X86-64,APIC] Use x2apic physical mode instead of default x2apic cluster mode on platforms supporting x2apic.include/linux/workqueue.h +3
-0@@ -302,6 +302,9 @@ enum {WQ_HIGHPRI =1 <<4 ,/* high priority */ WQ_CPU_INTENSIVE =1 <<5 ,/* cpu instensive workqueue */ WQ_SYSFS =1 <<6 ,/* visible in sysfs, see wq_sysfs_register() */ +WQ_POWER_EFFICIENT =1 <<7 ,/* WQ_UNBOUND, for power +* saving, if wq_power_efficient is +* enabled. Unused otherwise. */ __WQ_DRAINING =1 <<16 ,/* internal: workqueue is draining */ __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */kernel/power/Kconfig +0
-0
kernel/power/Kconfig config PM_GENERIC_DOMAINS · line 268
Quoted 6 lines
kernel/power/Kconfig +3
-0@@ -263,6 +263,25 @@ config PM_GENERIC_DOMAINS bool depends on PM +config WQ_POWER_EFFICIENT + bool "Workqueue allocated as UNBOUND (by default) for power efficiency" + depends on PM
default n
Quoted 6 lines
kernel/power/Kconfig +6
-0+ help + Workqueues can be performance or power oriented. For performance we + may want to keep them running on a single cpu, so that it remains + cache hot. For power we can give scheduler the liberty to choose + target cpu for running work handler. +
kernel/power/Kconfig config PM_GENERIC_DOMAINS · line 284
Quoted 10 lines
kernel/power/Kconfig +10
-0+ Later one (Power oriented WQ) can be achieved if the workqueue is + allocated with WQ_UNBOUND flag. Enabling CONFIG_WQ_POWER_EFFICIENT + will set 'wq_power_efficient' to 'true'. Setting 'power_efficient' + boot param will override value of 'wq_power_efficient' variable. When + 'wq_power_efficient' is set to 'true', we will convert + WQ_POWER_EFFICIENT flag to WQ_UNBOUND on wq allocation. And so + scheduler will have the liberty to choose where to run this work. + + If in doubt, say N. +
Rewrite as above
Quoted 40 lines
kernel/power/Kconfig +0
-0config PM_GENERIC_DOMAINS_SLEEP def_bool y depends on PM_SLEEP && PM_GENERIC_DOMAINSkernel/workqueue.c +11
-1@@ -272,6 +272,14 @@ static cpumask_var_t *wq_numa_possible_cpumask;static bool wq_disable_numa;module_param_named (disable_numa, wq_disable_numa, bool,0444 ); +#ifdef CONFIG_WQ_POWER_EFFICIENT +static bool wq_power_efficient = true; +#else +static bool wq_power_efficient; +#endif + +module_param_named (power_efficient, wq_power_efficient, bool,0444 ); +static bool wq_numa_enabled;/* unbound NUMA affinity enabled */ /* buf for wq_update_unbound_numa_attrs(), protected by CPU hotplug exclusion */ @@ -4085,6 +4093,9 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt,struct workqueue_struct *wq;struct pool_workqueue *pwq; +if ((flags &WQ_POWER_EFFICIENT ) && wq_power_efficient) + flags |=WQ_UNBOUND ; +/* allocate wq and format name */ if (flags &WQ_UNBOUND ) tbl_size = wq_numa_tbl_len *sizeof (wq->numa_pwq_tbl[0 ]); --1.7.12.rc2.18.g61b472e
_______________________________________________
linaro-kernel mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/linaro-kernel
Re: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
Quoted 6 lines · Amit Kucheria
kernel/power/Kconfig config PM_GENERIC_DOMAINS · line 268
Quoted 3 lines · Viresh Kumar
kernel/power/Kconfig +3
-0+config WQ_POWER_EFFICIENT + bool "Workqueue allocated as UNBOUND (by default) for power efficiency" + depends on PMdefault n
If this line is not present i believe it is 'default n' only. So, i skipped it.
All others comments accepted.
Tejun Heo
maintainerRe: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
Quoted 1 line · Viresh Kumar
If this line is not present i believe it is 'default n' only. So, i skipped it.
I think the difference is that when you configure the option for the first time - ie. building kernel with .config used for an older kernel
- that it prompts for selection, thus annoying the big penguin. You probably want the explicit 'N'.
Thanks.
Signature · 1 line
tejun
A message that is not in the archive (sent off-list or not yet received): CAP245DUGuaSQbP4026N8kgn6-NqXFJWR3zKoYud=HQ_b+v5+Xw@mail.gmail.com
Re: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
Quoted 2 lines · Amit Kucheria
Yes. That was my intention - preventing a prompt on existing defconfigs and there by maintaining current behavior.
Hmm... Following is the version after fixing all problems you reported. @Tejun: I have attached it too as gmail's copy-paste may break it. Please consider applying this series if it looks fine to you.
---------------x----------------x---------------------
From: Viresh Kumar <[email protected]>
Date: Mon, 8 Apr 2013 16:45:40 +0530
Subject: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for
power oriented workqueues
Workqueues can be performance or power-oriented. Currently, most workqueues are bound to the CPU they were created on. This gives good performance (due to cache effects) at the cost of potentially waking up otherwise idle cores just to process some work. To save power, we can allow the work to be rescheduled on a core that is already awake.
Workqueues created with the WQ_UNBOUND flag will allow some power savings. However, we don't change the default behaviour of the system. To enable power-saving behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT needs to be turned on. This option can also be overridden by the workqueue.power_efficient boot parameter.
--- Documentation/kernel-parameters.txt | 17 +++++++++++++++++ include/linux/workqueue.h | 3 +++ kernel/power/Kconfig | 19 +++++++++++++++++++ kernel/workqueue.c | 11 +++++++++++ 4 files changed, 50 insertions(+)
(quoted diff) +0 -0
b/Documentation/kernel-parameters.txt
index c4fa000..22edc83 100644
Documentation/kernel-parameters.txt +0 -0
@@ -3312,6 +3312,23 @@ bytes respectively. Such letter suffixes can
also be entirely omitted.
that this also can be controlled per-workqueue for workqueues visible under /sys/bus/workqueue/.
+ workqueue.power_efficient
+ Workqueues can be performance or power-oriented.
+ Currently, most workqueues are bound to the CPU they
+ were created on. This gives good performance (due to
+ cache effects) at the cost of potentially waking up
+ otherwise idle cores just to process some work. To save
+ power, we can allow the work to be rescheduled on a core
+ that is already awake.
+
+ Workqueues created with the WQ_UNBOUND flag will allow
+ some power savings. However, we don't change the
+ default behaviour of the system. To enable power-saving
+ behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT
+ needs to be turned on. This option can also be
+ overridden by the workqueue.power_efficient boot
+ parameter.
+
x2apic_phys [X86-64,APIC] Use x2apic physical mode instead of
default x2apic cluster mode on platforms supporting x2apic.
include/linux/workqueue.h +3 -0
@@ -302,6 +302,9 @@ enum {WQ_HIGHPRI =1 <<4 ,/* high priority */ WQ_CPU_INTENSIVE =1 <<5 ,/* cpu instensive workqueue */ WQ_SYSFS =1 <<6 ,/* visible in sysfs, see wq_sysfs_register() */ +WQ_POWER_EFFICIENT =1 <<7 ,/* WQ_UNBOUND, for power +* saving, if wq_power_efficient is +* enabled. Unused otherwise. */ __WQ_DRAINING =1 <<16 ,/* internal: workqueue is draining */ __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */
kernel/power/Kconfig +19 -0
@@ -263,6 +263,25 @@ config PM_GENERIC_DOMAINS bool depends on PM +config WQ_POWER_EFFICIENT + bool "Workqueue allocated as UNBOUND (by default) for power efficiency" + depends on PM + default n + help + Workqueues can be performance or power-oriented. Currently, most + workqueues are bound to the CPU they were created on. This gives good + performance (due to cache effects) at the cost of potentially waking + up otherwise idle cores just to process some work. To save power, we + can allow the work to be rescheduled on a core that is already awake. + + Workqueues created with the WQ_UNBOUND flag will allow some power + savings. However, we don't change the default behaviour of the + system. To enable power-saving behaviour, a new config option + CONFIG_WQ_POWER_EFFICIENT needs to be turned on. This option can also + be overridden by the workqueue.power_efficient boot parameter. + + If in doubt, say N. + config PM_GENERIC_DOMAINS_SLEEP def_bool y depends on PM_SLEEP && PM_GENERIC_DOMAINS
kernel/workqueue.c +8 -0
@@ -272,6 +272,14 @@ static cpumask_var_t *wq_numa_possible_cpumask;static bool wq_disable_numa;module_param_named (disable_numa, wq_disable_numa, bool,0444 ); +#ifdef CONFIG_WQ_POWER_EFFICIENT +static bool wq_power_efficient = true; +#else +static bool wq_power_efficient; +#endif + +module_param_named (power_efficient, wq_power_efficient, bool,0444 ); +static bool wq_numa_enabled;/* unbound NUMA affinity enabled */ /* buf for wq_update_unbound_numa_attrs(), protected by CPU hotplug
exclusion */
@@ -4085,6 +4093,9 @@ struct workqueue_struct
*__alloc_workqueue_key(const char *fmt,
struct workqueue_struct *wq;
struct pool_workqueue *pwq;
+ if ((flags & WQ_POWER_EFFICIENT) && wq_power_efficient)
+ flags |= WQ_UNBOUND;
+
/* allocate wq and format name */
if (flags & WQ_UNBOUND)
tbl_size = wq_numa_tbl_len * sizeof(wq->numa_pwq_tbl[0]);
From 627634fb860403cbe1fcd18d6f321ee2cd910b90 Mon Sep 17 00:00:00 2001
Message-Id: <627634fb860403cbe1fcd18d6f321ee2cd910b90.1366861238.git.viresh.kumar@linaro.org>
From: Viresh Kumar <[email protected]>
Date: Mon, 8 Apr 2013 16:45:40 +0530
Subject: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for
power oriented workqueues
Workqueues can be performance or power-oriented. Currently, most workqueues are bound to the CPU they were created on. This gives good performance (due to cache effects) at the cost of potentially waking up otherwise idle cores just to process some work. To save power, we can allow the work to be rescheduled on a core that is already awake.
Workqueues created with the WQ_UNBOUND flag will allow some power savings. However, we don't change the default behaviour of the system. To enable power-saving behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT needs to be turned on. This option can also be overridden by the workqueue.power_efficient boot parameter.
--- Documentation/kernel-parameters.txt | 17 +++++++++++++++++ include/linux/workqueue.h | 3 +++ kernel/power/Kconfig | 19 +++++++++++++++++++ kernel/workqueue.c | 11 +++++++++++ 4 files changed, 50 insertions(+)
Documentation/kernel-parameters.txt +17 -0
@@ -3312,6 +3312,23 @@ bytes respectively. Such letter suffixes can also be entirely omitted. that this also can be controlled per-workqueue for workqueues visible under /sys/bus/workqueue/. + workqueue.power_efficient + Workqueues can be performance or power-oriented. + Currently, most workqueues are bound to the CPU they + were created on. This gives good performance (due to + cache effects) at the cost of potentially waking up + otherwise idle cores just to process some work. To save + power, we can allow the work to be rescheduled on a core + that is already awake. + + Workqueues created with the WQ_UNBOUND flag will allow + some power savings. However, we don't change the + default behaviour of the system. To enable power-saving + behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT + needs to be turned on. This option can also be + overridden by the workqueue.power_efficient boot + parameter. + x2apic_phys [X86-64,APIC] Use x2apic physical mode instead of default x2apic cluster mode on platforms supporting x2apic.
include/linux/workqueue.h +3 -0
@@ -302,6 +302,9 @@ enum {WQ_HIGHPRI =1 <<4 ,/* high priority */ WQ_CPU_INTENSIVE =1 <<5 ,/* cpu instensive workqueue */ WQ_SYSFS =1 <<6 ,/* visible in sysfs, see wq_sysfs_register() */ +WQ_POWER_EFFICIENT =1 <<7 ,/* WQ_UNBOUND, for power +* saving, if wq_power_efficient is +* enabled. Unused otherwise. */ __WQ_DRAINING =1 <<16 ,/* internal: workqueue is draining */ __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */
kernel/power/Kconfig +19 -0
@@ -263,6 +263,25 @@ config PM_GENERIC_DOMAINS bool depends on PM +config WQ_POWER_EFFICIENT + bool "Workqueue allocated as UNBOUND (by default) for power efficiency" + depends on PM + default n + help + Workqueues can be performance or power-oriented. Currently, most + workqueues are bound to the CPU they were created on. This gives good + performance (due to cache effects) at the cost of potentially waking + up otherwise idle cores just to process some work. To save power, we + can allow the work to be rescheduled on a core that is already awake. + + Workqueues created with the WQ_UNBOUND flag will allow some power + savings. However, we don't change the default behaviour of the + system. To enable power-saving behaviour, a new config option + CONFIG_WQ_POWER_EFFICIENT needs to be turned on. This option can also + be overridden by the workqueue.power_efficient boot parameter. + + If in doubt, say N. + config PM_GENERIC_DOMAINS_SLEEP def_bool y depends on PM_SLEEP && PM_GENERIC_DOMAINS
kernel/workqueue.c +11 -0
@@ -272,6 +272,14 @@ static cpumask_var_t *wq_numa_possible_cpumask;static bool wq_disable_numa;module_param_named (disable_numa, wq_disable_numa, bool,0444 ); +#ifdef CONFIG_WQ_POWER_EFFICIENT +static bool wq_power_efficient = true; +#else +static bool wq_power_efficient; +#endif + +module_param_named (power_efficient, wq_power_efficient, bool,0444 ); +static bool wq_numa_enabled;/* unbound NUMA affinity enabled */ /* buf for wq_update_unbound_numa_attrs(), protected by CPU hotplug exclusion */
@@ -4085,6 +4093,9 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt,struct workqueue_struct *wq;struct pool_workqueue *pwq; +if ((flags &WQ_POWER_EFFICIENT ) && wq_power_efficient) + flags |=WQ_UNBOUND ; +/* allocate wq and format name */ if (flags &WQ_UNBOUND ) tbl_size = wq_numa_tbl_len *sizeof (wq->numa_pwq_tbl[0 ]);
Signature · 1 line
1.7.12.rc2.18.g61b472e
Amit Kucheria
Reviewed-byRe: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
Quoted 22 lines · Viresh Kumar
Quoted 2 lines · Amit Kucheria
Yes. That was my intention - preventing a prompt on existing defconfigs and there by maintaining current behavior.
Hmm... Following is the version after fixing all problems you reported. @Tejun: I have attached it too as gmail's copy-paste may break it. Please consider applying this series if it looks fine to you.
---------------x----------------x---------------------
From: Viresh Kumar <[email protected]>
Date: Mon, 8 Apr 2013 16:45:40 +0530
Subject: [PATCH V5 1/5] workqueues: Introduce new flagWQ_POWER_EFFICIENTfor
power oriented workqueuesWorkqueues can be performance or power-oriented. Currently, most workqueues are bound to the CPU they were created on. This gives good performance (due to cache effects) at the cost of potentially waking up otherwise idle cores just to process some work. To save power, we can allow the work to be rescheduled on a core that is already awake.
Quoted 7 lines
Workqueues created with the
WQ_UNBOUNDflag will allow some power savings. However, we don't change the default behaviour of the system. To enable power-saving behaviour, a new config optionCONFIG_WQ_POWER_EFFICIENTneeds to be turned on. This option can also be overridden by the workqueue.power_efficient boot parameter.Signed-off-by Viresh Kumar <[email protected]>
For the series, you can add my:
Quoted 112 lines
--- Documentation/kernel-parameters.txt | 17 +++++++++++++++++ include/linux/workqueue.h | 3 +++ kernel/power/Kconfig | 19 +++++++++++++++++++ kernel/workqueue.c | 11 +++++++++++ 4 files changed, 50 insertions(+)Documentation/kernel-parameters.txt +0
-0@@ -3312,6 +3312,23 @@ bytes respectively. Such letter suffixes canalso be entirely omitted.
that this also can be controlled per-workqueue for workqueues visible under/sys/bus/workqueue/.Documentation/kernel-parameters.txt +17
-0+ workqueue.power_efficient + Workqueues can be performance or power-oriented. + Currently, most workqueues are bound to the CPU they + were created on. This gives good performance (due to + cache effects) at the cost of potentially waking up + otherwise idle cores just to process some work. To save + power, we can allow the work to be rescheduled on a core + that is already awake. + + Workqueues created with the WQ_UNBOUND flag will allow + some power savings. However, we don't change the + default behaviour of the system. To enable power-saving + behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT + needs to be turned on. This option can also be + overridden by the workqueue.power_efficient boot + parameter. + x2apic_phys [X86-64,APIC] Use x2apic physical mode instead of default x2apic cluster mode on platforms supporting x2apic.include/linux/workqueue.h +3
-0@@ -302,6 +302,9 @@ enum {WQ_HIGHPRI =1 <<4 ,/* high priority */ WQ_CPU_INTENSIVE =1 <<5 ,/* cpu instensive workqueue */ WQ_SYSFS =1 <<6 ,/* visible in sysfs, see wq_sysfs_register() */ +WQ_POWER_EFFICIENT =1 <<7 ,/* WQ_UNBOUND, for power +* saving, if wq_power_efficient is +* enabled. Unused otherwise. */ __WQ_DRAINING =1 <<16 ,/* internal: workqueue is draining */ __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */kernel/power/Kconfig +19
-0@@ -263,6 +263,25 @@ config PM_GENERIC_DOMAINS bool depends on PM +config WQ_POWER_EFFICIENT + bool "Workqueue allocated as UNBOUND (by default) for power efficiency" + depends on PM + default n + help + Workqueues can be performance or power-oriented. Currently, most + workqueues are bound to the CPU they were created on. This gives good + performance (due to cache effects) at the cost of potentially waking + up otherwise idle cores just to process some work. To save power, we + can allow the work to be rescheduled on a core that is already awake. + + Workqueues created with the WQ_UNBOUND flag will allow some power + savings. However, we don't change the default behaviour of the + system. To enable power-saving behaviour, a new config option + CONFIG_WQ_POWER_EFFICIENT needs to be turned on. This option can also + be overridden by the workqueue.power_efficient boot parameter. + + If in doubt, say N. + config PM_GENERIC_DOMAINS_SLEEP def_bool y depends on PM_SLEEP && PM_GENERIC_DOMAINSkernel/workqueue.c +8
-0@@ -272,6 +272,14 @@ static cpumask_var_t *wq_numa_possible_cpumask;static bool wq_disable_numa;module_param_named (disable_numa, wq_disable_numa, bool,0444 ); +#ifdef CONFIG_WQ_POWER_EFFICIENT +static bool wq_power_efficient = true; +#else +static bool wq_power_efficient; +#endif + +module_param_named (power_efficient, wq_power_efficient, bool,0444 ); +static bool wq_numa_enabled;/* unbound NUMA affinity enabled */ /* buf for wq_update_unbound_numa_attrs(), protected by CPU hotplug exclusion */
kernel/workqueue.c +3
-0@@ -4085,6 +4093,9 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt, struct workqueue_struct *wq;struct pool_workqueue *pwq; +if ((flags &WQ_POWER_EFFICIENT ) && wq_power_efficient) + flags |=WQ_UNBOUND ; +/* allocate wq and format name */ if (flags &WQ_UNBOUND )tbl_size = wq_numa_tbl_len * sizeof(wq->numa_pwq_tbl[0]);
Re: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
Quoted 29 lines · Amit Kucheria
Quoted 28 lines · Viresh Kumar
Quoted 2 lines · Amit Kucheria
Yes. That was my intention - preventing a prompt on existing defconfigs and there by maintaining current behavior.
Hmm... Following is the version after fixing all problems you reported. @Tejun: I have attached it too as gmail's copy-paste may break it. Please consider applying this series if it looks fine to you.
---------------x----------------x---------------------
From: Viresh Kumar <[email protected]>
Date: Mon, 8 Apr 2013 16:45:40 +0530
Subject: [PATCH V5 1/5] workqueues: Introduce new flagWQ_POWER_EFFICIENTfor
power oriented workqueuesWorkqueues can be performance or power-oriented. Currently, most workqueues are bound to the CPU they were created on. This gives good performance (due to cache effects) at the cost of potentially waking up otherwise idle cores just to process some work. To save power, we can allow the work to be rescheduled on a core that is already awake.
Workqueues created with the
WQ_UNBOUNDflag will allow some power savings. However, we don't change the default behaviour of the system. To enable power-saving behaviour, a new config optionCONFIG_WQ_POWER_EFFICIENTneeds to be turned on. This option can also be overridden by the workqueue.power_efficient boot parameter.
Quoted 5 lines
Quoted 1 line
Signed-off-by Viresh Kumar <[email protected]>For the series, you can add my:
Reviewed-by Amit Kucheria <[email protected]>
Thanks.
Tejun Heo
maintainerRe: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
In reply to Viresh KumarHey, Viresh.
It's already too late for the upcoming merge window, but things generally look good to me and I'll apply the patchset once wq/for-3.11 opens. One nitpick tho.
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3317
Quoted 3 lines · Viresh Kumar
Documentation/kernel-parameters.txt +3
-0+ workqueue.power_efficient + Workqueues can be performance or power-oriented. + Currently, most workqueues are bound to the CPU they
^^^^
per-cpu would be better
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3322
Quoted 5 lines
Documentation/kernel-parameters.txt +5
-0+ were created on. This gives good performance (due to + cache effects) at the cost of potentially waking up + otherwise idle cores just to process some work. To save + power, we can allow the work to be rescheduled on a core + that is already awake.
The above description is confusing to me. As have been discussed multiple times before, per-cpu workqueue in itself doesn't wake up the CPU physically. The timer may but per-cpu workqueue doesn't. It was confusing when this patchset was first posted and the above phrasing is still confusing. What the patchset tries to do is preventing the scheduler from perceiving the CPU as active due to the activated worker thread pinned to that CPU, right? The knob doesn't really do anything about waking up the processor in itself. It just avoids feeding the scheduler with noisy activation events and allows it to allocate work item execution according to the scheduler's view of CPU active/idleness. As the scheduler has longer / larger scope of overall CPU activities and means to regulate them, this leads to more power-efficient allocation of work item executions, right? It'd be really great if the descriptions and the comment above the flag makes this abundantly clear because it's not something too apparent.
Thanks.
Signature · 1 line
tejun
Re: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
Hey Tejun,
Quoted 5 lines · Tejun Heo
Hey, Viresh.
It's already too late for the upcoming merge window, but things generally look good to me and I'll apply the patchset once wq/for-3.11 opens. One nitpick tho.
Obviously. I understand this and agree with you on it. It should go in 3.11 now.
Quoted 13 lines · Viresh Kumar
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3317
Quoted 3 lines
Documentation/kernel-parameters.txt +3
-0+ workqueue.power_efficient + Workqueues can be performance or power-oriented. + Currently, most workqueues are bound to the CPU they^^^^
per-cpu would be betterDocumentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 3322
Quoted 5 lines
Documentation/kernel-parameters.txt +5
-0+ were created on. This gives good performance (due to + cache effects) at the cost of potentially waking up + otherwise idle cores just to process some work. To save + power, we can allow the work to be rescheduled on a core + that is already awake.
Quoted 15 lines
The above description is confusing to me. As have been discussed multiple times before, per-cpu workqueue in itself doesn't wake up the CPU physically. The timer may but per-cpu workqueue doesn't. It was confusing when this patchset was first posted and the above phrasing is still confusing. What the patchset tries to do is preventing the scheduler from perceiving the CPU as active due to the activated worker thread pinned to that CPU, right? The knob doesn't really do anything about waking up the processor in itself. It just avoids feeding the scheduler with noisy activation events and allows it to allocate work item execution according to the scheduler's view of CPU active/idleness. As the scheduler has longer / larger scope of overall CPU activities and means to regulate them, this leads to more power-efficient allocation of work item executions, right? It'd be really great if the descriptions and the comment above the flag makes this abundantly clear because it's not something too apparent.
Whatever you wrote above confused me even more :)
This is what i had in my mind until now. Its not about per-cpu workqueue.
Lets take example of system_wq. It doesn't have WQ_UNBOUND flag set. Now if we call queue_work_on() with cpu x and sytem_wq, then work will execute on cpu x. If we call queue_work() then it will queue the work on local cpu.
At this time local cpu may be busy or idle (Atleast according to scheduler). We don't want a idle cpu (From schedulers perspective) to be used for running this work's handler due to two reasons.
- idle cpu may be in WFI or deeper idle states and so we can avoid waking it up.
- We will make idle cpu look busy and so other kernel stuff may be scheduled on it now. But we could have kept it idle for a long time.
And what timer are you talking about? I am not talking about deffered work only, but normal work too.
I might have wrongly phrased some part of my patch (maybe used workqueue instead of work), will fix that up.
--
viresh
Tejun Heo
maintainerRe: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
Hello,
Quoted 1 line · Viresh Kumar
Whatever you wrote above confused me even more :)
Heh heh, confumageddon!!!!
Quoted 6 lines
This is what i had in my mind until now. Its not about per-cpu workqueue.
Lets take example of
system_wq. It doesn't haveWQ_UNBOUNDflag set. Now if we callqueue_work_on()with cpu x andsytem_wq, then work will execute on cpu x. If we callqueue_work()then it will queue the work on local cpu.
Yeap, !WQ_UNBOUND workqueues == per-cpu workqueues.
Quoted 5 lines
At this time local cpu may be busy or idle (Atleast according to scheduler). We don't want a idle cpu (From schedulers perspective) to be used for running this work's handler due to two reasons.
- idle cpu may be in WFI or deeper idle states and so we can avoid waking it up.
I have no idea what WFI is but the physical CPU is already awake at that time. It can't be idle - it's running queue_work(). It could be running in lower freq tho, which each code piece doesn't really have much control over.
Quoted 2 lines
- We will make idle cpu look busy and so other kernel stuff may be scheduled on it now. But we could have kept it idle for a long time.
Hmmm... yeah, about the same thing I wrote, it's not really about not waking up the CPU right now physically but avoiding forcing the scheduler scheduling a pinned task on an otherwise quiescent CPU. This effectively allows the scheduler to migrate such work items towards a CPU which the scheduler considers to be better (in power or whatever) leading to noticeable powersave.
Quoted 2 lines
And what timer are you talking about? I am not talking about deffered work only, but normal work too.
Deferred work item == timer + work item.
Quoted 2 lines
I might have wrongly phrased some part of my patch (maybe used workqueue instead of work), will fix that up.
I think it'd be necessary to distinguish the physical CPU being idle and the scheduler considers it to be idle (no task to schedule on it) and explain how increasing the latter can lead to powersave. As it's currently written, it seemingly, to me anyway, suggests that the proposed change somehow avoids waking up actually idle CPU, which isn't the case as queue_work() *always* schedules on the local CPU. The local CPU can't be idle by definition.
Thanks.
Signature · 1 line
tejun
Re: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
Quoted 2 lines · Tejun Heo
On Mon, Apr 29, 2013 at 12:06:28PM +0530, Viresh Kumar wrote:
Yeap, !WQ_UNBOUND workqueues == per-cpu workqueues.
Sigh!! You were talking about thread per cpu here... Sorry for missing it earlier :(
Quoted 10 lines
Quoted 5 lines
At this time local cpu may be busy or idle (Atleast according to scheduler). We don't want a idle cpu (From schedulers perspective) to be used for running this work's handler due to two reasons.
- idle cpu may be in WFI or deeper idle states and so we can avoid waking it up.I have no idea what WFI is but the physical CPU is already awake at that time. It can't be idle - it's running
queue_work(). It could be running in lower freq tho, which each code piece doesn't really have much control over.
Stupid point. WFI: Wait for interrupt (low power mode of cpu).
Quoted 9 lines
Quoted 2 lines
- We will make idle cpu look busy and so other kernel stuff may be scheduled on it now. But we could have kept it idle for a long time.
Hmmm... yeah, about the same thing I wrote, it's not really about not waking up the CPU right now physically but avoiding forcing the scheduler scheduling a pinned task on an otherwise quiescent CPU. This effectively allows the scheduler to migrate such work items towards a CPU which the scheduler considers to be better (in power or whatever) leading to noticeable powersave.
Correct.
Quoted 4 lines
Quoted 2 lines
And what timer are you talking about? I am not talking about deffered work only, but normal work too.
Deferred work item == timer + work item.
Ya, i knew that :)
Quoted 10 lines
Quoted 2 lines
I might have wrongly phrased some part of my patch (maybe used workqueue instead of work), will fix that up.
I think it'd be necessary to distinguish the physical CPU being idle and the scheduler considers it to be idle (no task to schedule on it) and explain how increasing the latter can lead to powersave. As it's currently written, it seemingly, to me anyway, suggests that the proposed change somehow avoids waking up actually idle CPU, which isn't the case as
queue_work()*always* schedules on the local CPU. The local CPU can't be idle by definition.
Yes you are correct. I will fix it.
Re: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
In reply to Tejun HeoQuoted 18 lines · Tejun Heo
It's already too late for the upcoming merge window, but things generally look good to me and I'll apply the patchset once wq/for-3.11 opens. One nitpick tho.
Review
Quoted 3 lines · Viresh Kumar
(quoted diff) +3
-0+ workqueue.power_efficient + Workqueues can be performance or power-oriented. + Currently, most workqueues are bound to the CPU they^^^^
per-cpu would be betterReview
Quoted 5 lines
(quoted diff) +5
-0+ were created on. This gives good performance (due to + cache effects) at the cost of potentially waking up + otherwise idle cores just to process some work. To save + power, we can allow the work to be rescheduled on a core + that is already awake.
Quoted 15 lines
The above description is confusing to me. As have been discussed multiple times before, per-cpu workqueue in itself doesn't wake up the CPU physically. The timer may but per-cpu workqueue doesn't. It was confusing when this patchset was first posted and the above phrasing is still confusing. What the patchset tries to do is preventing the scheduler from perceiving the CPU as active due to the activated worker thread pinned to that CPU, right? The knob doesn't really do anything about waking up the processor in itself. It just avoids feeding the scheduler with noisy activation events and allows it to allocate work item execution according to the scheduler's view of CPU active/idleness. As the scheduler has longer / larger scope of overall CPU activities and means to regulate them, this leads to more power-efficient allocation of work item executions, right? It'd be really great if the descriptions and the comment above the flag makes this abundantly clear because it's not something too apparent.
Sorry for the long delay for such a small change. I went on long leaves..
I have added following to make things more clear at places:
(Idle from scheduler's perspective. Which may or may not be physically idle)..
Let me know if it is still unclear..
And this is the new patch: (Attached it too for applying cleanly)
---------x---------------x-------------------
From: Viresh Kumar <[email protected]>
Date: Mon, 8 Apr 2013 16:45:40 +0530
Subject: [PATCH V5 resent 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
Workqueues can be performance or power-oriented. Currently, most workqueues are bound to the CPU they were created on. This gives good performance (due to cache effects) at the cost of potentially waking up otherwise idle cores (Idle from scheduler's perspective. Which may or may not be physically idle) just to process some work. To save power, we can allow the work to be rescheduled on a core that is already awake.
Workqueues created with the WQ_UNBOUND flag will allow some power savings. However, we don't change the default behaviour of the system. To enable power-saving behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT needs to be turned on. This option can also be overridden by the workqueue.power_efficient boot parameter.
--- Documentation/kernel-parameters.txt | 18 ++++++++++++++++++ include/linux/workqueue.h | 3 +++ kernel/power/Kconfig | 21 +++++++++++++++++++++ kernel/workqueue.c | 11 +++++++++++ 4 files changed, 53 insertions(+)
(quoted diff) +0 -0
b/Documentation/kernel-parameters.txt
index c3bfacb..9a991b6 100644
Documentation/kernel-parameters.txt +0 -0
@@ -3320,6 +3320,24 @@ bytes respectively. Such letter suffixes can
also be entirely omitted.
that this also can be controlled per-workqueue for workqueues visible under /sys/bus/workqueue/.
+ workqueue.power_efficient
+ Workqueues can be performance or power-oriented.
+ Currently, most workqueues are bound to the CPU they
+ were created on. This gives good performance (due to
+ cache effects) at the cost of potentially waking up
+ otherwise idle cores (Idle from scheduler's perspective.
+ Which may or may not be physically idle) just to process
+ some work. To save power, we can allow the work to be
+ rescheduled on a core that is already awake.
+
+ Workqueues created with the WQ_UNBOUND flag will allow
+ some power savings. However, we don't change the
+ default behaviour of the system. To enable power-saving
+ behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT
+ needs to be turned on. This option can also be
+ overridden by the workqueue.power_efficient boot
+ parameter.
+
x2apic_phys [X86-64,APIC] Use x2apic physical mode instead of
default x2apic cluster mode on platforms supporting x2apic.
include/linux/workqueue.h +3 -0
@@ -302,6 +302,9 @@ enum {WQ_HIGHPRI =1 <<4 ,/* high priority */ WQ_CPU_INTENSIVE =1 <<5 ,/* cpu instensive workqueue */ WQ_SYSFS =1 <<6 ,/* visible in sysfs, see wq_sysfs_register() */ +WQ_POWER_EFFICIENT =1 <<7 ,/* WQ_UNBOUND, for power +* saving, if wq_power_efficient is +* enabled. Unused otherwise. */ __WQ_DRAINING =1 <<16 ,/* internal: workqueue is draining */ __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */
kernel/power/Kconfig +21 -0
@@ -263,6 +263,27 @@ config PM_GENERIC_DOMAINS bool depends on PM +config WQ_POWER_EFFICIENT + bool "Workqueue allocated as UNBOUND (by default) for power efficiency" + depends on PM + default n + help + Workqueues can be performance or power-oriented. Currently, most + workqueues are bound to the CPU they were created on. This gives good + performance (due to cache effects) at the cost of potentially waking + up otherwise idle cores (Idle from scheduler's perspective. Which may + or may not be physically idle) just to process some work. To save + power, we can allow the work to be rescheduled on a core that is + already awake. + + Workqueues created with the WQ_UNBOUND flag will allow some power + savings. However, we don't change the default behaviour of the + system. To enable power-saving behaviour, a new config option + CONFIG_WQ_POWER_EFFICIENT needs to be turned on. This option can also + be overridden by the workqueue.power_efficient boot parameter. + + If in doubt, say N. + config PM_GENERIC_DOMAINS_SLEEP def_bool y depends on PM_SLEEP && PM_GENERIC_DOMAINS
kernel/workqueue.c +8 -0
@@ -272,6 +272,14 @@ static cpumask_var_t *wq_numa_possible_cpumask;static bool wq_disable_numa;module_param_named (disable_numa, wq_disable_numa, bool,0444 ); +#ifdef CONFIG_WQ_POWER_EFFICIENT +static bool wq_power_efficient = true; +#else +static bool wq_power_efficient; +#endif + +module_param_named (power_efficient, wq_power_efficient, bool,0444 ); +static bool wq_numa_enabled;/* unbound NUMA affinity enabled */ /* buf for wq_update_unbound_numa_attrs(), protected by CPU hotplug
exclusion */
@@ -4085,6 +4093,9 @@ struct workqueue_struct
*__alloc_workqueue_key(const char *fmt,
struct workqueue_struct *wq;
struct pool_workqueue *pwq;
+ if ((flags & WQ_POWER_EFFICIENT) && wq_power_efficient)
+ flags |= WQ_UNBOUND;
+
/* allocate wq and format name */
if (flags & WQ_UNBOUND)
tbl_size = wq_numa_tbl_len * sizeof(wq->numa_pwq_tbl[0]);
From 8b051a73ec68235589571a710130ddf4347527fc Mon Sep 17 00:00:00 2001
Message-Id: <8b051a73ec68235589571a710130ddf4347527fc.1368433695.git.viresh.kumar@linaro.org>
From: Viresh Kumar <[email protected]>
Date: Mon, 8 Apr 2013 16:45:40 +0530
Subject: [PATCH V5 resent 1/5] workqueues: Introduce new flag
WQ_POWER_EFFICIENT for power oriented
workqueues
Workqueues can be performance or power-oriented. Currently, most workqueues are bound to the CPU they were created on. This gives good performance (due to cache effects) at the cost of potentially waking up otherwise idle cores (Idle from scheduler's perspective. Which may or may not be physically idle) just to process some work. To save power, we can allow the work to be rescheduled on a core that is already awake.
Workqueues created with the WQ_UNBOUND flag will allow some power savings. However, we don't change the default behaviour of the system. To enable power-saving behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT needs to be turned on. This option can also be overridden by the workqueue.power_efficient boot parameter.
--- Documentation/kernel-parameters.txt | 18 ++++++++++++++++++ include/linux/workqueue.h | 3 +++ kernel/power/Kconfig | 21 +++++++++++++++++++++ kernel/workqueue.c | 11 +++++++++++ 4 files changed, 53 insertions(+)
Documentation/kernel-parameters.txt +18 -0
@@ -3320,6 +3320,24 @@ bytes respectively. Such letter suffixes can also be entirely omitted. that this also can be controlled per-workqueue for workqueues visible under /sys/bus/workqueue/. + workqueue.power_efficient + Workqueues can be performance or power-oriented. + Currently, most workqueues are bound to the CPU they + were created on. This gives good performance (due to + cache effects) at the cost of potentially waking up + otherwise idle cores (Idle from scheduler's perspective. + Which may or may not be physically idle) just to process + some work. To save power, we can allow the work to be + rescheduled on a core that is already awake. + + Workqueues created with the WQ_UNBOUND flag will allow + some power savings. However, we don't change the + default behaviour of the system. To enable power-saving + behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT + needs to be turned on. This option can also be + overridden by the workqueue.power_efficient boot + parameter. + x2apic_phys [X86-64,APIC] Use x2apic physical mode instead of default x2apic cluster mode on platforms supporting x2apic.
include/linux/workqueue.h +3 -0
@@ -302,6 +302,9 @@ enum {WQ_HIGHPRI =1 <<4 ,/* high priority */ WQ_CPU_INTENSIVE =1 <<5 ,/* cpu instensive workqueue */ WQ_SYSFS =1 <<6 ,/* visible in sysfs, see wq_sysfs_register() */ +WQ_POWER_EFFICIENT =1 <<7 ,/* WQ_UNBOUND, for power +* saving, if wq_power_efficient is +* enabled. Unused otherwise. */ __WQ_DRAINING =1 <<16 ,/* internal: workqueue is draining */ __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */
kernel/power/Kconfig +21 -0
@@ -263,6 +263,27 @@ config PM_GENERIC_DOMAINS bool depends on PM +config WQ_POWER_EFFICIENT + bool "Workqueue allocated as UNBOUND (by default) for power efficiency" + depends on PM + default n + help + Workqueues can be performance or power-oriented. Currently, most + workqueues are bound to the CPU they were created on. This gives good + performance (due to cache effects) at the cost of potentially waking + up otherwise idle cores (Idle from scheduler's perspective. Which may + or may not be physically idle) just to process some work. To save + power, we can allow the work to be rescheduled on a core that is + already awake. + + Workqueues created with the WQ_UNBOUND flag will allow some power + savings. However, we don't change the default behaviour of the + system. To enable power-saving behaviour, a new config option + CONFIG_WQ_POWER_EFFICIENT needs to be turned on. This option can also + be overridden by the workqueue.power_efficient boot parameter. + + If in doubt, say N. + config PM_GENERIC_DOMAINS_SLEEP def_bool y depends on PM_SLEEP && PM_GENERIC_DOMAINS
kernel/workqueue.c +11 -0
@@ -272,6 +272,14 @@ static cpumask_var_t *wq_numa_possible_cpumask;static bool wq_disable_numa;module_param_named (disable_numa, wq_disable_numa, bool,0444 ); +#ifdef CONFIG_WQ_POWER_EFFICIENT +static bool wq_power_efficient = true; +#else +static bool wq_power_efficient; +#endif + +module_param_named (power_efficient, wq_power_efficient, bool,0444 ); +static bool wq_numa_enabled;/* unbound NUMA affinity enabled */ /* buf for wq_update_unbound_numa_attrs(), protected by CPU hotplug exclusion */
@@ -4085,6 +4093,9 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt,struct workqueue_struct *wq;struct pool_workqueue *pwq; +if ((flags &WQ_POWER_EFFICIENT ) && wq_power_efficient) + flags |=WQ_UNBOUND ; +/* allocate wq and format name */ if (flags &WQ_UNBOUND ) tbl_size = wq_numa_tbl_len *sizeof (wq->numa_pwq_tbl[0 ]);
Signature · 1 line
1.7.12.rc2.18.g61b472e
Re: [PATCH V5 1/5] workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
Quoted 1 line
From
cee22a15052faa817e3ec8985a28154d3fabc7aaMon Sep 17 00:00:00 2001
From: Viresh Kumar <[email protected]>
Date: Mon, 8 Apr 2013 16:45:40 +0530
Subject: workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues
Workqueues can be performance or power-oriented. Currently, most workqueues are bound to the CPU they were created on. This gives good performance (due to cache effects) at the cost of potentially waking up otherwise idle cores (Idle from scheduler's perspective. Which may or may not be physically idle) just to process some work. To save power, we can allow the work to be rescheduled on a core that is already awake.
Workqueues created with the WQ_UNBOUND flag will allow some power savings. However, we don't change the default behaviour of the system. To enable power-saving behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT needs to be turned on. This option can also be overridden by the workqueue.power_efficient boot parameter.
tj: Updated config description and comments. Renamed
CONFIG_WQ_POWER_EFFICIENT to CONFIG_WQ_POWER_EFFICIENT_DEFAULT.
--- Documentation/kernel-parameters.txt | 15 +++++++++++++++ include/linux/workqueue.h | 27 +++++++++++++++++++++++++++ kernel/power/Kconfig | 20 ++++++++++++++++++++ kernel/workqueue.c | 13 +++++++++++++ 4 files changed, 75 insertions(+)
Documentation/kernel-parameters.txt +15 -0
@@ -3320,6 +3320,21 @@ bytes respectively. Such letter suffixes can also be entirely omitted. that this also can be controlled per-workqueue for workqueues visible under /sys/bus/workqueue/. + workqueue.power_efficient + Per-cpu workqueues are generally preferred because + they show better performance thanks to cache + locality; unfortunately, per-cpu workqueues tend to + be more power hungry than unbound workqueues. + + Enabling this makes the per-cpu workqueues which + were observed to contribute significantly to power + consumption unbound, leading to measurably lower + power usage at the cost of small performance + overhead. + + The default value of this parameter is determined by + the config option CONFIG_WQ_POWER_EFFICIENT_DEFAULT. + x2apic_phys [X86-64,APIC] Use x2apic physical mode instead of default x2apic cluster mode on platforms supporting x2apic.
include/linux/workqueue.h +27 -0
@@ -303,6 +303,33 @@ enum {WQ_CPU_INTENSIVE =1 <<5 ,/* cpu instensive workqueue */ WQ_SYSFS =1 <<6 ,/* visible in sysfs, see wq_sysfs_register() */ +/* +* Per-cpu workqueues are generally preferred because they tend to +* show better performance thanks to cache locality. Per-cpu +* workqueues exclude the scheduler from choosing the CPU to +* execute the worker threads, which has an unfortunate side effect +* of increasing power consumption. +* +* The scheduler considers a CPU idle if it doesn't have any task +* to execute and tries to keep idle cores idle to conserve power; +* however, for example, a per-cpu work item scheduled from an +* interrupt handler on an idle CPU will force the scheduler to +* excute the work item on that CPU breaking the idleness, which in +* turn may lead to more scheduling choices which are sub-optimal +* in terms of power consumption. +* +* Workqueues marked with WQ_POWER_EFFICIENT are per-cpu by default +* but become unbound if workqueue.power_efficient kernel param is +* specified. Per-cpu workqueues which are identified to +* contribute significantly to power-consumption are identified and +* marked with this flag and enabling the power_efficient mode +* leads to noticeable power saving at the cost of small +* performance disadvantage. +* +* http://thread.gmane.org/gmane.linux.kernel/1480396 +*/ +WQ_POWER_EFFICIENT =1 <<7 , + __WQ_DRAINING =1 <<16 ,/* internal: workqueue is draining */ __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */
kernel/power/Kconfig +20 -0
@@ -263,6 +263,26 @@ config PM_GENERIC_DOMAINS bool depends on PM +config WQ_POWER_EFFICIENT_DEFAULT + bool "Enable workqueue power-efficient mode by default" + depends on PM + default n + help + Per-cpu workqueues are generally preferred because they show + better performance thanks to cache locality; unfortunately, + per-cpu workqueues tend to be more power hungry than unbound + workqueues. + + Enabling workqueue.power_efficient kernel parameter makes the + per-cpu workqueues which were observed to contribute + significantly to power consumption unbound, leading to measurably + lower power usage at the cost of small performance overhead. + + This config option determines whether workqueue.power_efficient + is enabled by default. + + If in doubt, say N. + config PM_GENERIC_DOMAINS_SLEEP def_bool y depends on PM_SLEEP && PM_GENERIC_DOMAINS
kernel/workqueue.c +13 -0
@@ -272,6 +272,15 @@ static cpumask_var_t *wq_numa_possible_cpumask;static bool wq_disable_numa;module_param_named (disable_numa, wq_disable_numa, bool,0444 ); +/* see the comment above the definition of WQ_POWER_EFFICIENT */ +#ifdef CONFIG_WQ_POWER_EFFICIENT_DEFAULT +static bool wq_power_efficient = true; +#else +static bool wq_power_efficient; +#endif + +module_param_named (power_efficient, wq_power_efficient, bool,0444 ); +static bool wq_numa_enabled;/* unbound NUMA affinity enabled */ /* buf for wq_update_unbound_numa_attrs(), protected by CPU hotplug exclusion */
@@ -4085,6 +4094,10 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt,struct workqueue_struct *wq;struct pool_workqueue *pwq; +/* see the comment above the definition of WQ_POWER_EFFICIENT */ +if ((flags &WQ_POWER_EFFICIENT ) && wq_power_efficient) + flags |=WQ_UNBOUND ; +/* allocate wq and format name */ if (flags &WQ_UNBOUND ) tbl_size = wq_numa_tbl_len *sizeof (wq->numa_pwq_tbl[0 ]);
Signature · 1 line
1.8.1.4
PATCH v5 2/5 workqueue: Add system wide power_efficient workqueues
In reply to Viresh KumarThis patch adds system wide workqueues aligned towards power saving. This is done by allocating them with WQ_UNBOUND flag if 'wq_power_efficient' is set to 'true'.
--- include/linux/workqueue.h | 7 +++++++ kernel/workqueue.c | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
include/linux/workqueue.h +7 -0
@@ -336,11 +336,18 @@ enum {* * system_freezable_wq is equivalent to system_wq except that it's * freezable. +* +* *_power_efficient_wq are inclined towards saving power. They are converted +* into WQ_UNBOUND variants, if 'wq_power_efficient' is set to 'true'. Otherwise +* they are same as their sibling types. Like: system_power_efficient_wq will +* behave like system_wq if 'wq_power_efficient' is not set to 'true'. */ extern struct workqueue_struct *system_wq;extern struct workqueue_struct *system_long_wq;extern struct workqueue_struct *system_unbound_wq;extern struct workqueue_struct *system_freezable_wq; +extern struct workqueue_struct *system_power_efficient_wq; +extern struct workqueue_struct *system_freezable_power_efficient_wq;static inline struct workqueue_struct *__deprecated __system_nrt_wq (void ) {
kernel/workqueue.c +12 -1
@@ -313,6 +313,10 @@ struct workqueue_struct *system_unbound_wq __read_mostly;EXPORT_SYMBOL_GPL (system_unbound_wq);struct workqueue_struct *system_freezable_wq__read_mostly ;EXPORT_SYMBOL_GPL (system_freezable_wq); +struct workqueue_struct *system_power_efficient_wq__read_mostly ; +EXPORT_SYMBOL_GPL (system_power_efficient_wq); +struct workqueue_struct *system_freezable_power_efficient_wq__read_mostly ; +EXPORT_SYMBOL_GPL (system_freezable_power_efficient_wq);static int worker_thread (void *__worker); static void copy_workqueue_attrs(struct workqueue_attrs *to,
@@ -4985,8 +4989,15 @@ static int __init init_workqueues(void) WQ_UNBOUND_MAX_ACTIVE); system_freezable_wq =alloc_workqueue ("events_freezable" ,WQ_FREEZABLE ,0 ); + system_power_efficient_wq =alloc_workqueue ("events_power_efficient" , +WQ_POWER_EFFICIENT ,0 ); + system_freezable_power_efficient_wq =alloc_workqueue ("events_freezable_power_efficient" , +WQ_FREEZABLE |WQ_POWER_EFFICIENT , +0 );BUG_ON (!system_wq || !system_highpri_wq || !system_long_wq || - !system_unbound_wq || !system_freezable_wq); + !system_unbound_wq || !system_freezable_wq || + !system_power_efficient_wq || + !system_freezable_power_efficient_wq);return 0 ; }early_initcall (init_workqueues);
Signature · 1 line
1.7.12.rc2.18.g61b472e
Tejun Heo
maintainerRe: [PATCH V5 2/5] workqueue: Add system wide power_efficient workqueues
This one is slightly updated too. The rest remain the same.
Quoted 1 line
From
0668106ca3865ba945e155097fb042bf66d364d3Mon Sep 17 00:00:00 2001
From: Viresh Kumar <[email protected]>
Date: Wed, 24 Apr 2013 17:12:54 +0530
Subject: workqueue: Add system wide power_efficient workqueues
This patch adds system wide workqueues aligned towards power saving. This is done by allocating them with WQ_UNBOUND flag if 'wq_power_efficient' is set to 'true'.
tj: updated comments a bit.
--- include/linux/workqueue.h | 8 ++++++++ kernel/workqueue.c | 13 ++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)
include/linux/workqueue.h +8 -0
@@ -360,11 +360,19 @@ enum {* * system_freezable_wq is equivalent to system_wq except that it's * freezable. +* +* *_power_efficient_wq are inclined towards saving power and converted +* into WQ_UNBOUND variants if 'wq_power_efficient' is enabled; otherwise, +* they are same as their non-power-efficient counterparts - e.g. +* system_power_efficient_wq is identical to system_wq if +* 'wq_power_efficient' is disabled. See WQ_POWER_EFFICIENT for more info. */ extern struct workqueue_struct *system_wq;extern struct workqueue_struct *system_long_wq;extern struct workqueue_struct *system_unbound_wq;extern struct workqueue_struct *system_freezable_wq; +extern struct workqueue_struct *system_power_efficient_wq; +extern struct workqueue_struct *system_freezable_power_efficient_wq;static inline struct workqueue_struct *__deprecated __system_nrt_wq (void ) {
kernel/workqueue.c +12 -1
@@ -314,6 +314,10 @@ struct workqueue_struct *system_unbound_wq __read_mostly;EXPORT_SYMBOL_GPL (system_unbound_wq);struct workqueue_struct *system_freezable_wq__read_mostly ;EXPORT_SYMBOL_GPL (system_freezable_wq); +struct workqueue_struct *system_power_efficient_wq__read_mostly ; +EXPORT_SYMBOL_GPL (system_power_efficient_wq); +struct workqueue_struct *system_freezable_power_efficient_wq__read_mostly ; +EXPORT_SYMBOL_GPL (system_freezable_power_efficient_wq);static int worker_thread (void *__worker); static void copy_workqueue_attrs(struct workqueue_attrs *to,
@@ -4987,8 +4991,15 @@ static int __init init_workqueues(void) WQ_UNBOUND_MAX_ACTIVE); system_freezable_wq =alloc_workqueue ("events_freezable" ,WQ_FREEZABLE ,0 ); + system_power_efficient_wq =alloc_workqueue ("events_power_efficient" , +WQ_POWER_EFFICIENT ,0 ); + system_freezable_power_efficient_wq =alloc_workqueue ("events_freezable_power_efficient" , +WQ_FREEZABLE |WQ_POWER_EFFICIENT , +0 );BUG_ON (!system_wq || !system_highpri_wq || !system_long_wq || - !system_unbound_wq || !system_freezable_wq); + !system_unbound_wq || !system_freezable_wq || + !system_power_efficient_wq || + !system_freezable_power_efficient_wq);return 0 ; }early_initcall (init_workqueues);
Signature · 1 line
1.8.1.4
PATCH v5 3/5 PHYLIB: queue work on system_power_efficient_wq
In reply to Viresh KumarPhylib uses workqueues for multiple purposes. There is no real dependency of scheduling these on the cpu which scheduled them.
On a idle system, it is observed that and idle cpu wakes up many times just to service this work. It would be better if we can schedule it on a cpu which the scheduler believes to be the most appropriate one.
This patch replaces system_wq with system_power_efficient_wq for PHYLIB.
--- drivers/net/phy/phy.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/phy/phy.c +5 -4
@@ -439,7 +439,7 @@ void phy_start_machine(struct phy_device *phydev, { phydev->adjust_state = handler; -schedule_delayed_work (&phydev->state_queue,HZ ); +queue_delayed_work (system_power_efficient_wq, &phydev->state_queue,HZ ); }/**
@@ -500,7 +500,7 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)disable_irq_nosync (irq);atomic_inc (&phydev->irq_disable); -schedule_work (&phydev->phy_queue); +queue_work (system_power_efficient_wq, &phydev->phy_queue);return IRQ_HANDLED ; }
@@ -655,7 +655,7 @@ static void phy_change(struct work_struct *work)/* reschedule state queue work to run as soon as possible */ cancel_delayed_work_sync (&phydev->state_queue); -schedule_delayed_work (&phydev->state_queue,0 ); +queue_delayed_work (system_power_efficient_wq, &phydev->state_queue,0 );return ;
@@ -918,7 +918,8 @@ void phy_state_machine(struct work_struct *work)if (err <0 )phy_error (phydev); -schedule_delayed_work (&phydev->state_queue,PHY_STATE_TIME *HZ ); +queue_delayed_work (system_power_efficient_wq, &phydev->state_queue, +PHY_STATE_TIME *HZ ); } static inline void mmd_phy_indirect(struct mii_bus *bus, int prtad, int devad,
Signature · 1 line
1.7.12.rc2.18.g61b472e
PATCH v5 4/5 block: queue work on power efficient wq
In reply to Viresh KumarBlock layer uses workqueues for multiple purposes. There is no real dependency of scheduling these on the cpu which scheduled them.
On a idle system, it is observed that and idle cpu wakes up many times just to service this work. It would be better if we can schedule it on a cpu which the scheduler believes to be the most appropriate one.
This patch replaces normal workqueues with power efficient versions.
--- block/blk-core.c | 3 ++- block/blk-ioc.c | 3 ++- block/genhd.c | 12 ++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-)
block/blk-core.c +2 -1
@@ -3187,7 +3187,8 @@ int __init blk_dev_init(void)/* used for unplugging and affects IO latency/throughput - HIGHPRI */ kblockd_workqueue =alloc_workqueue ("kblockd" , -WQ_MEM_RECLAIM |WQ_HIGHPRI ,0 ); +WQ_MEM_RECLAIM |WQ_HIGHPRI | +WQ_POWER_EFFICIENT ,0 );if (!kblockd_workqueue)panic ("Failed to create kblockd\n" );
block/blk-ioc.c +2 -1
@@ -144,7 +144,8 @@ void put_io_context(struct io_context *ioc)if (atomic_long_dec_and_test (&ioc->refcount)) {spin_lock_irqsave (&ioc->lock, flags);if (!hlist_empty (&ioc->icq_list)) -schedule_work (&ioc->release_work); +queue_work (system_power_efficient_wq, + &ioc->release_work);else free_ioc = true;spin_unlock_irqrestore (&ioc->lock, flags);
block/genhd.c +8 -4
@@ -1489,9 +1489,11 @@ static void __disk_unblock_events(struct gendisk *disk, bool check_now) intv =disk_events_poll_jiffies (disk);set_timer_slack (&ev->dwork.timer, intv /4 );if (check_now) -queue_delayed_work (system_freezable_wq, &ev->dwork,0 ); +queue_delayed_work (system_freezable_power_efficient_wq, + &ev->dwork,0 );else if (intv) -queue_delayed_work (system_freezable_wq, &ev->dwork, intv); +queue_delayed_work (system_freezable_power_efficient_wq, + &ev->dwork, intv); out_unlock:spin_unlock_irqrestore (&ev->lock, flags); }
@@ -1534,7 +1536,8 @@ void disk_flush_events(struct gendisk *disk, unsigned int mask)spin_lock_irq (&ev->lock); ev->clearing |= mask;if (!ev->block) -mod_delayed_work (system_freezable_wq, &ev->dwork,0 ); +mod_delayed_work (system_freezable_power_efficient_wq, + &ev->dwork,0 );spin_unlock_irq (&ev->lock); }
@@ -1627,7 +1630,8 @@ static void disk_check_events(struct disk_events *ev, intv =disk_events_poll_jiffies (disk);if (!ev->block && intv) -queue_delayed_work (system_freezable_wq, &ev->dwork, intv); +queue_delayed_work (system_freezable_power_efficient_wq, + &ev->dwork, intv);spin_unlock_irq (&ev->lock);
Signature · 1 line
1.7.12.rc2.18.g61b472e
Tejun Heo
maintainerRe: [PATCH V5 4/5] block: queue work on power efficient wq
Quoted 11 lines · Viresh Kumar
Block layer uses workqueues for multiple purposes. There is no real dependency of scheduling these on the cpu which scheduled them.
On a idle system, it is observed that and idle cpu wakes up many times just to service this work. It would be better if we can schedule it on a cpu which the scheduler believes to be the most appropriate one.
This patch replaces normal workqueues with power efficient versions.
Cc Jens Axboe <[email protected]>Signed-off-by Viresh Kumar <[email protected]>
Jens, applied this to wq/for-3.11. Please holler if you wanna route this differently.
Thanks.
Signature · 1 line
tejun
PATCH v5 5/5 fbcon: queue work on power efficient wq
In reply to Viresh Kumarfbcon uses workqueues and it has no real dependency of scheduling these on the cpu which scheduled them.
On a idle system, it is observed that and idle cpu wakes up many times just to service this work. It would be better if we can schedule it on a cpu which the scheduler believes to be the most appropriate one.
This patch replaces system_wq with system_power_efficient_wq.
--- drivers/video/console/fbcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/console/fbcon.c +1 -1
@@ -404,7 +404,7 @@ static void cursor_timer_handler(unsigned long dev_addr)struct fb_info *info = (struct fb_info *) dev_addr;struct fbcon_ops *ops = info->fbcon_par; -schedule_work (&info->queue); +queue_work (system_power_efficient_wq, &info->queue);mod_timer (&ops->cursor_timer, jiffies +HZ /5 ); }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Tejun Heo
maintainerRe: [PATCH V5 5/5] fbcon: queue work on power efficient wq
Quoted 7 lines · Viresh Kumar
fbcon uses workqueues and it has no real dependency of scheduling these on the cpu which scheduled them.
On a idle system, it is observed that and idle cpu wakes up many times just to service this work. It would be better if we can schedule it on a cpu which the scheduler believes to be the most appropriate one.
Quoted 5 lines
This patch replaces
system_wqwithsystem_power_efficient_wq.Cc Dave Airlie <[email protected]>Signed-off-by Viresh Kumar <[email protected]>
Dave, applied this to wq/for-3.11. Please holler if you want this to be routed differently.
Thanks!
Signature · 1 line
tejun
Quoted 2 lines · Viresh Kumar
This patchset was called: "Create
sched_select_cpu()and use it for workqueues" for the first three versions.
Applied to wq/for-3.11 with some updates to comments and documentation. Will post the applied versions. If something is awry, please let me know.
Thanks.
Signature · 1 line
tejun
Quoted 7 lines · Tejun Heo
Quoted 2 lines · Viresh Kumar
This patchset was called: "Create
sched_select_cpu()and use it for workqueues" for the first three versions.Applied to wq/for-3.11 with some updates to comments and documentation. Will post the applied versions. If something is awry, please let me know.
Thanks. All looks good.
Hello,
Quoted 27 lines · Viresh Kumar
This patchset was called: "Create
sched_select_cpu()and use it for workqueues" for the first three versions.Earlier discussions over v3, v2 and v1 can be found here:
https://lkml.org/lkml/2013/3/18/364
http://lists.linaro.org/pipermail/linaro-dev/2012-November/014344.html
http://www.mail-archive.com/[email protected]/msg13342.htmlV4 is here:
https://lkml.org/lkml/2013/3/31/55Workqueues can be performance or power oriented. For performance we may want to keep them running on a single cpu, so that it remains cache hot. For power we can give scheduler the liberty to choose target cpu for running work handler.
Later one (Power oriented WQ) can be achieved if the workqueue is allocated with
WQ_UNBOUNDflag. EnablingCONFIG_WQ_POWER_EFFICIENTwill set 'wq_power_efficient' to 'true'. Setting 'power_efficient' boot param will override value of 'wq_power_efficient' variable. When 'wq_power_efficient' is set to 'true', we will convertWQ_POWER_EFFICIENTflag toWQ_UNBOUNDon wq allocation. And so scheduler will have the liberty to choose where to run this work.Here we are migrating few users of workqueues to
WQ_POWER_EFFICIENT. These drivers are found to be very much active on idle or lightly busy system and usingWQ_POWER_EFFICIENTfor these gave impressive results.
Quoted 8 lines
These would be used in power saving mode only if relevant configs are enabled at compile time or in bootargs. Otherwise behavior is unchanged.
Setup:
-----
- ARM Vexpress TC2 - big.LITTLE CPU
- Core 0-1: A15, 2-4: A7
- rootfs: linaro-ubuntu-devel
This patch set hit my tree now. I wonder if it makes sense to make WQ_POWER_EFFICIENT_DEFAULT depend on SMP. (Oh wait, big.LITTLE isn't SMP, so probably there is a better symbol to depend on?)
Just my 2 cent
Uwe
Signature · 6 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 3 lines · Uwe Kleine-König
This patch set hit my tree now. I wonder if it makes sense to make
WQ_POWER_EFFICIENT_DEFAULTdepend on SMP. (Oh wait, big.LITTLE isn't SMP, so probably there is a better symbol to depend on?)
Well, big LITTLE still runs an SMP kernel :) and so has this flag set. You can make it dependent on that if required.
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Viresh Kumar
Quoted 3 lines · Uwe Kleine-König
This patch set hit my tree now. I wonder if it makes sense to make
WQ_POWER_EFFICIENT_DEFAULTdepend on SMP. (Oh wait, big.LITTLE isn't SMP, so probably there is a better symbol to depend on?)Well, big LITTLE still runs an SMP kernel :) and so has this flag set.
The 'S' is justified because cpu0 and cpu1 are of the same type? Are there b.L systems that have only one big and one LITTLE cpu? Do these use SMP, too?
Quoted 1 line
You can make it dependent on that if required.
Well, it's not required. It's just that the corresponding question in make oldconfig isn't really an enrichment for a kernel targeting an Cortex M3 :-)
Uwe
Signature · 6 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Uwe Kleine-König
Quoted 1 line · Viresh Kumar
Well, big LITTLE still runs an SMP kernel :) and so has this flag set.
The 'S' is justified because cpu0 and cpu1 are of the same type? Are there b.L systems that have only one big and one LITTLE cpu? Do these use SMP, too?
Following definition of SMP says:
http://en.wikipedia.org/wiki/Symmetric_Multiprocessor
A system is SMP when:
- It has same type of cores
- controlled by a single instance of OS.
In big LITTLE first one is obviously not completely true as you pointed out. But second one is and so I would say its an SMP system :)
Don't know how it should be called though.
Quoted 4 lines
Quoted 1 line
You can make it dependent on that if required.
Well, it's not required. It's just that the corresponding question in make oldconfig isn't really an enrichment for a kernel targeting an Cortex M3 :-)
Just to make it clear enough, you are saying it doesn't make any sense to enable it for M3? But because it is disabled by default, the problem is not seen?
Why? Can't we have two M3's on a SoC and run an SMP kernel over it?
--
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello,
Quoted 11 lines · Viresh Kumar
Quoted 6 lines · Uwe Kleine-König
Quoted 1 line · Viresh Kumar
Well, big LITTLE still runs an SMP kernel :) and so has this flag set.
The 'S' is justified because cpu0 and cpu1 are of the same type? Are there b.L systems that have only one big and one LITTLE cpu? Do these use SMP, too?
Following definition of SMP says:
http://en.wikipedia.org/wiki/Symmetric_Multiprocessor
Quoted 8 lines
A system is SMP when:
- It has same type of cores
- controlled by a single instance of OS.In big LITTLE first one is obviously not completely true as you pointed out. But second one is and so I would say its an SMP system :)
Don't know how it should be called though.
MP maybe.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
You can make it dependent on that if required.
Well, it's not required. It's just that the corresponding question in make oldconfig isn't really an enrichment for a kernel targeting an Cortex M3 :-)
Just to make it clear enough, you are saying it doesn't make any sense to enable it for M3? But because it is disabled by default, the problem is not seen?
No I'm saying that asking me is bad because on an UP machine it won't matter what I answer. So please don't ask me if SMP is off.
Quoted 2 lines
Why? Can't we have two M3's on a SoC and run an SMP kernel over it?
Yeah, you can. Then you'd have SMP (or MP) enabled though and the choice for that workqueue thing makes a difference. In that case asking is OK.
Best regards
Uwe
Signature · 6 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html