All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Song Liu <song@kernel.org>, bpf@vger.kernel.org, netdev@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	kernel-team@fb.com, kernel test robot <lkp@intel.com>
Subject: Re: [PATCH bpf-next 2/2] bpf: fix bpf_prog_pack build HPAGE_PMD_SIZE
Date: Wed, 9 Feb 2022 17:13:09 -0800	[thread overview]
Message-ID: <3d13bcf4-8d20-0f06-5c00-3880b79363af@gmail.com> (raw)
In-Reply-To: <20220208220509.4180389-3-song@kernel.org>


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





  reply	other threads:[~2022-02-10  1:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3d13bcf4-8d20-0f06-5c00-3880b79363af@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=lkp@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=song@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.