Skip to contentSkip to conversation

hotfix: make sysfs of unbound kworker cpumask more clever

PATCH Superseded [email protected] 2 participants 2 messages Oct 14, 2021 Workqueue

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hotfix: make sysfs of unbound kworker cpumask more clever

From: Mengen Sun <[email protected]>

some unfriendly component eg, dpdk, write the same mask to unbound kworker cpumask again and agin. every time it write to this interface some work is queue to cpu, by rr evenly the mask is same with the original mask.

so, fix it, if the writing cpumask is equal with the old cpumask just return success and do nothing.

---
 kernel/workqueue.c | 5 +++++
 1 file changed, 5 insertions(+)
kernel/workqueue.c +5 -0
index 1b3eb1e9531f..8216fc45c77b 100644
@@ -5394,6 +5394,11 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
 	cpumask_and(cpumask, cpumask, cpu_possible_mask);
 	if (!cpumask_empty(cpumask)) {
 		apply_wqattrs_lock();
+		if (cpumask_equal(cpumask, wq_unbound_cpumask)) {
+			apply_wqattrs_unlock();
+			free_cpumask_var(saved_cpumask);
+			return 0;
+		}
 
 		/* save the old wq_unbound_cpumask. */
 		cpumask_copy(saved_cpumask, wq_unbound_cpumask);
Signature · 1 line
2.27.0
maintainer
#1 lore raw

Hello,

kernel/workqueue.c int workqueue_set_unbound_cpumask(cpumask_var_t cpumask) · line 5399

Quoted 11 lines · On Thu, Oct 14, 2021 at 11:06:41AM +0800, [email protected] wrote:
kernel/workqueue.c +3 -0
index 1b3eb1e9531f..8216fc45c77b 100644
@@ -5394,6 +5394,11 @@ int workqueue_set_unbound_cpumask(cpumask_var_t cpumask)
 	cpumask_and(cpumask, cpumask, cpu_possible_mask);
 	if (!cpumask_empty(cpumask)) {
 		apply_wqattrs_lock();
+		if (cpumask_equal(cpumask, wq_unbound_cpumask)) {
+			apply_wqattrs_unlock();
+			free_cpumask_var(saved_cpumask);

A few nitpicks:

* Please replace "hotfix:" with "workqueue:".

* Can you reorganize the code so that it doesn't have to alloc and free the saved_mask?

Thanks.

Signature · 1 line
tejun