[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPhsuW7Do8c8cA6rVykhVnFRgKA0s6nO8JyGXkEB7gm94KR7Mw@mail.gmail.com>
Date: Fri, 8 Mar 2024 08:55:15 -0800
From: Song Liu <song@...nel.org>
To: Puranjay Mohan <puranjay12@...il.com>
Cc: Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
John Fastabend <john.fastabend@...il.com>, Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>, Eduard Zingerman <eddyz87@...il.com>,
Yonghong Song <yonghong.song@...ux.dev>, KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...gle.com>, Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next] bpf: cap BPF_PROG_PACK_SIZE to 2MB * num_possible_nodes()
On Fri, Mar 8, 2024 at 4:07 AM Puranjay Mohan <puranjay12@...il.com> wrote:
>
> On some architectures like ARM64, PMD_SIZE can be really large in some
> configurations. Like with CONFIG_ARM64_64K_PAGES=y the PMD_SIZE is
> 512MB.
>
> Use 2MB * num_possible_nodes() as the upper limit for allocations done
> through the prog pack allocator.
>
> Fixes: ea2babac63d4 ("bpf: Simplify bpf_prog_pack_[size|mask]")
> Reported-by: "kernelci.org bot" <bot@...nelci.org>
> Closes: https://lore.kernel.org/all/7e216c88-77ee-47b8-becc-a0f780868d3c@sirena.org.uk/
> Suggested-by: Song Liu <song@...nel.org>
> Signed-off-by: Puranjay Mohan <puranjay12@...il.com>
> ---
> kernel/bpf/core.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
> index 134b7979f537..83a3b6964e54 100644
> --- a/kernel/bpf/core.c
> +++ b/kernel/bpf/core.c
> @@ -893,8 +893,17 @@ static LIST_HEAD(pack_list);
> * CONFIG_MMU=n. Use PAGE_SIZE in these cases.
> */
> #ifdef PMD_SIZE
> +/*
> + * PMD_SIZE is really big for some archs. It doesn't make sense to
> + * reserve too much memory in one allocation. Cap BPF_PROG_PACK_SIZE to
> + * 2MiB * num_possible_nodes().
> + */
In BPF code, we prefer a different style of multiple line comments:
/* PMD_SIZE is really big for some archs. It doesn't make sense to
* reserve too much memory in one allocation. Cap BPF_PROG_PACK_SIZE to
* 2MiB * num_possible_nodes().
*/
Other than this, this looks good to me.
Acked-by: Song Liu <song@...nel.org>
Thanks,
Song
> +#if PMD_SIZE <= (1 << 21)
> #define BPF_PROG_PACK_SIZE (PMD_SIZE * num_possible_nodes())
> #else
> +#define BPF_PROG_PACK_SIZE ((1 << 21) * num_possible_nodes())
> +#endif
> +#else
> #define BPF_PROG_PACK_SIZE PAGE_SIZE
> #endif
Powered by blists - more mailing lists