• Yafang Shao's avatar
    bpf: devmap memory usage · fa5e83df
    Yafang Shao authored
    A new helper is introduced to calculate the memory usage of devmap and
    devmap_hash. The number of dynamically allocated elements are recored
    for devmap_hash already, but not for devmap. To track the memory size of
    dynamically allocated elements, this patch also count the numbers for
    devmap.
    
    The result as follows,
    - before
    40: devmap  name count_map  flags 0x80
            key 4B  value 4B  max_entries 65536  memlock 524288B
    41: devmap_hash  name count_map  flags 0x80
            key 4B  value 4B  max_entries 65536  memlock 524288B
    
    - after
    40: devmap  name count_map  flags 0x80  <<<< no elements
            key 4B  value 4B  max_entries 65536  memlock 524608B
    41: devmap_hash  name count_map  flags 0x80 <<<< no elements
            key 4B  value 4B  max_entries 65536  memlock 524608B
    
    Note that the number of buckets is same with max_entries for devmap_hash
    in this case.
    Signed-off-by: default avatarYafang Shao <laoar.shao@gmail.com>
    Link: https://lore.kernel.org/r/20230305124615.12358-11-laoar.shao@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    fa5e83df
devmap.c 30 KB