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


Groups > linux.kernel > #1390400

Re: [PATCH] md: simplify free_params for kmalloc vs vmalloc fallback

From Michal Hocko <mhocko@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH] md: simplify free_params for kmalloc vs vmalloc fallback
Date 2016-04-28 19:00 +0200
Message-ID <rsXsf-74R-13@gated-at.bofh.it> (permalink)
References <rsUb0-3LP-21@gated-at.bofh.it> <rsVA6-50h-13@gated-at.bofh.it> <rsVJM-5u4-33@gated-at.bofh.it> <rsW37-5Ij-1@gated-at.bofh.it> <rsWmv-5UH-31@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu 28-04-16 11:40:59, Mikulas Patocka wrote:
[...]
> There are many users that use one of these patterns:
> 
> 	if (size <= some_threshold)
> 		p = kmalloc(size);
> 	else
> 		p = vmalloc(size);
> 
> or
> 
> 	p = kmalloc(size);
> 	if (!p)
> 		p = vmalloc(size);
> 
> 
> For example: alloc_fdmem, seq_buf_alloc, setxattr, getxattr, ipc_alloc, 
> pidlist_allocate, get_pages_array, alloc_bucket_locks, 
> frame_vector_create. If you grep the kernel for vmalloc, you'll find this 
> pattern over and over again.

It is certainly good to address a common pattern by a helper if it makes
to code easier to follo IMHO.

> 
> In alloc_large_system_hash, there is
> 	table = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL);
> - that is clearly wrong because __vmalloc doesn't respect GFP_ATOMIC

I have seen this code some time already. I guess it was Al complaining
about it but then I just forgot about it. I have no idea why GFP_ATOMIC
was used there. This predates git times but it should be
https://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.10/2.6.10-mm1/broken-out/alloc_large_system_hash-numa-interleaving.patch
The changelog is quite verbose but no mention about this ugliness.

So I do agree that the above should be fixed and a common helper might
be interesting but I am afraid we are getting off topic here.

Thanks!
-- 
Michal Hocko
SUSE Labs

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


Thread

[PATCH 19/20] md: simplify free_params for kmalloc vs vmalloc fallback Michal Hocko <mhocko@kernel.org> - 2016-04-28 15:30 +0200
  [PATCH] md: simplify free_params for kmalloc vs vmalloc fallback Michal Hocko <mhocko@kernel.org> - 2016-04-28 17:00 +0200
    Re: [PATCH] md: simplify free_params for kmalloc vs vmalloc  fallback Mikulas Patocka <mpatocka@redhat.com> - 2016-04-28 17:10 +0200
      Re: [PATCH] md: simplify free_params for kmalloc vs vmalloc fallback Michal Hocko <mhocko@kernel.org> - 2016-04-28 17:30 +0200
        Re: [PATCH] md: simplify free_params for kmalloc vs vmalloc  fallback Mikulas Patocka <mpatocka@redhat.com> - 2016-04-28 17:50 +0200
          Re: [PATCH] md: simplify free_params for kmalloc vs vmalloc fallback Michal Hocko <mhocko@kernel.org> - 2016-04-28 19:00 +0200
  Re: [PATCH 19/20] md: simplify free_params for kmalloc vs vmalloc  fallback Mike Snitzer <snitzer@redhat.com> - 2016-04-28 17:40 +0200
    Re: [PATCH 19/20] md: simplify free_params for kmalloc vs vmalloc  fallback Michal Hocko <mhocko@kernel.org> - 2016-04-28 18:10 +0200

csiph-web