• Yafang Shao's avatar
    bpf: arraymap memory usage · 1746d055
    Yafang Shao authored
    Introduce array_map_mem_usage() to calculate arraymap memory usage. In
    this helper, some small memory allocations are ignored, like the
    allocation of struct bpf_array_aux in prog_array. The inner_map_meta in
    array_of_map is also ignored.
    
    The result as follows,
    
    - before
    11: array  name count_map  flags 0x0
            key 4B  value 4B  max_entries 65536  memlock 524288B
    12: percpu_array  name count_map  flags 0x0
            key 4B  value 4B  max_entries 65536  memlock 8912896B
    13: perf_event_array  name count_map  flags 0x0
            key 4B  value 4B  max_entries 65536  memlock 524288B
    14: prog_array  name count_map  flags 0x0
            key 4B  value 4B  max_entries 65536  memlock 524288B
    15: cgroup_array  name count_map  flags 0x0
            key 4B  value 4B  max_entries 65536  memlock 524288B
    
    - after
    11: array  name count_map  flags 0x0
            key 4B  value 4B  max_entries 65536  memlock 524608B
    12: percpu_array  name count_map  flags 0x0
            key 4B  value 4B  max_entries 65536  memlock 17301824B
    13: perf_event_array  name count_map  flags 0x0
            key 4B  value 4B  max_entries 65536  memlock 524608B
    14: prog_array  name count_map  flags 0x0
            key 4B  value 4B  max_entries 65536  memlock 524608B
    15: cgroup_array  name count_map  flags 0x0
            key 4B  value 4B  max_entries 65536  memlock 524608B
    Signed-off-by: default avatarYafang Shao <laoar.shao@gmail.com>
    Link: https://lore.kernel.org/r/20230305124615.12358-5-laoar.shao@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    1746d055
arraymap.c 37.5 KB