Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

workqueue: Avoid using isolated cpus' timers on queue_delayed_work

When __queue_delayed_work() is called, it chooses a cpu for handling the
timer interrupt. As of today, it will pick either the cpu passed as
parameter or the last cpu used for this.

This is not good if a system does use CPU isolation, because it can take
away some valuable cpu time to:
1 - deal with the timer interrupt,
2 - schedule-out the desired task,
3 - queue work on a random workqueue, and
4 - schedule the desired task back to the cpu.

So to fix this, during __queue_delayed_work(), if cpu isolation is in
place, pick a random non-isolated cpu to handle the timer interrupt.

As an optimization, if the current cpu is not isolated, use it instead
of looking for another candidate.

Signed-off-by: Leonardo Bras <leobras@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Leonardo Bras and committed by
Tejun Heo
aae17ebb 07daa99b

+11 -3
+11 -3
kernel/workqueue.c
··· 2362 2362 dwork->cpu = cpu; 2363 2363 timer->expires = jiffies + delay; 2364 2364 2365 - if (unlikely(cpu != WORK_CPU_UNBOUND)) 2365 + if (housekeeping_enabled(HK_TYPE_TIMER)) { 2366 + /* If the current cpu is a housekeeping cpu, use it. */ 2367 + cpu = smp_processor_id(); 2368 + if (!housekeeping_test_cpu(cpu, HK_TYPE_TIMER)) 2369 + cpu = housekeeping_any_cpu(HK_TYPE_TIMER); 2366 2370 add_timer_on(timer, cpu); 2367 - else 2368 - add_timer(timer); 2371 + } else { 2372 + if (likely(cpu == WORK_CPU_UNBOUND)) 2373 + add_timer(timer); 2374 + else 2375 + add_timer_on(timer, cpu); 2376 + } 2369 2377 } 2370 2378 2371 2379 /**