workqueue: Schedule workers on CPU0 or 0-5 by default

For regular bound workers that don't request to be queued onto a specific
CPU, just use CPU0 to save power. Additionally, adjust the CPU affinity of
unbound workqueues to force their workers onto the power cluster (CPUs 0-5)
to further improve power consumption.

Change-Id: Ib3aede9947c4a2c2673adc5f5b7c4e0c2c4520bf
Signed-off-by: Sultanxda <sultanxda@gmail.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This commit is contained in:
Sultanxda 2017-11-29 01:20:03 -08:00 committed by Richard Raya
parent a771b8ad1b
commit fae4a4fed8

View File

@ -1416,6 +1416,9 @@ static void __queue_work(int cpu, struct workqueue_struct *wq,
if (unlikely(wq->flags & __WQ_DRAINING) &&
WARN_ON_ONCE(!is_chained_work(wq)))
return;
if (req_cpu == WORK_CPU_UNBOUND)
cpu = wq_select_unbound_cpu(0);
retry:
/* pwq which will be used unless @work is executing elsewhere */
if (wq->flags & WQ_UNBOUND) {
@ -1569,7 +1572,7 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq,
if (unlikely(cpu != WORK_CPU_UNBOUND))
add_timer_on(timer, cpu);
else
add_timer(timer);
add_timer_on(timer, 0);
}
/**
@ -3265,6 +3268,7 @@ void free_workqueue_attrs(struct workqueue_attrs *attrs)
struct workqueue_attrs *alloc_workqueue_attrs(gfp_t gfp_mask)
{
struct workqueue_attrs *attrs;
const unsigned long allowed_cpus = 0x3F;
attrs = kzalloc(sizeof(*attrs), gfp_mask);
if (!attrs)
@ -3272,7 +3276,7 @@ struct workqueue_attrs *alloc_workqueue_attrs(gfp_t gfp_mask)
if (!alloc_cpumask_var(&attrs->cpumask, gfp_mask))
goto fail;
cpumask_copy(attrs->cpumask, cpu_possible_mask);
cpumask_copy(attrs->cpumask, to_cpumask(&allowed_cpus));
return attrs;
fail:
free_workqueue_attrs(attrs);
@ -4378,7 +4382,7 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq)
rcu_read_lock_sched();
if (cpu == WORK_CPU_UNBOUND)
cpu = smp_processor_id();
cpu = 0;
if (!(wq->flags & WQ_UNBOUND))
pwq = per_cpu_ptr(wq->cpu_pwqs, cpu);