Skip to contentSkip to conversation

workqueue: get the probable node ID from the first CPU of the mask

PATCH In review Lai Jiangshan 2 participants 4 messages Jul 22, 2014 – Jul 23, 2014 Workqueue

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 workqueue: get the probable node ID from the first CPU of the mask

Current get_unbound_pool() considers all node IDs are probable for the pool, and it travel all nodes to find the node ID for the pool. This travel is unnecessary, the probable node ID can be attained from the first CPU and we need check only one possible node ID.

---
 kernel/workqueue.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
kernel/workqueue.c +4 -6
index 347ac5b..942103d9 100644
@@ -3482,12 +3482,10 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
 
 	/* if cpumask is contained inside a NUMA node, we belong to that node */
 	if (wq_numa_enabled) {
-		for_each_node(node) {
-			if (cpumask_subset(pool->attrs->cpumask,
-					   wq_numa_possible_cpumask[node])) {
-				pool->node = node;
-				break;
-			}
+		node = cpu_to_node(cpumask_first(pool->attrs->cpumask));
+		if (cpumask_subset(pool->attrs->cpumask,
+				   wq_numa_possible_cpumask[node])) {
+			pool->node = node;
 		}
 	}
 
Signature · 1 line
1.7.4.4
maintainer
#1 lore raw

kernel/workqueue.c static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs) · line 3485

Quoted 1 line · Lai Jiangshan
kernel/workqueue.c +1 -0
+		node = cpu_to_node(cpumask_first(pool->attrs->cpumask));

Minor but maybe cpumask_any() is a better fit here?

Thanks.

Signature · 1 line
tejun
#2 lore raw
Quoted 5 lines · Tejun Heo

kernel/workqueue.c static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs) · line 3485

Quoted 1 line · Lai Jiangshan
kernel/workqueue.c +1 -0
+		node = cpu_to_node(cpumask_first(pool->attrs->cpumask));

Minor but maybe cpumask_any() is a better fit here?

It is OK, the result are the same. But I still think cpumask_first() is better since its name sounds deterministic while we need a deterministic value for pool->node.

Thanks,
Lai

maintainer
#3 lore raw
Quoted 9 lines · Lai Jiangshan
Quoted 5 lines · Tejun Heo

kernel/workqueue.c static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs) · line 3485

Quoted 1 line · Lai Jiangshan
kernel/workqueue.c +1 -0
+		node = cpu_to_node(cpumask_first(pool->attrs->cpumask));

Minor but maybe cpumask_any() is a better fit here?

It is OK, the result are the same. But I still think cpumask_first() is better since its name sounds deterministic while we need a deterministic value for pool->node.

The CPU can be any CPU in the mask. That's the whole point of cpumask_any(). Please use it.

Signature · 1 line
tejun