Hi Song, > > bpf_prog_pack gives benefits without using PMD pages. For arm64 > with 64kB page, even bpf_prog_pack of 64kB can fit multiple bpf > programs in it. OTOH, 512MB is really big. > > How about we do something like the following? > > Thanks, > Song > > diff --git i/kernel/bpf/core.c w/kernel/bpf/core.c > index 9ee4536d0a09..1fe05c280e31 100644 > --- i/kernel/bpf/core.c > +++ w/kernel/bpf/core.c > @@ -888,7 +888,15 @@ 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. Cap BPF_PROG_PACK_SIZE to > + * 2MiB * num_possible_nodes(). > + */ > + #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 I have sent a patch with the above: https://lore.kernel.org/all/20240308120712.88122-1-puranjay12@xxxxxxxxx/ Thanks for helping with this. I have tested that this patch fixes this issue. Thanks, Puranjay