From: Michal Hocko <mhocko@kernel.org>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Tom Herbert <tom@herbertland.com>,
linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>,
edumazet@google.com
Subject: Re: weird allocation pattern in alloc_ila_locks
Date: Sat, 7 Jan 2017 10:27:48 +0100 [thread overview]
Message-ID: <20170107092746.GC5047@dhcp22.suse.cz> (raw)
In-Reply-To: <1483740889.9712.44.camel@edumazet-glaptop3.roam.corp.google.com>
On Fri 06-01-17 14:14:49, Eric Dumazet wrote:
> On Fri, 2017-01-06 at 13:16 +0100, Michal Hocko wrote:
> > I was thinking about the rhashtable which was the source of the c&p and
> > it can be simplified as well.
> > ---
> > From 555543604f5f020284ea85d928d52f6a55fde7ca Mon Sep 17 00:00:00 2001
> > From: Michal Hocko <mhocko@suse.com>
> > Date: Fri, 6 Jan 2017 13:12:31 +0100
> > Subject: [PATCH] rhashtable: simplify a strange allocation pattern
> >
> > alloc_bucket_locks allocation pattern is quite unusual. We are
> > preferring vmalloc when CONFIG_NUMA is enabled which doesn't make much
> > sense because there is no special NUMA locality handled in that code
> > path. Let's just simplify the code and use kvmalloc helper, which is a
> > transparent way to use kmalloc with vmalloc fallback, if the caller
> > is allowed to block and use the flag otherwise.
> >
> > Signed-off-by: Michal Hocko <mhocko@suse.com>
> > ---
> > lib/rhashtable.c | 13 +++----------
> > 1 file changed, 3 insertions(+), 10 deletions(-)
> >
> > diff --git a/lib/rhashtable.c b/lib/rhashtable.c
> > index 32d0ad058380..4d3886b6ab7d 100644
> > --- a/lib/rhashtable.c
> > +++ b/lib/rhashtable.c
> > @@ -77,16 +77,9 @@ static int alloc_bucket_locks(struct rhashtable *ht, struct bucket_table *tbl,
> > size = min_t(unsigned int, size, tbl->size >> 1);
> >
> > if (sizeof(spinlock_t) != 0) {
> > - tbl->locks = NULL;
> > -#ifdef CONFIG_NUMA
> > - if (size * sizeof(spinlock_t) > PAGE_SIZE &&
> > - gfp == GFP_KERNEL)
> > - tbl->locks = vmalloc(size * sizeof(spinlock_t));
> > -#endif
> > - if (gfp != GFP_KERNEL)
> > - gfp |= __GFP_NOWARN | __GFP_NORETRY;
> > -
> > - if (!tbl->locks)
> > + if (gfpflags_allow_blocking(gfp_))
> > + tbl->locks = kvmalloc(size * sizeof(spinlock_t), gfp);
> > + else
> > tbl->locks = kmalloc_array(size, sizeof(spinlock_t),
>
>
> I believe the intent was to get NUMA spreading, a bit like what we have
> in alloc_large_system_hash() when hashdist == HASHDIST_DEFAULT
Hmm, I am not sure this works as expected then. Because it is more
likely that all pages backing the vmallocked area will come from the
local node than spread around more nodes. Or did I miss your point?
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2017-01-07 9:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-06 9:51 weird allocation pattern in alloc_ila_locks Michal Hocko
2017-01-06 10:04 ` Michal Hocko
2017-01-06 12:16 ` Michal Hocko
2017-01-06 22:14 ` Eric Dumazet
2017-01-07 9:27 ` Michal Hocko [this message]
2017-01-07 18:37 ` Eric Dumazet
2017-01-09 9:58 ` Michal Hocko
2017-01-09 14:31 ` Eric Dumazet
2017-01-09 14:41 ` Michal Hocko
2017-01-09 14:43 ` [PATCH 1/2] rhashtable: simplify a strange allocation pattern Michal Hocko
2017-01-09 14:43 ` [PATCH 2/2] ila: " Michal Hocko
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=20170107092746.GC5047@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=tom@herbertland.com \
/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;
as well as URLs for NNTP newsgroup(s).