Skip to content

Commit 5736f1d

Browse files
menglongdonggregkh
authored andcommitted
workqueue: make sysfs of unbound kworker cpumask more clever
[ Upstream commit d25302e ] Some unfriendly component, such as dpdk, write the same mask to unbound kworker cpumask again and again. Every time it write to this interface some work is queue to cpu, even though the mask is same with the original mask. So, fix it by return success and do nothing if the cpumask is equal with the old one. Signed-off-by: Mengen Sun <mengensun@tencent.com> Signed-off-by: Menglong Dong <imagedong@tencent.com> Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ab5c46f commit 5736f1d

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

kernel/workqueue.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5326,16 +5326,22 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
53265326
int ret = -EINVAL;
53275327
cpumask_var_t saved_cpumask;
53285328

5329-
if (!zalloc_cpumask_var(&saved_cpumask, GFP_KERNEL))
5330-
return -ENOMEM;
5331-
53325329
/*
53335330
* Not excluding isolated cpus on purpose.
53345331
* If the user wishes to include them, we allow that.
53355332
*/
53365333
cpumask_and(cpumask, cpumask, cpu_possible_mask);
53375334
if (!cpumask_empty(cpumask)) {
53385335
apply_wqattrs_lock();
5336+
if (cpumask_equal(cpumask, wq_unbound_cpumask)) {
5337+
ret = 0;
5338+
goto out_unlock;
5339+
}
5340+
5341+
if (!zalloc_cpumask_var(&saved_cpumask, GFP_KERNEL)) {
5342+
ret = -ENOMEM;
5343+
goto out_unlock;
5344+
}
53395345

53405346
/* save the old wq_unbound_cpumask. */
53415347
cpumask_copy(saved_cpumask, wq_unbound_cpumask);
@@ -5348,10 +5354,11 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
53485354
if (ret < 0)
53495355
cpumask_copy(wq_unbound_cpumask, saved_cpumask);
53505356

5357+
free_cpumask_var(saved_cpumask);
5358+
out_unlock:
53515359
apply_wqattrs_unlock();
53525360
}
53535361

5354-
free_cpumask_var(saved_cpumask);
53555362
return ret;
53565363
}
53575364

0 commit comments

Comments
 (0)