• Kui-Feng Lee's avatar
    bpf: struct_ops supports more than one page for trampolines. · 187e2af0
    Kui-Feng Lee authored
    The BPF struct_ops previously only allowed one page of trampolines.
    Each function pointer of a struct_ops is implemented by a struct_ops
    bpf program. Each struct_ops bpf program requires a trampoline.
    The following selftest patch shows each page can hold a little more
    than 20 trampolines.
    
    While one page is more than enough for the tcp-cc usecase,
    the sched_ext use case shows that one page is not always enough and hits
    the one page limit. This patch overcomes the one page limit by allocating
    another page when needed and it is limited to a total of
    MAX_IMAGE_PAGES (8) pages which is more than enough for
    reasonable usages.
    
    The variable st_map->image has been changed to st_map->image_pages, and
    its type has been changed to an array of pointers to pages.
    Signed-off-by: default avatarKui-Feng Lee <thinker.li@gmail.com>
    Link: https://lore.kernel.org/r/20240224223418.526631-3-thinker.li@gmail.comSigned-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
    187e2af0
bpf_struct_ops.c 31.1 KB