History

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.

Viresh Kumar committed 13 years ago

Commit cee22a11 parent f7224064 files · +75 −0Browse files

Showing the changes to kernel/workqueue.c (1 of 4 files). Show all

Unified · Split

kernel/workqueue.c+13−0
@@ -272,6 +272,15 @@ static cpumask_var_t *wq_numa_possible_cpumask; · 271 unmodified lines
272272 static bool wq_disable_numa;
273273 module_param_named(disable_numa, wq_disable_numa, bool, 0444);
274274
275+/* see the comment above the definition of WQ_POWER_EFFICIENT */
276+#ifdef CONFIG_WQ_POWER_EFFICIENT_DEFAULT
277+static bool wq_power_efficient = true;
278+#else
279+static bool wq_power_efficient;
280+#endif
281+
282+module_param_named(power_efficient, wq_power_efficient, bool, 0444);
283+
275284 static bool wq_numa_enabled; /* unbound NUMA affinity enabled */
276285
277286 /* 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, · 3807 unmodified lines
40854094 struct workqueue_struct *wq;
40864095 struct pool_workqueue *pwq;
40874096
4097+ /* see the comment above the definition of WQ_POWER_EFFICIENT */
4098+ if ((flags & WQ_POWER_EFFICIENT) && wq_power_efficient)
4099+ flags |= WQ_UNBOUND;
4100+
40884101 /* allocate wq and format name */
40894102 if (flags & WQ_UNBOUND)
40904103 tbl_size = wq_numa_tbl_len * sizeof(wq->numa_pwq_tbl[0]);