• Hou Tao's avatar
    bpf: Optimize the free of inner map · af66bfd3
    Hou Tao authored
    When removing the inner map from the outer map, the inner map will be
    freed after one RCU grace period and one RCU tasks trace grace
    period, so it is certain that the bpf program, which may access the
    inner map, has exited before the inner map is freed.
    
    However there is no need to wait for one RCU tasks trace grace period if
    the outer map is only accessed by non-sleepable program. So adding
    sleepable_refcnt in bpf_map and increasing sleepable_refcnt when adding
    the outer map into env->used_maps for sleepable program. Although the
    max number of bpf program is INT_MAX - 1, the number of bpf programs
    which are being loaded may be greater than INT_MAX, so using atomic64_t
    instead of atomic_t for sleepable_refcnt. When removing the inner map
    from the outer map, using sleepable_refcnt to decide whether or not a
    RCU tasks trace grace period is needed before freeing the inner map.
    Signed-off-by: default avatarHou Tao <houtao1@huawei.com>
    Link: https://lore.kernel.org/r/20231204140425.1480317-6-houtao@huaweicloud.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    af66bfd3
core.c 75.4 KB