Skip to content

Commit 8416588

Browse files
Lai Jiangshanhtejun
authored andcommitted
workqueue: Update cpumasks after only applying it successfully
Make workqueue_unbound_exclude_cpumask() and workqueue_set_unbound_cpumask() only update wq_isolated_cpumask and wq_requested_unbound_cpumask when workqueue_apply_unbound_cpumask() returns successfully. Fixes: fe28f63("workqueue: Add workqueue_unbound_exclude_cpumask() to exclude CPUs from wq_unbound_cpumask") Cc: Waiman Long <[email protected]> Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 98f887f commit 8416588

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

kernel/workqueue.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6848,9 +6848,6 @@ int workqueue_unbound_exclude_cpumask(cpumask_var_t exclude_cpumask)
68486848
lockdep_assert_cpus_held();
68496849
mutex_lock(&wq_pool_mutex);
68506850

6851-
/* Save the current isolated cpumask & export it via sysfs */
6852-
cpumask_copy(wq_isolated_cpumask, exclude_cpumask);
6853-
68546851
/*
68556852
* If the operation fails, it will fall back to
68566853
* wq_requested_unbound_cpumask which is initially set to
@@ -6862,6 +6859,10 @@ int workqueue_unbound_exclude_cpumask(cpumask_var_t exclude_cpumask)
68626859
if (!cpumask_equal(cpumask, wq_unbound_cpumask))
68636860
ret = workqueue_apply_unbound_cpumask(cpumask);
68646861

6862+
/* Save the current isolated cpumask & export it via sysfs */
6863+
if (!ret)
6864+
cpumask_copy(wq_isolated_cpumask, exclude_cpumask);
6865+
68656866
mutex_unlock(&wq_pool_mutex);
68666867
free_cpumask_var(cpumask);
68676868
return ret;
@@ -7197,7 +7198,6 @@ static int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
71977198
cpumask_and(cpumask, cpumask, cpu_possible_mask);
71987199
if (!cpumask_empty(cpumask)) {
71997200
apply_wqattrs_lock();
7200-
cpumask_copy(wq_requested_unbound_cpumask, cpumask);
72017201
if (cpumask_equal(cpumask, wq_unbound_cpumask)) {
72027202
ret = 0;
72037203
goto out_unlock;
@@ -7206,6 +7206,8 @@ static int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
72067206
ret = workqueue_apply_unbound_cpumask(cpumask);
72077207

72087208
out_unlock:
7209+
if (!ret)
7210+
cpumask_copy(wq_requested_unbound_cpumask, cpumask);
72097211
apply_wqattrs_unlock();
72107212
}
72117213

0 commit comments

Comments
 (0)