Commit d6170e4a authored by Puranjay Mohan's avatar Puranjay Mohan Committed by Alexei Starovoitov

bpf: hardcode BPF_PROG_PACK_SIZE to 2MB * num_possible_nodes()

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: ea2babac ("bpf: Simplify bpf_prog_pack_[size|mask]")
Reported-by: default avatar"kernelci.org bot" <bot@kernelci.org>
Closes: https://lore.kernel.org/all/7e216c88-77ee-47b8-becc-a0f780868d3c@sirena.org.uk/Reported-by: default avatarkernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202403092219.dhgcuz2G-lkp@intel.com/Suggested-by: default avatarSong Liu <song@kernel.org>
Signed-off-by: default avatarPuranjay Mohan <puranjay12@gmail.com>
Message-ID: <20240311122722.86232-1-puranjay12@gmail.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 379b97bb
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment