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


Groups > linux.kernel > #1569829

Re: [PATCH 4/9] ila: simplify a strange allocation pattern

From Vlastimil Babka <vbabka@suse.cz>
Newsgroups linux.kernel
Subject Re: [PATCH 4/9] ila: simplify a strange allocation pattern
Date 2017-01-30 16:30 +0100
Message-ID <t5m42-5BN-19@gated-at.bofh.it> (permalink)
References <t5gUF-2oF-3@gated-at.bofh.it> <t5gUG-2oF-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 01/30/2017 10:49 AM, Michal Hocko wrote:
> From: Michal Hocko <mhocko@suse.com>
>
> alloc_ila_locks seemed to c&p from alloc_bucket_locks allocation
> pattern which is quite unusual. The default allocation size is 320 *
> sizeof(spinlock_t) which is sub page unless lockdep is enabled when the
> performance benefit is really questionable and not worth the subtle code
> IMHO. Also note that the context when we call ila_init_net (modprobe or
> a task creating a net namespace) has to be properly configured.
>
> Let's just simplify the code and use kvmalloc helper which is a
> transparent way to use kmalloc with vmalloc fallback.
>
> Cc: Tom Herbert <tom@herbertland.com>
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Michal Hocko <mhocko@suse.com>

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

> ---
>  net/ipv6/ila/ila_xlat.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/net/ipv6/ila/ila_xlat.c b/net/ipv6/ila/ila_xlat.c
> index af8f52ee7180..2fd5ca151dcf 100644
> --- a/net/ipv6/ila/ila_xlat.c
> +++ b/net/ipv6/ila/ila_xlat.c
> @@ -41,13 +41,7 @@ static int alloc_ila_locks(struct ila_net *ilan)
>  	size = roundup_pow_of_two(nr_pcpus * LOCKS_PER_CPU);
>
>  	if (sizeof(spinlock_t) != 0) {
> -#ifdef CONFIG_NUMA
> -		if (size * sizeof(spinlock_t) > PAGE_SIZE)
> -			ilan->locks = vmalloc(size * sizeof(spinlock_t));
> -		else
> -#endif
> -		ilan->locks = kmalloc_array(size, sizeof(spinlock_t),
> -					    GFP_KERNEL);
> +		ilan->locks = kvmalloc(size * sizeof(spinlock_t), GFP_KERNEL);
>  		if (!ilan->locks)
>  			return -ENOMEM;
>  		for (i = 0; i < size; i++)
>

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


Thread

[PATCH 0/6 v3] kvmalloc Michal Hocko <mhocko@kernel.org> - 2017-01-30 11:00 +0100
  [PATCH 8/9] bcache: use kvmalloc Michal Hocko <mhocko@kernel.org> - 2017-01-30 11:00 +0100
    Re: [PATCH 8/9] bcache: use kvmalloc Vlastimil Babka <vbabka@suse.cz> - 2017-01-30 18:00 +0100
      Re: [PATCH 8/9] bcache: use kvmalloc Michal Hocko <mhocko@kernel.org> - 2017-01-30 18:30 +0100
  [PATCH 9/9] net, bpf: use kvzalloc helper Michal Hocko <mhocko@kernel.org> - 2017-01-30 11:00 +0100
    Re: [PATCH 9/9] net, bpf: use kvzalloc helper Michal Hocko <mhocko@kernel.org> - 2017-01-30 18:30 +0100
  [PATCH 4/9] ila: simplify a strange allocation pattern Michal Hocko <mhocko@kernel.org> - 2017-01-30 11:00 +0100
    Re: [PATCH 4/9] ila: simplify a strange allocation pattern Vlastimil Babka <vbabka@suse.cz> - 2017-01-30 16:30 +0100
  [PATCH 2/9] mm: support __GFP_REPEAT in kvmalloc_node for >32kB Michal Hocko <mhocko@kernel.org> - 2017-01-30 11:00 +0100
  [PATCH 7/9] md: use kvmalloc rather than opencoded variant Michal Hocko <mhocko@kernel.org> - 2017-01-30 11:00 +0100
    Re: [PATCH 7/9] md: use kvmalloc rather than opencoded variant Vlastimil Babka <vbabka@suse.cz> - 2017-01-30 18:00 +0100
    Re: [PATCH 7/9] md: use kvmalloc rather than opencoded variant Mikulas Patocka <mpatocka@redhat.com> - 2017-02-01 18:40 +0100
      Re: [PATCH 7/9] md: use kvmalloc rather than opencoded variant Michal Hocko <mhocko@kernel.org> - 2017-02-01 19:00 +0100
  Re: [PATCH 5/9] treewide: use kv[mz]alloc* rather than opencoded  variants Leon Romanovsky <leon@kernel.org> - 2017-01-30 11:40 +0100
  Re: [PATCH 5/9] treewide: use kv[mz]alloc* rather than opencoded  variants Vlastimil Babka <vbabka@suse.cz> - 2017-01-30 17:40 +0100
  Re: [PATCH 5/9] treewide: use kv[mz]alloc* rather than opencoded variants Kees Cook <keescook@chromium.org> - 2017-01-30 20:30 +0100
  Re: [PATCH 0/6 v3] kvmalloc Michal Hocko <mhocko@kernel.org> - 2017-02-05 11:30 +0100

csiph-web