All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] workqueue: Allocate the unbound pool using local node memory
       [not found] <065801d10279$2b3fe0c0$81bfa240$@alibaba-inc.com>
@ 2015-10-09 10:05 ` Hillf Danton
  2015-10-10  1:02   ` pang.xunlei
  0 siblings, 1 reply; 4+ messages in thread
From: Hillf Danton @ 2015-10-09 10:05 UTC (permalink / raw)
  To: 'Xunlei Pang'; +Cc: linux-kernel, Tejun Heo

> From: Xunlei Pang <pang.xunlei@linaro.org>
> 
> Currently, get_unbound_pool() uses kzalloc() to allocate the
> worker pool. Actually, we can use the right node to do the
> allocation, achieving local memory access.
> 
> This patch selects target node first, and uses kzalloc_node()
> instead.
> 
> Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
> ---
>  kernel/workqueue.c | 26 ++++++++++++++------------
>  1 file changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index ca71582..96d3747 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -3199,6 +3199,7 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
>  	u32 hash = wqattrs_hash(attrs);
>  	struct worker_pool *pool;
>  	int node;
> +	int target_node = NUMA_NO_NODE;
> 
>  	lockdep_assert_held(&wq_pool_mutex);
> 
> @@ -3210,13 +3211,25 @@ 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(attrs->cpumask,
> +					   wq_numa_possible_cpumask[node])) {
> +				target_node = node;
> +				break;
> +			}
> +		}
> +	}
> +
>  	/* nope, create a new one */
> -	pool = kzalloc(sizeof(*pool), GFP_KERNEL);
> +	pool = kzalloc_node(sizeof(*pool), GFP_KERNEL, target_node);

What if target_node is short of pages at the moment?

>  	if (!pool || init_worker_pool(pool) < 0)
>  		goto fail;
> 
>  	lockdep_set_subclass(&pool->lock, 1);	/* see put_pwq() */
>  	copy_workqueue_attrs(pool->attrs, attrs);
> +	pool->node = target_node;
> 
>  	/*
>  	 * no_numa isn't a worker_pool attribute, always clear it.  See
> @@ -3224,17 +3237,6 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
>  	 */
>  	pool->attrs->no_numa = false;
> 
> -	/* 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;
> -			}
> -		}
> -	}
> -
>  	if (worker_pool_assign_id(pool) < 0)
>  		goto fail;
> 
> --
> 1.9.1


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

* Re: [PATCH] workqueue: Allocate the unbound pool using local node memory
  2015-10-09 10:05 ` [PATCH] workqueue: Allocate the unbound pool using local node memory Hillf Danton
@ 2015-10-10  1:02   ` pang.xunlei
  0 siblings, 0 replies; 4+ messages in thread
From: pang.xunlei @ 2015-10-10  1:02 UTC (permalink / raw)
  To: Hillf Danton; +Cc: linux-kernel, 'Xunlei Pang', Tejun Heo

Hello,

"Hillf Danton" <hillf.zj@alibaba-inc.com> wrote 2015-10-09 PM 06:05:20:
> 
> Re: [PATCH] workqueue: Allocate the unbound pool using local node memory
> 
> > From: Xunlei Pang <pang.xunlei@linaro.org>
> > 
> > Currently, get_unbound_pool() uses kzalloc() to allocate the
> > worker pool. Actually, we can use the right node to do the
> > allocation, achieving local memory access.
> > 
> > This patch selects target node first, and uses kzalloc_node()
> > instead.
> > 
> > Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
> > ---
> >  kernel/workqueue.c | 26 ++++++++++++++------------
> >  1 file changed, 14 insertions(+), 12 deletions(-)
> > 
> > diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> > index ca71582..96d3747 100644
> > --- a/kernel/workqueue.c
> > +++ b/kernel/workqueue.c
> > @@ -3199,6 +3199,7 @@ static struct worker_pool *get_unbound_pool
> (const struct workqueue_attrs *attrs)
> >     u32 hash = wqattrs_hash(attrs);
> >     struct worker_pool *pool;
> >     int node;
> > +   int target_node = NUMA_NO_NODE;
> > 
> >     lockdep_assert_held(&wq_pool_mutex);
> > 
> > @@ -3210,13 +3211,25 @@ 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(attrs->cpumask,
> > +                  wq_numa_possible_cpumask[node])) {
> > +            target_node = node;
> > +            break;
> > +         }
> > +      }
> > +   }
> > +
> >     /* nope, create a new one */
> > -   pool = kzalloc(sizeof(*pool), GFP_KERNEL);
> > +   pool = kzalloc_node(sizeof(*pool), GFP_KERNEL, target_node);
> 
> What if target_node is short of pages at the moment?

