Skip to content

Commit 8d84baf

Browse files
Lai Jiangshanhtejun
authored andcommitted
workqueue: Add wq_online_cpumask
The new wq_online_mask mirrors the cpu_online_mask except during hotplugging; specifically, it differs between the hotplugging stages of workqueue_offline_cpu() and workqueue_online_cpu(), during which the transitioning CPU is not represented in the mask. Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 449b31a commit 8d84baf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

kernel/workqueue.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,9 @@ static struct rcuwait manager_wait = __RCUWAIT_INITIALIZER(manager_wait);
444444
static LIST_HEAD(workqueues); /* PR: list of all workqueues */
445445
static bool workqueue_freezing; /* PL: have wqs started freezing? */
446446

447+
/* PL: mirror the cpu_online_mask excluding the CPU in the midst of hotplugging */
448+
static cpumask_var_t wq_online_cpumask;
449+
447450
/* PL&A: allowable cpus for unbound wqs and work items */
448451
static cpumask_var_t wq_unbound_cpumask;
449452

@@ -6574,6 +6577,8 @@ int workqueue_online_cpu(unsigned int cpu)
65746577

65756578
mutex_lock(&wq_pool_mutex);
65766579

6580+
cpumask_set_cpu(cpu, wq_online_cpumask);
6581+
65776582
for_each_pool(pool, pi) {
65786583
/* BH pools aren't affected by hotplug */
65796584
if (pool->flags & POOL_BH)
@@ -6620,6 +6625,9 @@ int workqueue_offline_cpu(unsigned int cpu)
66206625

66216626
/* update pod affinity of unbound workqueues */
66226627
mutex_lock(&wq_pool_mutex);
6628+
6629+
cpumask_clear_cpu(cpu, wq_online_cpumask);
6630+
66236631
list_for_each_entry(wq, &workqueues, list) {
66246632
struct workqueue_attrs *attrs = wq->unbound_attrs;
66256633

@@ -7649,10 +7657,12 @@ void __init workqueue_init_early(void)
76497657

76507658
BUILD_BUG_ON(__alignof__(struct pool_workqueue) < __alignof__(long long));
76517659

7660+
BUG_ON(!alloc_cpumask_var(&wq_online_cpumask, GFP_KERNEL));
76527661
BUG_ON(!alloc_cpumask_var(&wq_unbound_cpumask, GFP_KERNEL));
76537662
BUG_ON(!alloc_cpumask_var(&wq_requested_unbound_cpumask, GFP_KERNEL));
76547663
BUG_ON(!zalloc_cpumask_var(&wq_isolated_cpumask, GFP_KERNEL));
76557664

7665+
cpumask_copy(wq_online_cpumask, cpu_online_mask);
76567666
cpumask_copy(wq_unbound_cpumask, cpu_possible_mask);
76577667
restrict_unbound_cpumask("HK_TYPE_WQ", housekeeping_cpumask(HK_TYPE_WQ));
76587668
restrict_unbound_cpumask("HK_TYPE_DOMAIN", housekeeping_cpumask(HK_TYPE_DOMAIN));

0 commit comments

Comments
 (0)