From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E54AC2BA19 for ; Thu, 9 Apr 2020 04:07:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1C97E20757 for ; Thu, 9 Apr 2020 04:07:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C97E20757 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 90DBA8E000D; Thu, 9 Apr 2020 00:07:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8967F8E0006; Thu, 9 Apr 2020 00:07:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 738808E000D; Thu, 9 Apr 2020 00:07:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0110.hostedemail.com [216.40.44.110]) by kanga.kvack.org (Postfix) with ESMTP id 674938E0006 for ; Thu, 9 Apr 2020 00:07:00 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 31A81181AF5C1 for ; Thu, 9 Apr 2020 04:07:00 +0000 (UTC) X-FDA: 76686981000.09.stop32_1fd01bfcb424a X-HE-Tag: stop32_1fd01bfcb424a X-Filterd-Recvd-Size: 6147 Received: from mail3-164.sinamail.sina.com.cn (mail3-164.sinamail.sina.com.cn [202.108.3.164]) by imf44.hostedemail.com (Postfix) with SMTP for ; Thu, 9 Apr 2020 04:06:58 +0000 (UTC) Received: from unknown (HELO localhost.localdomain)([114.246.227.120]) by sina.com with ESMTP id 5E8E9F5E00033C6F; Thu, 9 Apr 2020 12:06:56 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 13542715073441 From: Hillf Danton To: Christoph Hellwig Cc: Andrew Morton , linux-mm@kvack.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 25/28] mm: remove vmalloc_user_node_flags Date: Thu, 9 Apr 2020 12:06:45 +0800 Message-Id: <20200409040645.14400-1-hdanton@sina.com> In-Reply-To: <20200408115926.1467567-1-hch@lst.de> References: <20200408115926.1467567-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 8 Apr 2020 13:59:23 +0200 Christoph Hellwig wrote: >=20 > 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. >=20 > For this to compile for the nommu case add a __vmalloc_node_range stub > to nommu.c. >=20 > Signed-off-by: Christoph Hellwig > --- > 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(-) >=20 > 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 n= uma_node, bool mmapable) > * __GFP_RETRY_MAYFAIL to avoid such situations. > */ > =20 > - const gfp_t flags =3D __GFP_NOWARN | __GFP_ZERO; > + const gfp_t gfp =3D __GFP_NOWARN | __GFP_ZERO; > + unsigned int flags =3D 0; > + unsigned long align =3D 1; > void *area; > =20 > if (size >=3D SIZE_MAX) > return NULL; > =20 > /* kmalloc()'ed memory can't be mmap()'ed */ > - if (!mmapable && size <=3D (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { > - area =3D kmalloc_node(size, GFP_USER | __GFP_NORETRY | flags, > + if (mmapable) { > + BUG_ON(!PAGE_ALIGNED(size)); > + align =3D SHMLBA; > + flags =3D VM_USERMAP; > + } else if (size <=3D (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { > + area =3D kmalloc_node(size, gfp | GFP_USER | __GFP_NORETRY, > numa_node); > if (area !=3D 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 | fla= gs, > - numa_node, __builtin_return_address(0)); > + > + return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END, > + gfp | GFP_KERNEL | __GFP_RETRY_MAYFAIL, PAGE_KERNEL, Dunno if __GFP_ZERO needs to be added to match the current=20 vmalloc_user_node_flags(). > + flags, numa_node, __builtin_return_address(0)); > } > =20 > 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); > =20 > +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 gf= p_mask, > int node, const void *caller) > { > @@ -180,12 +188,6 @@ void *vmalloc_user(unsigned long size) > } > EXPORT_SYMBOL(vmalloc_user); > =20 > -void *vmalloc_user_node_flags(unsigned long size, int node, gfp_t flag= s) > -{ > - 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); > =20 > -/** > - * vmalloc_user_node_flags - allocate memory for userspace on a specif= ic 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 userspac= e > - * 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 flag= s) > -{ > - 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 > --=20 > 2.25.1