diff options
author | Lai Jiangshan <jiangshan.ljs@antgroup.com> | 2024-07-02 06:14:55 +0200 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2024-07-02 19:14:33 +0200 |
commit | 841658832335a32dd86f4e4d3aab7d14188b268b (patch) | |
tree | 220c1bb4feaaee7b55894d262587e422e89acaee /kernel/workqueue.c | |
parent | workqueue: Improve scalability of workqueue watchdog touch (diff) | |
download | linux-841658832335a32dd86f4e4d3aab7d14188b268b.tar.xz linux-841658832335a32dd86f4e4d3aab7d14188b268b.zip |
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: fe28f631fa94("workqueue: Add workqueue_unbound_exclude_cpumask() to exclude CPUs from wq_unbound_cpumask")
Cc: Waiman Long <longman@redhat.com>
Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r-- | kernel/workqueue.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index e271d02f3d8c..6adee950077a 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -6848,9 +6848,6 @@ int workqueue_unbound_exclude_cpumask(cpumask_var_t exclude_cpumask) lockdep_assert_cpus_held(); mutex_lock(&wq_pool_mutex); - /* Save the current isolated cpumask & export it via sysfs */ - cpumask_copy(wq_isolated_cpumask, exclude_cpumask); - /* * If the operation fails, it will fall back to * wq_requested_unbound_cpumask which is initially set to @@ -6862,6 +6859,10 @@ int workqueue_unbound_exclude_cpumask(cpumask_var_t exclude_cpumask) if (!cpumask_equal(cpumask, wq_unbound_cpumask)) ret = workqueue_apply_unbound_cpumask(cpumask); + /* Save the current isolated cpumask & export it via sysfs */ + if (!ret) + cpumask_copy(wq_isolated_cpumask, exclude_cpumask); + mutex_unlock(&wq_pool_mutex); free_cpumask_var(cpumask); return ret; @@ -7197,7 +7198,6 @@ static int workqueue_set_unbound_cpumask(cpumask_var_t cpumask) cpumask_and(cpumask, cpumask, cpu_possible_mask); if (!cpumask_empty(cpumask)) { apply_wqattrs_lock(); - cpumask_copy(wq_requested_unbound_cpumask, cpumask); if (cpumask_equal(cpumask, wq_unbound_cpumask)) { ret = 0; goto out_unlock; @@ -7206,6 +7206,8 @@ static int workqueue_set_unbound_cpumask(cpumask_var_t cpumask) ret = workqueue_apply_unbound_cpumask(cpumask); out_unlock: + if (!ret) + cpumask_copy(wq_requested_unbound_cpumask, cpumask); apply_wqattrs_unlock(); } |