History

mm: remove vmalloc_user_node_flags

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. [akpm@linux-foundation.org: fix nommu.c build] Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: Christophe Leroy <christophe.leroy@c-s.fr> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: David Airlie <airlied@linux.ie> Cc: Gao Xiang <xiang@kernel.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Haiyang Zhang <haiyangz@microsoft.com> Cc: "K. Y. Srinivasan" <kys@microsoft.com> Cc: Laura Abbott <labbott@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Michael Kelley <mikelley@microsoft.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Nitin Gupta <ngupta@vflare.org> Cc: Robin Murphy <robin.murphy@arm.com> Cc: Sakari Ailus <sakari.ailus@linux.intel.com> Cc: Stephen Hemminger <sthemmin@microsoft.com> Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Wei Liu <wei.liu@kernel.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Paul Mackerras <paulus@ozlabs.org> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Will Deacon <will@kernel.org> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Link: http://lkml.kernel.org/r/20200414131348.444715-27-hch@lst.de Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Christoph Hellwig committed 6 years ago

Commit 041de931 parent c3f896d4 files · +22 −37Browse files

Showing the changes to kernel (1 of 4 files). Show all

Unified · Split

kernel/bpf/syscall.c+14−10
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include <linux/nospec.h>
2626 #include <linux/audit.h>
2727 #include <uapi/linux/btf.h>
28+#include <asm/pgtable.h>
2829 #include <linux/bpf_lsm.h>
2930
3031 #define IS_FD_ARRAY(map) ((map)->map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY || \
@@ -281,26 +282,29 @@ static void *__bpf_map_area_alloc(u64 size, int numa_node, bool mmapable) · 250 unmodified lines
281282 * __GFP_RETRY_MAYFAIL to avoid such situations.
282283 */
283284
284− const gfp_t flags = __GFP_NOWARN | __GFP_ZERO;
285+ const gfp_t gfp = __GFP_NOWARN | __GFP_ZERO;
286+ unsigned int flags = 0;
287+ unsigned long align = 1;
285288 void *area;
286289
287290 if (size >= SIZE_MAX)
288291 return NULL;
289292
290293 /* kmalloc()'ed memory can't be mmap()'ed */
291− if (!mmapable && size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) {
292− area = kmalloc_node(size, GFP_USER | __GFP_NORETRY | flags,
294+ if (mmapable) {
295+ BUG_ON(!PAGE_ALIGNED(size));
296+ align = SHMLBA;
297+ flags = VM_USERMAP;
298+ } else if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) {
299+ area = kmalloc_node(size, gfp | GFP_USER | __GFP_NORETRY,
293300 numa_node);
294301 if (area != NULL)
295302 return area;
296303 }
297− if (mmapable) {
298− BUG_ON(!PAGE_ALIGNED(size));
299− return vmalloc_user_node_flags(size, numa_node, GFP_KERNEL |
300− __GFP_RETRY_MAYFAIL | flags);
301− }
302− return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_RETRY_MAYFAIL | flags,
303− numa_node, __builtin_return_address(0));
304+
305+ return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END,
306+ gfp | GFP_KERNEL | __GFP_RETRY_MAYFAIL, PAGE_KERNEL,
307+ flags, numa_node, __builtin_return_address(0));
304308 }
305309
306310 void *bpf_map_area_alloc(u64 size, int numa_node)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t