Skip to content

KFunc bpf_preempt_disable


Disable preemption in eBPF programs.


void bpf_preempt_disable()


This 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 in non-preemptible regions. Static subprog calls are permitted. Sleepable helpers and kfuncs are disallowed in non-preemptible regions.

Program types

The following program types can make use of this kfunc:


Docs could be improved

This part of the docs is incomplete, contributions are very welcome