All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] workqueue: get the probable node ID from the first CPU of the mask
@ 2014-07-22  5:04 Lai Jiangshan
  2014-07-22 15:30 ` Tejun Heo
  0 siblings, 1 reply; 4+ messages in thread
From: Lai Jiangshan @ 2014-07-22  5:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: Tejun Heo, Lai Jiangshan

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.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 kernel/workqueue.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 347ac5b..942103d9 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -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;
 		}
 	}
 
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] workqueue: get the probable node ID from the first CPU of the mask
  2014-07-22  5:04 [PATCH] workqueue: get the probable node ID from the first CPU of the mask Lai Jiangshan
@ 2014-07-22 15:30 ` Tejun Heo
  2014-07-23  1:26   ` Lai Jiangshan
  0 siblings, 1 reply; 4+ messages in thread
From: Tejun Heo @ 2014-07-22 15:30 UTC (permalink / raw)
  To: Lai Jiangshan; +Cc: linux-kernel

On Tue, Jul 22, 2014 at 01:04:02PM +0800, Lai Jiangshan wrote:
> +		node = cpu_to_node(cpumask_first(pool->attrs->cpumask));

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

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] workqueue: get the probable node ID from the first CPU of the mask
  2014-07-22 15:30 ` Tejun Heo
@ 2014-07-23  1:26   ` Lai Jiangshan
  2014-07-23 15:10     ` Tejun Heo
  0 siblings, 1 reply; 4+ messages in thread
From: Lai Jiangshan @ 2014-07-23  1:26 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-kernel

On 07/22/2014 11:30 PM, Tejun Heo wrote:
> On Tue, Jul 22, 2014 at 01:04:02PM +0800, Lai Jiangshan wrote:
>> +		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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] workqueue: get the probable node ID from the first CPU of the mask
  2014-07-23  1:26   ` Lai Jiangshan
@ 2014-07-23 15:10     ` Tejun Heo
  0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2014-07-23 15:10 UTC (permalink / raw)
  To: Lai Jiangshan; +Cc: linux-kernel

On Wed, Jul 23, 2014 at 09:26:30AM +0800, Lai Jiangshan wrote:
> On 07/22/2014 11:30 PM, Tejun Heo wrote:
> > On Tue, Jul 22, 2014 at 01:04:02PM +0800, Lai Jiangshan wrote:
> >> +		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.

-- 
tejun

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-23 15:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-22  5:04 [PATCH] workqueue: get the probable node ID from the first CPU of the mask Lai Jiangshan
2014-07-22 15:30 ` Tejun Heo
2014-07-23  1:26   ` Lai Jiangshan
2014-07-23 15:10     ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.