From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Christoph Hellwig <hch@lst.de>, Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
Wei Liu <wei.liu@kernel.org>,
x86@kernel.org, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
Laura Abbott <labbott@redhat.com>,
Sumit Semwal <sumit.semwal@linaro.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Minchan Kim <minchan@kernel.org>,
Nitin Gupta <ngupta@vflare.org>,
Robin Murphy <robin.murphy@arm.com>,
Christophe Leroy <christophe.leroy@c-s.fr>,
Peter Zijlstra <peterz@infradead.org>,
linuxppc-dev@lists.ozlabs.org, linux-hyperv@vger.kernel.org,
dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
linux-arch@vger.kernel.org, linux-mm@kvack.org,
iommu@lists.linux-foundation.org,
linux-arm-kernel@lists.infradead.org,
linux-s390@vger.kernel.org, bpf <bpf@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 25/28] mm: remove vmalloc_user_node_flags
Date: Thu, 9 Apr 2020 15:25:03 -0700 [thread overview]
Message-ID: <CAEf4BzZOC2tLrqt_Km=WQb=9xiya2e31i6K3oJuzgYQt6wp1LQ@mail.gmail.com> (raw)
In-Reply-To: <20200408115926.1467567-26-hch@lst.de>
cc Johannes who suggested this API call originally
On Wed, Apr 8, 2020 at 5:03 AM Christoph Hellwig <hch@lst.de> wrote:
>
> Open code it in __bpf_map_area_alloc, which is the only caller. Also
> clean up __bpf_map_area_alloc to have a single vmalloc call with
> slightly different flags instead of the current two different calls.
>
> For this to compile for the nommu case add a __vmalloc_node_range stub
> to nommu.c.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> include/linux/vmalloc.h | 1 -
> kernel/bpf/syscall.c | 23 +++++++++++++----------
> mm/nommu.c | 14 ++++++++------
> mm/vmalloc.c | 20 --------------------
> 4 files changed, 21 insertions(+), 37 deletions(-)
>
> diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
> index 108f49b47756..f90f2946aac2 100644
> --- a/include/linux/vmalloc.h
> +++ b/include/linux/vmalloc.h
> @@ -106,7 +106,6 @@ extern void *vzalloc(unsigned long size);
> extern void *vmalloc_user(unsigned long size);
> extern void *vmalloc_node(unsigned long size, int node);
> extern void *vzalloc_node(unsigned long size, int node);
> -extern void *vmalloc_user_node_flags(unsigned long size, int node, gfp_t flags);
> extern void *vmalloc_exec(unsigned long size);
> extern void *vmalloc_32(unsigned long size);
> extern void *vmalloc_32_user(unsigned long size);
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 48d98ea8fad6..249d9bd43321 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -281,26 +281,29 @@ static void *__bpf_map_area_alloc(u64 size, int numa_node, bool mmapable)
> * __GFP_RETRY_MAYFAIL to avoid such situations.
> */
>
> - const gfp_t flags = __GFP_NOWARN | __GFP_ZERO;
> + const gfp_t gfp = __GFP_NOWARN | __GFP_ZERO;
> + unsigned int flags = 0;
> + unsigned long align = 1;
> void *area;
>
> if (size >= SIZE_MAX)
> return NULL;
>
> /* kmalloc()'ed memory can't be mmap()'ed */
> - if (!mmapable && size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) {
> - area = kmalloc_node(size, GFP_USER | __GFP_NORETRY | flags,
> + if (mmapable) {
> + BUG_ON(!PAGE_ALIGNED(size));
> + align = SHMLBA;
> + flags = VM_USERMAP;
> + } else if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) {
> + area = kmalloc_node(size, gfp | GFP_USER | __GFP_NORETRY,
> numa_node);
> if (area != NULL)
> return area;
> }
> - if (mmapable) {
> - BUG_ON(!PAGE_ALIGNED(size));
> - return vmalloc_user_node_flags(size, numa_node, GFP_KERNEL |
> - __GFP_RETRY_MAYFAIL | flags);
> - }
> - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_RETRY_MAYFAIL | flags,
> - numa_node, __builtin_return_address(0));
> +
> + return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END,
> + gfp | GFP_KERNEL | __GFP_RETRY_MAYFAIL, PAGE_KERNEL,
> + flags, numa_node, __builtin_return_address(0));
> }
>
> void *bpf_map_area_alloc(u64 size, int numa_node)
> diff --git a/mm/nommu.c b/mm/nommu.c
> index 81a86cd85893..b42cd6003d7d 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -150,6 +150,14 @@ void *__vmalloc(unsigned long size, gfp_t gfp_mask)
> }
> EXPORT_SYMBOL(__vmalloc);
>
> +void *__vmalloc_node_range(unsigned long size, unsigned long align,
> + unsigned long start, unsigned long end, gfp_t gfp_mask,
> + pgprot_t prot, unsigned long vm_flags, int node,
> + const void *caller)
> +{
> + return __vmalloc(size, flags);
> +}
> +
> void *__vmalloc_node(unsigned long size, unsigned long align, gfp_t gfp_mask,
> int node, const void *caller)
> {
> @@ -180,12 +188,6 @@ void *vmalloc_user(unsigned long size)
> }
> EXPORT_SYMBOL(vmalloc_user);
>
> -void *vmalloc_user_node_flags(unsigned long size, int node, gfp_t flags)
> -{
> - return __vmalloc_user_flags(size, flags | __GFP_ZERO);
> -}
> -EXPORT_SYMBOL(vmalloc_user_node_flags);
> -
> struct page *vmalloc_to_page(const void *addr)
> {
> return virt_to_page(addr);
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 333fbe77255a..f6f2acdaf70c 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2658,26 +2658,6 @@ void *vzalloc_node(unsigned long size, int node)
> }
> EXPORT_SYMBOL(vzalloc_node);
>
> -/**
> - * vmalloc_user_node_flags - allocate memory for userspace on a specific node
> - * @size: allocation size
> - * @node: numa node
> - * @flags: flags for the page level allocator
> - *
> - * The resulting memory area is zeroed so it can be mapped to userspace
> - * without leaking data.
> - *
> - * Return: pointer to the allocated memory or %NULL on error
> - */
> -void *vmalloc_user_node_flags(unsigned long size, int node, gfp_t flags)
> -{
> - return __vmalloc_node_range(size, SHMLBA, VMALLOC_START, VMALLOC_END,
> - flags | __GFP_ZERO, PAGE_KERNEL,
> - VM_USERMAP, node,
> - __builtin_return_address(0));
> -}
> -EXPORT_SYMBOL(vmalloc_user_node_flags);
> -
> /**
> * vmalloc_exec - allocate virtually contiguous, executable memory
> * @size: allocation size
> --
> 2.25.1
>
next prev parent reply other threads:[~2020-04-09 22:25 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-08 11:58 decruft the vmalloc API Christoph Hellwig
2020-04-08 11:58 ` [PATCH 01/28] x86/hyperv: use vmalloc_exec for the hypercall page Christoph Hellwig
2020-04-09 15:52 ` Wei Liu
2020-04-10 20:40 ` Michael Kelley
2020-04-08 11:59 ` [PATCH 02/28] staging: android: ion: use vmap instead of vm_map_ram Christoph Hellwig
2020-04-08 13:27 ` Greg KH
2020-04-08 11:59 ` [PATCH 03/28] staging: media: ipu3: use vmap insted of reimplementing it Christoph Hellwig
2020-04-08 11:59 ` [PATCH 04/28] dma-mapping: " Christoph Hellwig
2020-04-08 11:59 ` [PATCH 05/28] powerpc: add an ioremap_phb helper Christoph Hellwig
2020-04-08 11:59 ` [PATCH 06/28] powerpc: remove __ioremap_at and __iounmap_at Christoph Hellwig
2020-04-08 11:59 ` [PATCH 07/28] mm: remove __get_vm_area Christoph Hellwig
2020-04-08 11:59 ` [PATCH 08/28] mm: unexport unmap_kernel_range_noflush Christoph Hellwig
2020-04-08 11:59 ` [PATCH 09/28] mm: rename CONFIG_PGTABLE_MAPPING to CONFIG_ZSMALLOC_PGTABLE_MAPPING Christoph Hellwig
2020-04-08 15:00 ` Randy Dunlap
2020-04-09 15:59 ` Minchan Kim
2020-04-08 11:59 ` [PATCH 10/28] mm: only allow page table mappings for built-in zsmalloc Christoph Hellwig
2020-04-08 15:01 ` Randy Dunlap
2020-04-08 15:12 ` Peter Zijlstra
2020-04-08 15:15 ` Matthew Wilcox
2020-04-08 15:36 ` Christoph Hellwig
2020-04-08 15:37 ` Randy Dunlap
2020-04-08 15:36 ` Randy Dunlap
2020-04-09 16:08 ` Minchan Kim
2020-04-09 16:50 ` Peter Zijlstra
2020-04-09 17:08 ` Minchan Kim
2020-04-10 2:38 ` Sergey Senozhatsky
2020-04-10 23:11 ` Minchan Kim
2020-04-11 7:20 ` Christoph Hellwig
2020-04-16 20:37 ` Minchan Kim
2020-04-08 11:59 ` [PATCH 11/28] mm: pass addr as unsigned long to vb_free Christoph Hellwig
2020-04-08 11:59 ` [PATCH 12/28] mm: remove vmap_page_range_noflush and vunmap_page_range Christoph Hellwig
2020-04-08 11:59 ` [PATCH 13/28] mm: rename vmap_page_range to map_kernel_range Christoph Hellwig
2020-04-08 11:59 ` [PATCH 14/28] mm: don't return the number of pages from map_kernel_range{,_noflush} Christoph Hellwig
2020-04-08 11:59 ` [PATCH 15/28] mm: remove map_vm_range Christoph Hellwig
2020-04-08 11:59 ` [PATCH 16/28] mm: remove unmap_vmap_area Christoph Hellwig
2020-04-08 11:59 ` [PATCH 17/28] mm: remove the prot argument from vm_map_ram Christoph Hellwig
2020-04-08 12:21 ` Peter Zijlstra
2020-04-08 12:23 ` Christoph Hellwig
2020-04-09 0:39 ` Gao Xiang
2020-04-08 11:59 ` [PATCH 18/28] mm: enforce that vmap can't map pages executable Christoph Hellwig
2020-04-08 12:38 ` Mark Rutland
2020-04-08 15:32 ` Christoph Hellwig
2020-04-08 11:59 ` [PATCH 19/28] gpu/drm: remove the powerpc hack in drm_legacy_sg_alloc Christoph Hellwig
2020-04-08 12:25 ` Daniel Vetter
2020-04-09 8:54 ` Benjamin Herrenschmidt
2020-04-09 9:41 ` Daniel Vetter
2020-04-09 14:19 ` Alex Deucher
2020-04-09 14:57 ` Daniel Vetter
2020-04-09 22:56 ` Benjamin Herrenschmidt
2020-04-10 8:11 ` Daniel Vetter
2020-04-09 11:46 ` Gerhard Pircher
2020-04-08 11:59 ` [PATCH 20/28] mm: remove the pgprot argument to __vmalloc Christoph Hellwig
2020-04-10 20:39 ` Michael Kelley
2020-04-08 11:59 ` [PATCH 21/28] mm: remove the prot argument to __vmalloc_node Christoph Hellwig
2020-04-08 11:59 ` [PATCH 22/28] mm: remove both instances of __vmalloc_node_flags Christoph Hellwig
2020-04-08 11:59 ` [PATCH 23/28] mm: remove __vmalloc_node_flags_caller Christoph Hellwig
2020-04-08 11:59 ` [PATCH 24/28] mm: switch the test_vmalloc module to use __vmalloc_node Christoph Hellwig
2020-04-08 11:59 ` [PATCH 25/28] mm: remove vmalloc_user_node_flags Christoph Hellwig
2020-04-09 22:25 ` Andrii Nakryiko [this message]
2020-04-13 20:03 ` Johannes Weiner
2020-04-08 11:59 ` [PATCH 26/28] arm64: use __vmalloc_node in arch_alloc_vmap_stack Christoph Hellwig
2020-04-08 12:18 ` Mark Rutland
2020-04-08 11:59 ` [PATCH 27/28] s390: use __vmalloc_node in alloc_vm_stack Christoph Hellwig
2020-04-08 13:33 ` Christian Borntraeger
2020-04-08 11:59 ` [PATCH 28/28] s390: use __vmalloc_node in stack_alloc Christoph Hellwig
2020-04-08 13:44 ` Christian Borntraeger
2020-04-08 12:25 ` decruft the vmalloc API Peter Zijlstra
2020-04-08 12:48 ` [PATCH 02/28] staging: android: ion: use vmap instead of vm_map_ram Hillf Danton
2020-04-08 15:40 ` Christoph Hellwig
2020-04-08 13:17 ` [PATCH 04/28] dma-mapping: use vmap insted of reimplementing it Hillf Danton
2020-04-08 15:42 ` Christoph Hellwig
2020-04-08 13:52 ` [PATCH 17/28] mm: remove the prot argument from vm_map_ram Hillf Danton
2020-04-08 15:43 ` Christoph Hellwig
2020-04-08 16:03 ` decruft the vmalloc API Russell King - ARM Linux admin
2020-04-08 16:07 ` Christoph Hellwig
2020-04-09 4:06 ` [PATCH 25/28] mm: remove vmalloc_user_node_flags Hillf Danton
2020-04-09 6:09 ` Christoph Hellwig
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='CAEf4BzZOC2tLrqt_Km=WQb=9xiya2e31i6K3oJuzgYQt6wp1LQ@mail.gmail.com' \
--to=andrii.nakryiko@gmail.com \
--cc=airlied@linux.ie \
--cc=akpm@linux-foundation.org \
--cc=bpf@vger.kernel.org \
--cc=christophe.leroy@c-s.fr \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=haiyangz@microsoft.com \
--cc=hannes@cmpxchg.org \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=kys@microsoft.com \
--cc=labbott@redhat.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=minchan@kernel.org \
--cc=ngupta@vflare.org \
--cc=peterz@infradead.org \
--cc=robin.murphy@arm.com \
--cc=sakari.ailus@linux.intel.com \
--cc=sthemmin@microsoft.com \
--cc=sumit.semwal@linaro.org \
--cc=wei.liu@kernel.org \
--cc=x86@kernel.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;
as well as URLs for NNTP newsgroup(s).