• Kumar Kartikeya Dwivedi's avatar
    bpf: Introduce bpf_preempt_[disable,enable] kfuncs · fc7566ad
    Kumar Kartikeya Dwivedi authored
    Introduce two new BPF kfuncs, bpf_preempt_disable and
    bpf_preempt_enable. These kfuncs allow disabling preemption in BPF
    programs. Nesting is allowed, since the intended use cases includes
    building native BPF spin locks without kernel helper involvement. Apart
    from that, this can be used to per-CPU data structures for cases where
    programs (or userspace) may preempt one or the other. Currently, while
    per-CPU access is stable, whether it will be consistent is not
    guaranteed, as only migration is disabled for BPF programs.
    
    Global functions are disallowed from being called, but support for them
    will be added as a follow up not just preempt kfuncs, but rcu_read_lock
    kfuncs as well. Static subprog calls are permitted. Sleepable helpers
    and kfuncs are disallowed in non-preemptible regions.
    Signed-off-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
    Link: https://lore.kernel.org/r/20240424031315.2757363-2-memxor@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    fc7566ad
helpers.c 75.9 KB