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: replace use of system_wq with system_percpu_wq

Currently if a user enqueue a work item using schedule_delayed_work() the
used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use
WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to
schedule_work() that is using system_wq and queue_work(), that makes use
again of WORK_CPU_UNBOUND.

This lack of consistentcy cannot be addressed without refactoring the API.

system_wq is a per-CPU worqueue, yet nothing in its name tells about that
CPU affinity constraint, which is very often not required by users. Make
it clear by adding a system_percpu_wq.

queue_work() / queue_delayed_work() mod_delayed_work() will now use the
new per-cpu wq: whether the user still stick on the old name a warn will
be printed along a wq redirect to the new one.

This patch add the new system_percpu_wq except for mm, fs and net
subsystem, whom are handled in separated patches.

The old wq will be kept for a few release cylces.

Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Marco Crivellari and committed by
Tejun Heo
a2be943b f6cfa602

+12 -12
+11 -11
include/linux/workqueue.h
··· 434 434 * short queue flush time. Don't queue works which can run for too 435 435 * long. 436 436 * 437 - * system_highpri_wq is similar to system_wq but for work items which 437 + * system_highpri_wq is similar to system_percpu_wq but for work items which 438 438 * require WQ_HIGHPRI. 439 439 * 440 - * system_long_wq is similar to system_wq but may host long running 440 + * system_long_wq is similar to system_percpu_wq but may host long running 441 441 * works. Queue flushing might take relatively long. 442 442 * 443 443 * system_dfl_wq is unbound workqueue. Workers are not bound to ··· 445 445 * executed immediately as long as max_active limit is not reached and 446 446 * resources are available. 447 447 * 448 - * system_freezable_wq is equivalent to system_wq except that it's 448 + * system_freezable_wq is equivalent to system_percpu_wq except that it's 449 449 * freezable. 450 450 * 451 451 * *_power_efficient_wq are inclined towards saving power and converted 452 452 * into WQ_UNBOUND variants if 'wq_power_efficient' is enabled; otherwise, 453 453 * they are same as their non-power-efficient counterparts - e.g. 454 - * system_power_efficient_wq is identical to system_wq if 454 + * system_power_efficient_wq is identical to system_percpu_wq if 455 455 * 'wq_power_efficient' is disabled. See WQ_POWER_EFFICIENT for more info. 456 456 * 457 457 * system_bh[_highpri]_wq are convenience interface to softirq. BH work items ··· 708 708 */ 709 709 static inline bool schedule_work_on(int cpu, struct work_struct *work) 710 710 { 711 - return queue_work_on(cpu, system_wq, work); 711 + return queue_work_on(cpu, system_percpu_wq, work); 712 712 } 713 713 714 714 /** ··· 727 727 */ 728 728 static inline bool schedule_work(struct work_struct *work) 729 729 { 730 - return queue_work(system_wq, work); 730 + return queue_work(system_percpu_wq, work); 731 731 } 732 732 733 733 /** ··· 770 770 #define flush_scheduled_work() \ 771 771 ({ \ 772 772 __warn_flushing_systemwide_wq(); \ 773 - __flush_workqueue(system_wq); \ 773 + __flush_workqueue(system_percpu_wq); \ 774 774 }) 775 775 776 776 #define flush_workqueue(wq) \ 777 777 ({ \ 778 778 struct workqueue_struct *_wq = (wq); \ 779 779 \ 780 - if ((__builtin_constant_p(_wq == system_wq) && \ 781 - _wq == system_wq) || \ 780 + if ((__builtin_constant_p(_wq == system_percpu_wq) && \ 781 + _wq == system_percpu_wq) || \ 782 782 (__builtin_constant_p(_wq == system_highpri_wq) && \ 783 783 _wq == system_highpri_wq) || \ 784 784 (__builtin_constant_p(_wq == system_long_wq) && \ ··· 807 807 static inline bool schedule_delayed_work_on(int cpu, struct delayed_work *dwork, 808 808 unsigned long delay) 809 809 { 810 - return queue_delayed_work_on(cpu, system_wq, dwork, delay); 810 + return queue_delayed_work_on(cpu, system_percpu_wq, dwork, delay); 811 811 } 812 812 813 813 /** ··· 821 821 static inline bool schedule_delayed_work(struct delayed_work *dwork, 822 822 unsigned long delay) 823 823 { 824 - return queue_delayed_work(system_wq, dwork, delay); 824 + return queue_delayed_work(system_percpu_wq, dwork, delay); 825 825 } 826 826 827 827 #ifndef CONFIG_SMP
+1 -1
kernel/workqueue.c
··· 7668 7668 if (ret) 7669 7669 return ret; 7670 7670 7671 - if (system_wq) 7671 + if (system_percpu_wq) 7672 7672 wq_watchdog_set_thresh(thresh); 7673 7673 else 7674 7674 wq_watchdog_thresh = thresh;