fix bpf_prog_pack build errors
Subsystems (8)
Song Liu
reviewerPATCH 2/2 bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE
In reply to Song LiuFix build with CONFIG_TRANSPARENT_HUGEPAGE=n with BPF_PROG_PACK_SIZE as PAGE_SIZE.
--- kernel/bpf/core.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/bpf/core.c +4 -0
@@ -814,7 +814,11 @@ int bpf_jit_add_poke_descriptor(struct bpf_prog *prog,* allocator. The prog_pack allocator uses HPAGE_PMD_SIZE page (2MB 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))
Signature · 1 line
2.30.2
Song Liu
reviewercover fix bpf_prog_pack build errors
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
Song Liu
reviewerPATCH 1/2 bpf: fix leftover header->pages in sparc and powerpc code.
Replace header->pages * PAGE_SIZE with new header->size.
--- arch/powerpc/net/bpf_jit_comp.c | 2 +- arch/sparc/net/bpf_jit_comp_64.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/net/bpf_jit_comp.c +1 -1
@@ -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);
arch/sparc/net/bpf_jit_comp_64.c +1 -1
@@ -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);
Signature · 1 line
2.30.2
This series was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This series was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 6 lines · On Tue, 8 Feb 2022 14:05:07 -0800 you wrote:
Fix build errors reported by kernel test robot.
Song Liu (2):
bpf: fix leftoverheader->pagesin sparc and powerpc code.
bpf: fixbpf_prog_packbuildHPAGE_PMD_SIZE
Quoted 6 lines
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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Re: [PATCH bpf-next 2/2] bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE
In reply to Song LiuQuoted 16 lines · Song Liu
Fix build with
CONFIG_TRANSPARENT_HUGEPAGE=nwithBPF_PROG_PACK_SIZEasPAGE_SIZE.Fixes 57631054fae6 ("bpf: Introduce bpf_prog_pack allocator")Reported-by kernel test robot <[email protected]>Signed-off-by Song Liu <[email protected]>--- kernel/bpf/core.c | 4 ++++ 1 file changed, 4 insertions(+)kernel/bpf/core.c +0
-0@@ -814,7 +814,11 @@ int bpf_jit_add_poke_descriptor(struct bpf_prog *prog,* allocator. The prog_pack allocator uses HPAGE_PMD_SIZE page (2MB on x86)
kernel/bpf/core.c int bpf_jit_add_poke_descriptor(struct bpf_prog *prog, · line 824
Quoted 10 lines
kernel/bpf/core.c +4
-0* 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);
Re: [PATCH bpf-next 2/2] bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE
Hi Eric,
Quoted 49 lines · Eric Dumazet
Quoted 16 lines · Song Liu
Fix build with
CONFIG_TRANSPARENT_HUGEPAGE=nwithBPF_PROG_PACK_SIZEasPAGE_SIZE.Fixes 57631054fae6 ("bpf: Introduce bpf_prog_pack allocator")Reported-by kernel test robot <[email protected]>Signed-off-by Song Liu <[email protected]>--- kernel/bpf/core.c | 4 ++++ 1 file changed, 4 insertions(+)kernel/bpf/core.c +0
-0@@ -814,7 +814,11 @@ int bpf_jit_add_poke_descriptor(struct bpf_prog *prog,* allocator. The prog_pack allocator uses HPAGE_PMD_SIZE page (2MB on x86) kernel/bpf/core.c int bpf_jit_add_poke_descriptor(struct bpf_prog *prog, · line 824
Quoted 10 lines
kernel/bpf/core.c +4
-0* 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_64and 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. */
Quoted 7 lines
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