On Tue, 2024-02-13 at 17:02 -0800, Alexei Starovoitov wrote: [...] > > First is regarding initialization data. > > In bpf_object__init_internal_map() the amount of bpf_map_mmap_sz(map) > > bytes is mmaped and only data_sz bytes are copied, > > then bpf_map_mmap_sz(map) bytes are copied in bpf_object__create_maps(). > > Is Linux/libc smart enough to skip action on pages which were mmaped but > > never touched? > > kernel gives zeroed out pages to user space. > So it's ok to mmap a page, copy data_sz bytes into it > and later copy the full page from one addr to another. > No garbage copy. > In this case there will be data by llvm construction of ".arena.1" > It looks to me that even .bss-like __arena vars have zero-s in data > and non-zero data_sz. I was actually worried about second memcpy increasing RSS unnecessarily, but I missed that internal map does: def->max_entries = roundup(data_sz, page_sz) / page_sz; So that is not an issue as bpf_map_mmap_sz() for internal map is proportional to data_sz, not full arena. Sorry for the noise.