Skip to contentSkip to conversation

bpf: fix a no-mmu build failure by providing a stub allocator

PATCH New John Hubbard 2 participants 4 messages Nov 25, 2019

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover bpf: fix a no-mmu build failure by providing a stub allocator

Hi,

I ran into this on today's linux-next: commit c165016bac27 ("Add linux-next specific files for 20191125"). The kbuild robot reported a build failure on my larger (unrelated) patchset, but there were actually two build failures, and this patch here fixes the second failure.

John Hubbard (1):
bpf: fix a no-mmu build failure by providing a stub allocator

 kernel/bpf/syscall.c | 7 +++++++
 1 file changed, 7 insertions(+)
Signature · 1 line
2.24.0
#1 lore raw

PATCH 1/1 bpf: fix a no-mmu build failure by providing a stub allocator

Commit fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY") added code that calls vmalloc_user_node_flags() and therefore requires mm/vmalloc.c. However, that file is not built for the !CONFIG_MMU case. This leads to a build failure when using ARM with the config provided by at least one particular kbuild test robot report [1].

[1] https://lore/kernel.org/r/201911251639.UWS3hE3Y%[email protected]

Fix the build by providing a stub function for __bpf_map_area_alloc().

Fixes fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
Cc Andrii Nakryiko <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Song Liu <[email protected]>
Cc John Fastabend <[email protected]>
Cc Johannes Weiner <[email protected]>
---
 kernel/bpf/syscall.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/bpf/syscall.c +7 -0
index e3461ec59570..cb3e13ee4123 100644
@@ -128,6 +128,7 @@ static struct bpf_map *find_and_alloc_map(union bpf_attr *attr)
 	return map;
 }
 
+#ifdef CONFIG_MMU
 static void *__bpf_map_area_alloc(u64 size, int numa_node, bool mmapable)
 {
 	/* We really just want to fail instead of triggering OOM killer
@@ -162,6 +163,12 @@ static void *__bpf_map_area_alloc(u64 size, int numa_node, bool mmapable)
 					   GFP_KERNEL | __GFP_RETRY_MAYFAIL |
 					   flags, __builtin_return_address(0));
 }
+#else /* CONFIG_MMU */
+static void *__bpf_map_area_alloc(u64 size, int numa_node, bool mmapable)
+{
+	return NULL;
+}
+#endif /* !CONFIG_MMU */
 
 void *bpf_map_area_alloc(u64 size, int numa_node)
 {
Signature · 1 line
2.24.0
maintainer
#2 lore raw
Quoted 10 lines · John Hubbard

Commit fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY") added code that calls vmalloc_user_node_flags() and therefore requires mm/vmalloc.c. However, that file is not built for the !CONFIG_MMU case. This leads to a build failure when using ARM with the config provided by at least one particular kbuild test robot report [1].

[1] https://lore/kernel.org/r/201911251639.UWS3hE3Y%[email protected]

Fix the build by providing a stub function for __bpf_map_area_alloc().

Quoted 8 lines
Fixes fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
Cc Andrii Nakryiko <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Song Liu <[email protected]>
Cc John Fastabend <[email protected]>
Cc Johannes Weiner <[email protected]>

Thanks for the patch, already fixed via:

https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=ed81745a4c96841937f1da35c0eb66ac312e1480

#3 lore raw
Quoted 20 lines · Daniel Borkmann
Quoted 10 lines · John Hubbard

Commit fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY") added code that calls vmalloc_user_node_flags() and therefore requires mm/vmalloc.c. However, that file is not built for the !CONFIG_MMU case. This leads to a build failure when using ARM with the config provided by at least one particular kbuild test robot report [1].

[1] https://lore/kernel.org/r/201911251639.UWS3hE3Y%[email protected]

Fix the build by providing a stub function for __bpf_map_area_alloc().

Quoted 8 lines
Fixes fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
Cc Andrii Nakryiko <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Song Liu <[email protected]>
Cc John Fastabend <[email protected]>
Cc Johannes Weiner <[email protected]>
Quoted 3 lines

Thanks for the patch, already fixed via:

https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=ed81745a4c96841937f1da35c0eb66ac312e1480

OK, good, that's a better fix, too. Appreciate the quick answers!

thanks,

Signature · 2 lines
John Hubbard
NVIDIA