On Mon, 2024-02-12 at 18:08 -0800, Alexei Starovoitov wrote: [...] > Since it was a surprising behavior we can make libbpf > to auto-extend max_entries with the number of pages necessary > for arena global vars, but it will be surprising too. > > struct { > __uint(type, BPF_MAP_TYPE_ARENA); > __uint(map_flags, BPF_F_MMAPABLE); > __ulong(map_extra, 2ull << 44); // this is start of user VMA > __uint(max_entries, 1000); // this is length of user VMA in pages > } arena SEC(".maps"); > > if libbpf adds extra pages to max_entries the user_vm_end shifts too > and libbpf would need to mmap() it with that size. > When all is hidden in libbpf it's fine, but still can be a surprise > to see a different max_entries in map_info and bpftool map list. > Not sure which way is user friendlier. Adjusting max_entries would be surprising indeed. On the other hand, it would remove the error condition about "Declared arena map size %zd is too small ...". Probably either way is fine, as long as it is documented. Don't have a strong opinion.