[PATCH bpf-next 0/2] fix bpf_prog_pack build errors
STALE1673d
6 messages,
4 authors,
2022-02-10 · open the first message on its own page
Fix build errors reported by kernel test robot.
Song Liu (2):
bpf: fix leftover header->pages in sparc and powerpc code.
bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE
arch/powerpc/net/bpf_jit_comp.c | 2 +-
arch/sparc/net/bpf_jit_comp_64.c | 2 +-
kernel/bpf/core.c | 4 ++++
3 files changed, 6 insertions(+), 2 deletions(-)
--
2.30.2
Fix build with CONFIG_TRANSPARENT_HUGEPAGE=n with BPF_PROG_PACK_SIZE as
PAGE_SIZE.
Fixes: 57631054fae6 ("bpf: Introduce bpf_prog_pack allocator")
Reported-by: kernel test robot <redacted>
Signed-off-by: Song Liu <song@kernel.org>
---
kernel/bpf/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 306aa63fa58e..9519264ab1ee 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c @@ -814,7 +814,11 @@ int bpf_jit_add_poke_descriptor(struct bpf_prog *prog,
* allocator . The prog_pack allocator uses HPAGE_PMD_SIZE page ( 2 MB on x86 )
* to host BPF programs .
*/
+ #ifdef CONFIG_TRANSPARENT_HUGEPAGE
#define BPF_PROG_PACK_SIZE HPAGE_PMD_SIZE
+ #else
+ #define BPF_PROG_PACK_SIZE PAGE_SIZE
+ #endif
#define BPF_PROG_CHUNK_SHIFT 6
#define BPF_PROG_CHUNK_SIZE (1 << BPF_PROG_CHUNK_SHIFT)
#define BPF_PROG_CHUNK_MASK (~(BPF_PROG_CHUNK_SIZE - 1)) --
2.30.2
Replace header->pages * PAGE_SIZE with new header->size.
Fixes: ed2d9e1a26cc ("bpf: Use size instead of pages in bpf_binary_header")
Reported-by: kernel test robot <redacted>
Signed-off-by: Song Liu <song@kernel.org>
---
arch/powerpc/net/bpf_jit_comp.c | 2 +-
arch/sparc/net/bpf_jit_comp_64.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
index d6ffdd0f2309..9003c313475d 100644
--- a/arch/powerpc/net/bpf_jit_comp.c
+++ b/arch/powerpc/net/bpf_jit_comp.c @@ -247,7 +247,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
fp -> jited = 1 ;
fp -> jited_len = proglen + FUNCTION_DESCR_SIZE ;
- bpf_flush_icache ( bpf_hdr , ( u8 * ) bpf_hdr + ( bpf_hdr -> pages * PAGE_SIZE ));
+ bpf_flush_icache ( bpf_hdr , ( u8 * ) bpf_hdr + bpf_hdr -> size );
if ( ! fp -> is_func || extra_pass ) {
bpf_jit_binary_lock_ro ( bpf_hdr );
bpf_prog_fill_jited_linfo ( fp , addrs ); diff --git a/arch/sparc/net/bpf_jit_comp_64.c b/arch/sparc/net/bpf_jit_comp_64.c
index b1e38784eb23..fa0759bfe498 100644
--- a/arch/sparc/net/bpf_jit_comp_64.c
+++ b/arch/sparc/net/bpf_jit_comp_64.c @@ -1599,7 +1599,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
if ( bpf_jit_enable > 1 )
bpf_jit_dump ( prog -> len , image_size , pass , ctx . image );
- bpf_flush_icache ( header , ( u8 * ) header + ( header -> pages * PAGE_SIZE ));
+ bpf_flush_icache ( header , ( u8 * ) header + header -> size );
if ( ! prog -> is_func || extra_pass ) {
bpf_jit_binary_lock_ro ( header ); --
2.30.2
Hello:
This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov [off-list ref]:
On Tue, 8 Feb 2022 14:05:07 -0800 you wrote: Fix build errors reported by kernel test robot.
Song Liu (2):
bpf: fix leftover header->pages in sparc and powerpc code.
bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE
arch/powerpc/net/bpf_jit_comp.c | 2 +-
arch/sparc/net/bpf_jit_comp_64.c | 2 +-
kernel/bpf/core.c | 4 ++++
3 files changed, 6 insertions(+), 2 deletions(-)
[...]
Here is the summary with links:
- [bpf-next,1/2] bpf: fix leftover header->pages in sparc and powerpc code.
https://git.kernel.org/bpf/bpf-next/c/0f350231b5ac
- [bpf-next,2/2] bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE
https://git.kernel.org/bpf/bpf-next/c/c1b13a9451ab
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
On 2/8/22 14:05, Song Liu wrote: quoted hunk Fix build with CONFIG_TRANSPARENT_HUGEPAGE=n with BPF_PROG_PACK_SIZE as
PAGE_SIZE.
Fixes: 57631054fae6 ("bpf: Introduce bpf_prog_pack allocator")
Reported-by: kernel test robot <redacted>
Signed-off-by: Song Liu <song@kernel.org>
---
kernel/bpf/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 306aa63fa58e..9519264ab1ee 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c @@ -814,7 +814,11 @@ int bpf_jit_add_poke_descriptor(struct bpf_prog *prog,
* allocator . The prog_pack allocator uses HPAGE_PMD_SIZE page ( 2 MB on x86 )
* to host BPF programs .
*/
+ #ifdef CONFIG_TRANSPARENT_HUGEPAGE
#define BPF_PROG_PACK_SIZE HPAGE_PMD_SIZE
+ #else
+ #define BPF_PROG_PACK_SIZE PAGE_SIZE
+ #endif
#define BPF_PROG_CHUNK_SHIFT 6
#define BPF_PROG_CHUNK_SIZE (1 << BPF_PROG_CHUNK_SHIFT)
#define BPF_PROG_CHUNK_MASK (~(BPF_PROG_CHUNK_SIZE - 1))
BTW, I do not understand with module_alloc(HPAGE_PMD_SIZE) would
necessarily allocate a huge page.
I am pretty sure it does not on x86_64 and dual socket host (NUMA)
It seems you need to multiply this by num_online_nodes() or change the
way __vmalloc_node_range()
works, because it currently does:
if (vmap_allow_huge && !(vm_flags & VM_NO_HUGE_VMAP)) {
unsigned long size_per_node;
/*
* Try huge pages. Only try for PAGE_KERNEL allocations,
* others like modules don't yet expect huge pages in
* their allocations due to apply_to_page_range not
* supporting them.
*/
size_per_node = size;
if (node == NUMA_NO_NODE)
<*> size_per_node /= num_online_nodes();
if (arch_vmap_pmd_supported(prot) && size_per_node >= PMD_SIZE)
shift = PMD_SHIFT;
else
shift = arch_vmap_pte_supported_shift(size_per_node);
Hi Eric,
On Feb 9, 2022, at 5:13 PM, Eric Dumazet [off-list ref] wrote:
On 2/8/22 14:05, Song Liu wrote: quoted Fix build with CONFIG_TRANSPARENT_HUGEPAGE=n with BPF_PROG_PACK_SIZE as
PAGE_SIZE.
Fixes: 57631054fae6 ("bpf: Introduce bpf_prog_pack allocator")
Reported-by: kernel test robot <redacted>
Signed-off-by: Song Liu <song@kernel.org>
---
kernel/bpf/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 306aa63fa58e..9519264ab1ee 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c @@ -814,7 +814,11 @@ int bpf_jit_add_poke_descriptor(struct bpf_prog *prog,
* allocator . The prog_pack allocator uses HPAGE_PMD_SIZE page ( 2 MB on x86 )
* to host BPF programs .
*/
+ #ifdef CONFIG_TRANSPARENT_HUGEPAGE
#define BPF_PROG_PACK_SIZE HPAGE_PMD_SIZE
+ #else
+ #define BPF_PROG_PACK_SIZE PAGE_SIZE
+ #endif
#define BPF_PROG_CHUNK_SHIFT 6
#define BPF_PROG_CHUNK_SIZE (1 << BPF_PROG_CHUNK_SHIFT)
#define BPF_PROG_CHUNK_MASK (~(BPF_PROG_CHUNK_SIZE - 1))
BTW, I do not understand with module_alloc(HPAGE_PMD_SIZE) would necessarily allocate a huge page.
I am pretty sure it does not on x86_64 and dual socket host (NUMA)
It seems you need to multiply this by num_online_nodes() or change the way __vmalloc_node_range()
works, because it currently does:
if (vmap_allow_huge && !(vm_flags & VM_NO_HUGE_VMAP)) {
unsigned long size_per_node;
/*
* Try huge pages. Only try for PAGE_KERNEL allocations,
* others like modules don't yet expect huge pages in
* their allocations due to apply_to_page_range not
* supporting them.
*/
size_per_node = size;
if (node == NUMA_NO_NODE)
<*> size_per_node /= num_online_nodes();
if (arch_vmap_pmd_supported(prot) && size_per_node >= PMD_SIZE)
shift = PMD_SHIFT;
else
shift = arch_vmap_pte_supported_shift(size_per_node);
Thanks for highlighting this issue! I will address this in a follow up commit.
Regards,
Song