Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] I guess up to the size limit of eBPF Maps. #5085

Open
Bobcat-yang opened this issue Aug 18, 2024 · 1 comment
Open

[question] I guess up to the size limit of eBPF Maps. #5085

Bobcat-yang opened this issue Aug 18, 2024 · 1 comment

Comments

@Bobcat-yang
Copy link

Hello,
I would like to know what is the size limit of eBPF Maps in Linux? How much data can I store when using it?
I did not find the answer in the documentation, so I asked this question here. Hope to get your reply.

Thank you.

@yonghong-song
Copy link
Collaborator

There is no documentation. You can see the source code, e.g.,
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/kernel/bpf/hashtab.c

if ((u64)attr->key_size + attr->value_size >= KMALLOC_MAX_SIZE -
	   sizeof(struct htab_elem))
		/* if key_size + value_size is bigger, the user space won't be
		 * able to access the elements via bpf syscall. This check
		 * also makes sure that the elem_size doesn't overflow and it's
		 * kmalloc-able later in htab_map_update_elem()
		 */
		return -E2BIG;

or

	/* hash table size must be power of 2; roundup_pow_of_two() can overflow
	 * into UB on 32-bit arches, so check that first
	 */
	err = -E2BIG;
	if (htab->map.max_entries > 1UL << 31)
		goto free_htab;

Similarly you can check other files for other map types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants