Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1569762

Re: [PATCH 3/9] rhashtable: simplify a strange allocation pattern

Path csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod
From Vlastimil Babka <vbabka@suse.cz>
Newsgroups linux.kernel
Subject Re: [PATCH 3/9] rhashtable: simplify a strange allocation pattern
Date Mon, 30 Jan 2017 15:10:02 +0100
Message-ID <t5kOC-4Wr-17@gated-at.bofh.it> (permalink)
References <t5gUF-2oF-3@gated-at.bofh.it> <t5gUG-2oF-15@gated-at.bofh.it>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0
MIME-Version 1.0
Content-Type text/plain; charset=iso-8859-2; format=flowed
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 50
Organization linux.* mail to news gateway
X-Original-Cc David Rientjes <rientjes@google.com>, Mel Gorman <mgorman@suse.de>, Johannes Weiner <hannes@cmpxchg.org>, Al Viro <viro@zeniv.linux.org.uk>, linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>, Michal Hocko <mhocko@suse.com>, Tom Herbert <tom@herbertland.com>, Eric Dumazet <eric.dumazet@gmail.com>
X-Original-Date Mon, 30 Jan 2017 15:04:43 +0100
X-Original-Message-ID <42a48532-23f5-f965-1e14-aa4b292b13cd@suse.cz>
X-Original-References <20170130094940.13546-1-mhocko@kernel.org> <20170130094940.13546-4-mhocko@kernel.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1569762

Show key headers only | View raw


On 01/30/2017 10:49 AM, Michal Hocko wrote:
> From: Michal Hocko <mhocko@suse.com>
>
> alloc_bucket_locks allocation pattern is quite unusual. We are
> preferring vmalloc when CONFIG_NUMA is enabled. The rationale is that
> vmalloc will respect the memory policy of the current process and so the
> backing memory will get distributed over multiple nodes if the requester
> is configured properly. At least that is the intention, in reality
> rhastable is shrunk and expanded from a kernel worker so no mempolicy
> can be assumed.
>
> 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.
>
> Cc: Tom Herbert <tom@herbertland.com>
> Cc: Eric Dumazet <eric.dumazet@gmail.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> 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..1a487ea70829 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),
>  						   gfp);
>  		if (!tbl->locks)
>

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 3/9] rhashtable: simplify a strange allocation pattern Michal Hocko <mhocko@kernel.org> - 2017-01-30 11:00 +0100
  Re: [PATCH 3/9] rhashtable: simplify a strange allocation pattern Vlastimil Babka <vbabka@suse.cz> - 2017-01-30 15:10 +0100

csiph-web