Skip to content

Commit d25302e

Browse files
menglongdonghtejun
authored andcommitted
workqueue: make sysfs of unbound kworker cpumask more clever
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 <[email protected]> Signed-off-by: Menglong Dong <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent d9abdee commit d25302e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

kernel/workqueue.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5384,16 +5384,22 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
53845384
int ret = -EINVAL;
53855385
cpumask_var_t saved_cpumask;
53865386

5387-
if (!zalloc_cpumask_var(&saved_cpumask, GFP_KERNEL))
5388-
return -ENOMEM;
5389-
53905387
/*
53915388
* Not excluding isolated cpus on purpose.
53925389
* If the user wishes to include them, we allow that.
53935390
*/
53945391
cpumask_and(cpumask, cpumask, cpu_possible_mask);
53955392
if (!cpumask_empty(cpumask)) {
53965393
apply_wqattrs_lock();
5394+
if (cpumask_equal(cpumask, wq_unbound_cpumask)) {
5395+
ret = 0;
5396+
goto out_unlock;
5397+
}
5398+
5399+
if (!zalloc_cpumask_var(&saved_cpumask, GFP_KERNEL)) {
5400+
ret = -ENOMEM;
5401+
goto out_unlock;
5402+
}
53975403

53985404
/* save the old wq_unbound_cpumask. */
53995405
cpumask_copy(saved_cpumask, wq_unbound_cpumask);
@@ -5406,10 +5412,11 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
54065412
if (ret < 0)
54075413
cpumask_copy(wq_unbound_cpumask, saved_cpumask);
54085414

5415+
free_cpumask_var(saved_cpumask);
5416+
out_unlock:
54095417
apply_wqattrs_unlock();
54105418
}
54115419

5412-
free_cpumask_var(saved_cpumask);
54135420
return ret;
54145421
}
54155422

0 commit comments

Comments
 (0)