All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] fix bpf_prog_pack build errors
@ 2022-02-08 22:05 Song Liu
  2022-02-08 22:05 ` [PATCH bpf-next 1/2] bpf: fix leftover header->pages in sparc and powerpc code Song Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Song Liu @ 2022-02-08 22:05 UTC (permalink / raw)
  To: bpf, netdev; +Cc: ast, daniel, andrii, kernel-team, Song Liu

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH bpf-next 1/2] bpf: fix leftover header->pages in sparc and powerpc code.
  2022-02-08 22:05 [PATCH bpf-next 0/2] fix bpf_prog_pack build errors Song Liu
@ 2022-02-08 22:05 ` Song Liu
  2022-02-08 22:05 ` [PATCH bpf-next 2/2] bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE Song Liu
  2022-02-09  5:20 ` [PATCH bpf-next 0/2] fix bpf_prog_pack build errors patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: Song Liu @ 2022-02-08 22:05 UTC (permalink / raw)
  To: bpf, netdev; +Cc: ast, daniel, andrii, kernel-team, Song Liu, kernel test robot

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 <lkp@intel.com>
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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH bpf-next 2/2] bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE
  2022-02-08 22:05 [PATCH bpf-next 0/2] fix bpf_prog_pack build errors Song Liu
  2022-02-08 22:05 ` [PATCH bpf-next 1/2] bpf: fix leftover header->pages in sparc and powerpc code Song Liu
@ 2022-02-08 22:05 ` Song Liu
  2022-02-10  1:13   ` Eric Dumazet
  2022-02-09  5:20 ` [PATCH bpf-next 0/2] fix bpf_prog_pack build errors patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Song Liu @ 2022-02-08 22:05 UTC (permalink / raw)
  To: bpf, netdev; +Cc: ast, daniel, andrii, kernel-team, Song Liu, kernel test robot

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 <lkp@intel.com>
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 (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))
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next 0/2] fix bpf_prog_pack build errors
  2022-02-08 22:05 [PATCH bpf-next 0/2] fix bpf_prog_pack build errors Song Liu
  2022-02-08 22:05 ` [PATCH bpf-next 1/2] bpf: fix leftover header->pages in sparc and powerpc code Song Liu
  2022-02-08 22:05 ` [PATCH bpf-next 2/2] bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE Song Liu
@ 2022-02-09  5:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-09  5:20 UTC (permalink / raw)
  To: Song Liu; +Cc: bpf, netdev, ast, daniel, andrii, kernel-team

Hello:

This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next 2/2] bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE
  2022-02-08 22:05 ` [PATCH bpf-next 2/2] bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE Song Liu
@ 2022-02-10  1:13   ` Eric Dumazet
  2022-02-10  5:59     ` Song Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2022-02-10  1:13 UTC (permalink / raw)
  To: Song Liu, bpf, netdev; +Cc: ast, daniel, andrii, kernel-team, kernel test robot


On 2/8/22 14:05, Song Liu wrote:
> 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 <lkp@intel.com>
> 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 (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))

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);





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next 2/2] bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE
  2022-02-10  1:13   ` Eric Dumazet
@ 2022-02-10  5:59     ` Song Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Song Liu @ 2022-02-10  5:59 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Song Liu, bpf, Network Development, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Kernel Team, kernel test robot

Hi Eric, 

> On Feb 9, 2022, at 5:13 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> 
> 
> On 2/8/22 14:05, Song Liu wrote:
>> 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 <lkp@intel.com>
>> 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 (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))
> 
> 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-02-10  5:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-08 22:05 [PATCH bpf-next 0/2] fix bpf_prog_pack build errors Song Liu
2022-02-08 22:05 ` [PATCH bpf-next 1/2] bpf: fix leftover header->pages in sparc and powerpc code Song Liu
2022-02-08 22:05 ` [PATCH bpf-next 2/2] bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE Song Liu
2022-02-10  1:13   ` Eric Dumazet
2022-02-10  5:59     ` Song Liu
2022-02-09  5:20 ` [PATCH bpf-next 0/2] fix bpf_prog_pack build errors patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.