From: "J. Bruce Fields" <bfields@fieldses.org>
To: Jeff Layton <jlayton@redhat.com>
Cc: Greg Banks
<gnb-cP1dWloDopni96+mSzHFpQC/G2K4zDHf@public.gmane.org>,
linux-nfs@vger.kernel.org, nfsv4@linux-nfs.org
Subject: Re: [PATCH 0/3] [RFC] knfsd: convert to kthread API and remove signaling for shutdown
Date: Fri, 30 May 2008 14:46:53 -0400 [thread overview]
Message-ID: <20080530184653.GB18154@fieldses.org> (raw)
In-Reply-To: <20080530122517.4f18c48e-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
On Fri, May 30, 2008 at 12:25:17PM -0400, Jeff Layton wrote:
> On Tue, 20 May 2008 20:29:52 -0700
> Greg Banks <gnb-cP1dWloDopni96+mSzHFpQC/G2K4zDHf@public.gmane.org> wrote:
>
> > Jeff Layton wrote:
> > >
> > > [...] Rather than delaying the allocation like this,
> > > I wonder if we can just figure out the node from the cpumask and then
> > > do a kmalloc_node()?
> > >
> > >
> > Sure.
> >
>
> I started to do this patch as part of the kthread conversion, but it's
> actually pretty independent. We can probably treat it separately.
> This hasn't been tested on an actual NUMA machine yet, but any thoughts
> on the following patch?
>
> -----------------[snip]-------------------
>
> >From 46432a021fe1931f4a44587124ac9442e83c4731 Mon Sep 17 00:00:00 2001
> From: Jeff Layton <jlayton@redhat.com>
> Date: Fri, 30 May 2008 11:57:18 -0400
> Subject: [PATCH] sunrpc: have pooled services make NUMA-friendly allocations
>
> Currently, svc_prepare_thread allocates memory using plain kmalloc()
> and alloc_page() calls, even for threads that are destined to run on
> different CPUs or NUMA nodes than the current one. Add a function to
> translate a poolid into a NUMA node, and have svc_prepare_thread and
> svc_init_buffer allocate memory on those nodes instead.
>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
> net/sunrpc/svc.c | 46 ++++++++++++++++++++++++++++++++++++++++------
> 1 files changed, 40 insertions(+), 6 deletions(-)
>
> diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
> index 01c7e31..3985fbc 100644
> --- a/net/sunrpc/svc.c
> +++ b/net/sunrpc/svc.c
> @@ -332,6 +332,32 @@ svc_pool_map_set_cpumask(unsigned int pidx, cpumask_t *oldmask)
> }
>
> /*
> + * for a given poolid, return the NUMA memory node. This allows us to
> + * allocate memory close to the CPU's where the task will be running
> + */
> +static inline unsigned int
> +svc_pool_to_node(unsigned int pidx)
> +{
> + struct svc_pool_map *m = &svc_pool_map;
> + unsigned int poolnode = m->pool_to[pidx];
> +
> + /*
> + * The caller checks for sv_nrpools > 1, which
> + * implies that we've been initialized.
> + */
> + BUG_ON(m->count == 0);
> +
> + switch (m->mode) {
> + case SVC_POOL_PERNODE:
> + return poolnode;
> + case SVC_POOL_PERCPU:
> + return cpu_to_node(poolnode);
> + }
> +
> + return numa_node_id();
> +}
> +
> +/*
> * Use the mapping mode to choose a pool for a given CPU.
> * Used when enqueueing an incoming RPC. Always returns
> * a non-NULL pool pointer.
> @@ -507,7 +533,7 @@ EXPORT_SYMBOL(svc_destroy);
> * We allocate pages and place them in rq_argpages.
> */
> static int
> -svc_init_buffer(struct svc_rqst *rqstp, unsigned int size)
> +svc_init_buffer(struct svc_rqst *rqstp, unsigned int size, unsigned int node)
> {
> unsigned int pages, arghi;
>
> @@ -517,7 +543,7 @@ svc_init_buffer(struct svc_rqst *rqstp, unsigned int size)
> arghi = 0;
> BUG_ON(pages > RPCSVC_MAXPAGES);
> while (pages) {
> - struct page *p = alloc_page(GFP_KERNEL);
> + struct page *p = alloc_pages_node(node, GFP_KERNEL, 0);
> if (!p)
> break;
> rqstp->rq_pages[arghi++] = p;
> @@ -543,8 +569,14 @@ struct svc_rqst *
> svc_prepare_thread(struct svc_serv *serv, struct svc_pool *pool)
> {
> struct svc_rqst *rqstp;
> + unsigned int node;
> +
> + if (serv->sv_nrpools > 1)
> + node = svc_pool_to_node(pool->sp_id);
> + else
> + node = numa_node_id();
>
> - rqstp = kzalloc(sizeof(*rqstp), GFP_KERNEL);
> + rqstp = kmalloc_node(sizeof(*rqstp), GFP_KERNEL | __GFP_ZERO, node);
> if (!rqstp)
> goto out_enomem;
>
> @@ -558,15 +590,17 @@ svc_prepare_thread(struct svc_serv *serv, struct svc_pool *pool)
> rqstp->rq_server = serv;
> rqstp->rq_pool = pool;
>
> - rqstp->rq_argp = kmalloc(serv->sv_xdrsize, GFP_KERNEL);
> + rqstp->rq_argp = kmalloc_node(serv->sv_xdrsize,
> + GFP_KERNEL | __GFP_ZERO, node);
> if (!rqstp->rq_argp)
> goto out_thread;
>
> - rqstp->rq_resp = kmalloc(serv->sv_xdrsize, GFP_KERNEL);
> + rqstp->rq_resp = kmalloc_node(serv->sv_xdrsize,
> + GFP_KERNEL | __GFP_ZERO, node);
Why the __GFP_ZERO's on these last two?
--b.
> if (!rqstp->rq_resp)
> goto out_thread;
>
> - if (!svc_init_buffer(rqstp, serv->sv_max_mesg))
> + if (!svc_init_buffer(rqstp, serv->sv_max_mesg, node))
> goto out_thread;
>
> return rqstp;
> --
> 1.5.3.6
>
> _______________________________________________
> NFSv4 mailing list
> NFSv4@linux-nfs.org
> http://linux-nfs.org/cgi-bin/mailman/listinfo/nfsv4
next prev parent reply other threads:[~2008-05-30 18:46 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-18 2:35 [PATCH 0/3] [RFC] knfsd: convert to kthread API and remove signaling for shutdown Jeff Layton
2008-05-18 2:35 ` [PATCH 1/3] [RFC] knfsd: convert knfsd to kthread API Jeff Layton
2008-05-18 2:35 ` [PATCH 2/3] [RFC] sunrpc: remove unneeded fields from svc_serv struct Jeff Layton
2008-05-18 2:35 ` [PATCH 3/3] [RFC] knfsd: remove signal defines and extraneous variables Jeff Layton
2008-05-19 6:07 ` [PATCH 0/3] [RFC] knfsd: convert to kthread API and remove signaling for shutdown Neil Brown
[not found] ` <18481.6416.571430.593722-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2008-05-19 21:01 ` Jeff Layton
2008-05-19 22:00 ` Greg Banks
2008-05-19 23:52 ` Neil Brown
[not found] ` <18482.4782.858347.981553-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2008-05-20 2:04 ` Greg Banks
2008-05-20 2:24 ` Jeff Layton
[not found] ` <20080519222457.6f24daa5-PC62bkCOHzGdMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2008-05-20 2:34 ` Greg Banks
2008-05-20 11:05 ` Jeff Layton
[not found] ` <483238B3.4010702-cP1dWloDopni96+mSzHFpQC/G2K4zDHf@public.gmane.org>
2008-05-20 13:33 ` Talpey, Thomas
2008-05-20 3:13 ` Neil Brown
2008-05-20 11:13 ` Jeff Layton
[not found] ` <18482.16837.381955.636390-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2008-05-20 20:26 ` Greg Banks
2008-05-20 20:36 ` Greg Banks
[not found] ` <4833364A.4010803-cP1dWloDopni96+mSzHFpQC/G2K4zDHf@public.gmane.org>
2008-05-21 1:48 ` Jeff Layton
[not found] ` <20080520214823.576ad7a7-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-05-21 3:29 ` Greg Banks
[not found] ` <48339730.3060206-cP1dWloDopni96+mSzHFpQC/G2K4zDHf@public.gmane.org>
2008-05-30 16:25 ` Jeff Layton
[not found] ` <20080530122517.4f18c48e-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-05-30 18:46 ` J. Bruce Fields [this message]
2008-05-30 20:59 ` Jeff Layton
2008-06-02 5:51 ` Greg Banks
[not found] ` <48438A76.6000400-cP1dWloDopni96+mSzHFpQC/G2K4zDHf@public.gmane.org>
2008-06-02 10:41 ` Jeff Layton
[not found] ` <20080602064132.10c69c88-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-06-03 3:27 ` Greg Banks
[not found] ` <4844BA3C.3010605-cP1dWloDopni96+mSzHFpQC/G2K4zDHf@public.gmane.org>
2008-06-03 10:51 ` Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080530184653.GB18154@fieldses.org \
--to=bfields@fieldses.org \
--cc=gnb-cP1dWloDopni96+mSzHFpQC/G2K4zDHf@public.gmane.org \
--cc=jlayton@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=nfsv4@linux-nfs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox