• Martin KaFai Lau's avatar
    bpf: Repurpose use_trace_rcu to reuse_now in bpf_local_storage · a47eabf2
    Martin KaFai Lau authored
    This patch re-purpose the use_trace_rcu to mean
    if the freed memory can be reused immediately or not.
    The use_trace_rcu is renamed to reuse_now. Other than
    the boolean test is reversed, it should be a no-op.
    
    The following explains the reason for the rename and how it will
    be used in a later patch.
    
    In a later patch, bpf_mem_cache_alloc/free will be used
    in the bpf_local_storage. The bpf mem allocator will reuse
    the freed memory immediately. Some of the free paths in
    bpf_local_storage does not support memory to be reused immediately.
    These paths are the "delete" elem cases from the bpf_*_storage_delete()
    helper and the map_delete_elem() syscall. Note that "delete" elem
    before the owner's (sk/task/cgrp/inode) lifetime ended is not
    the common usage for the local storage.
    
    The common free path, bpf_local_storage_destroy(), can reuse the
    memory immediately. This common path means the storage stays with
    its owner until the owner is destroyed.
    
    The above mentioned "delete" elem paths that cannot
    reuse immediately always has the 'use_trace_rcu ==  true'.
    The cases that is safe for immediate reuse always have
    'use_trace_rcu == false'. Instead of adding another arg
    in a later patch, this patch re-purpose this arg
    to reuse_now and have the test logic reversed.
    
    In a later patch, 'reuse_now == true' will free to the
    bpf_mem_cache_free() where the memory can be reused
    immediately. 'reuse_now == false' will go through the
    call_rcu_tasks_trace().
    Signed-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
    Link: https://lore.kernel.org/r/20230308065936.1550103-7-martin.lau@linux.devSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    a47eabf2
bpf_inode_storage.c 5.92 KB