* [PATCH bpf-next v2] bpf: hardcode BPF_PROG_PACK_SIZE to 2MB * num_possible_nodes()
@ 2024-03-11 12:27 Puranjay Mohan
2024-03-11 23:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Puranjay Mohan @ 2024-03-11 12:27 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, John Fastabend,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
bpf, linux-kernel
Cc: puranjay12
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 size for allocations done through
the prog pack allocator. On most architectures, PMD_SIZE will be equal
to 2MB in case of 4KB pages and will be greater than 2MB for bigger page
sizes.
Fixes: ea2babac63d4 ("bpf: Simplify bpf_prog_pack_[size|mask]")
Reported-by: "kernelci.org bot" <bot@kernelci.org>
Closes: https://lore.kernel.org/all/7e216c88-77ee-47b8-becc-a0f780868d3c@sirena.org.uk/
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202403092219.dhgcuz2G-lkp@intel.com/
Suggested-by: Song Liu <song@kernel.org>
Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
---
kernel/bpf/core.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 134b7979f537..a8007f7f706d 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -893,7 +893,12 @@ static LIST_HEAD(pack_list);
* CONFIG_MMU=n. Use PAGE_SIZE in these cases.
*/
#ifdef PMD_SIZE
-#define BPF_PROG_PACK_SIZE (PMD_SIZE * num_possible_nodes())
+/* PMD_SIZE is really big for some archs. It doesn't make sense to
+ * reserve too much memory in one allocation. Hardcode BPF_PROG_PACK_SIZE to
+ * 2MiB * num_possible_nodes(). On most architectures PMD_SIZE will be
+ * greater than or equal to 2MB.
+ */
+#define BPF_PROG_PACK_SIZE (SZ_2M * num_possible_nodes())
#else
#define BPF_PROG_PACK_SIZE PAGE_SIZE
#endif
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH bpf-next v2] bpf: hardcode BPF_PROG_PACK_SIZE to 2MB * num_possible_nodes()
2024-03-11 12:27 [PATCH bpf-next v2] bpf: hardcode BPF_PROG_PACK_SIZE to 2MB * num_possible_nodes() Puranjay Mohan
@ 2024-03-11 23:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-11 23:40 UTC (permalink / raw)
To: Puranjay Mohan
Cc: ast, daniel, john.fastabend, andrii, martin.lau, eddyz87, song,
yonghong.song, kpsingh, sdf, haoluo, jolsa, bpf, linux-kernel
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Mon, 11 Mar 2024 12:27:22 +0000 you 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 size for allocations done through
> the prog pack allocator. On most architectures, PMD_SIZE will be equal
> to 2MB in case of 4KB pages and will be greater than 2MB for bigger page
> sizes.
>
> [...]
Here is the summary with links:
- [bpf-next,v2] bpf: hardcode BPF_PROG_PACK_SIZE to 2MB * num_possible_nodes()
https://git.kernel.org/bpf/bpf-next/c/d6170e4aaf86
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] 2+ messages in thread
end of thread, other threads:[~2024-03-11 23:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-11 12:27 [PATCH bpf-next v2] bpf: hardcode BPF_PROG_PACK_SIZE to 2MB * num_possible_nodes() Puranjay Mohan
2024-03-11 23:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox