]> git.ipfire.org Git - thirdparty/linux.git/commit
bpf: Enable bpf_timer and bpf_wq in any context
authorAlexei Starovoitov <ast@kernel.org>
Sun, 1 Feb 2026 02:53:55 +0000 (18:53 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 4 Feb 2026 00:58:46 +0000 (16:58 -0800)
commit1bfbc267ec915e58c3723a2237bf067f0c4dffa8
tree176344fcef3c4eada4ea0b1ba555d3ede30f0380
parentf11f7cf90ee09dbcf76413818063ffc38ed2d9fe
bpf: Enable bpf_timer and bpf_wq in any context

Refactor bpf_timer and bpf_wq to allow calling them from any context:
- add refcnt to bpf_async_cb
- map_delete_elem or map_free will drop refcnt to zero
  via bpf_async_cancel_and_free()
- once refcnt is zero timer/wq_start is not allowed to make sure
  that callback cannot rearm itself
- if in_hardirq defer to start/cancel operations to irq_work

Co-developed-by: Mykyta Yatsenko <yatsenko@meta.com>
Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/bpf/20260201025403.66625-2-alexei.starovoitov@gmail.com
kernel/bpf/helpers.c