IIRC, the zonelist to be used contains all nodes' zones in order 
(otherwise __GFP_THISNODE is set)with target_node's zones having 
the highest priority, so it should automatically fall back to 
other nodes if target_node is short of pages.

Regards,
-Xunlei

> 
> >     if (!pool || init_worker_pool(pool) < 0)
> >        goto fail;
> > 
> >     lockdep_set_subclass(&pool->lock, 1);   /* see put_pwq() */
> >     copy_workqueue_attrs(pool->attrs, attrs);
> > +   pool->node = target_node;
> > 
> >     /*
> >      * no_numa isn't a worker_pool attribute, always clear it.  See
> > @@ -3224,17 +3237,6 @@ static struct worker_pool *get_unbound_pool
> (const struct workqueue_attrs *attrs)
> >      */
> >     pool->attrs->no_numa = false;
> > 
> > -   /* 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;
> > -         }
> > -      }
> > -   }
> > -
> >     if (worker_pool_assign_id(pool) < 0)
> >        goto fail;
> > 
> > --
> > 1.9.1
> 

--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail (and any attachment transmitted herewith) is privileged and confidential and is intended for the exclusive use of the addressee(s).  If you are not an intended recipient, any disclosure, reproduction, distribution or other dissemination or use of the information contained is strictly prohibited.  If you have received this mail in error, please delete it and notify us immediately.

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

* Re: [PATCH] workqueue: Allocate the unbound pool using local node memory
  2015-10-09  3:53 Xunlei Pang
@ 2015-10-12 16:20 ` Tejun Heo
  0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2015-10-12 16:20 UTC (permalink / raw)
  To: Xunlei Pang; +Cc: linux-kernel, Lai Jiangshan, Xunlei Pang

On Fri, Oct 09, 2015 at 11:53:12AM +0800, Xunlei Pang wrote:
> From: Xunlei Pang <pang.xunlei@linaro.org>
> 
> Currently, get_unbound_pool() uses kzalloc() to allocate the
> worker pool. Actually, we can use the right node to do the
> allocation, achieving local memory access.
> 
> This patch selects target node first, and uses kzalloc_node()
> instead.
> 
> Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>

Applied to wq/for-4.4.

Thanks.

-- 
tejun

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

* [PATCH] workqueue: Allocate the unbound pool using local node memory
@ 2015-10-09  3:53 Xunlei Pang
  2015-10-12 16:20 ` Tejun Heo
  0 siblings, 1 reply; 4+ messages in thread
From: Xunlei Pang @ 2015-10-09  3:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: Tejun Heo, Lai Jiangshan, Xunlei Pang

From: Xunlei Pang <pang.xunlei@linaro.org>

Currently, get_unbound_pool() uses kzalloc() to allocate the
worker pool. Actually, we can use the right node to do the
allocation, achieving local memory access.

This patch selects target node first, and uses kzalloc_node()
instead.

Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 kernel/workqueue.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ca71582..96d3747 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3199,6 +3199,7 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
 	u32 hash = wqattrs_hash(attrs);
 	struct worker_pool *pool;
 	int node;
+	int target_node = NUMA_NO_NODE;
 
 	lockdep_assert_held(&wq_pool_mutex);
 
@@ -3210,13 +3211,25 @@ 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(attrs->cpumask,
+					   wq_numa_possible_cpumask[node])) {
+				target_node = node;
+				break;
+			}
+		}
+	}
+
 	/* nope, create a new one */
-	pool = kzalloc(sizeof(*pool), GFP_KERNEL);
+	pool = kzalloc_node(sizeof(*pool), GFP_KERNEL, target_node);
 	if (!pool || init_worker_pool(pool) < 0)
 		goto fail;
 
 	lockdep_set_subclass(&pool->lock, 1);	/* see put_pwq() */
 	copy_workqueue_attrs(pool->attrs, attrs);
+	pool->node = target_node;
 
 	/*
 	 * no_numa isn't a worker_pool attribute, always clear it.  See
@@ -3224,17 +3237,6 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
 	 */
 	pool->attrs->no_numa = false;
 
-	/* 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;
-			}
-		}
-	}
-
 	if (worker_pool_assign_id(pool) < 0)
 		goto fail;
 
-- 
1.9.1



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

end of thread, other threads:[~2015-10-12 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <065801d10279$2b3fe0c0$81bfa240$@alibaba-inc.com>
2015-10-09 10:05 ` [PATCH] workqueue: Allocate the unbound pool using local node memory Hillf Danton
2015-10-10  1:02   ` pang.xunlei
2015-10-09  3:53 Xunlei Pang
2015-10-12 16:20 ` 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.