bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC v2 0/5] bpf: avoid locks in bpf_timer and bpf_wq
@ 2025-11-05 15:59 Mykyta Yatsenko
  2025-11-05 15:59 ` [PATCH RFC v2 1/5] bpf: refactor bpf_async_cb callback update Mykyta Yatsenko
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Mykyta Yatsenko @ 2025-11-05 15:59 UTC (permalink / raw)
  To: bpf, ast, andrii, daniel, kafai, kernel-team, memxor, eddyz87
  Cc: Mykyta Yatsenko

This series reworks implementation of BPF timer and workqueue APIs.
The goal is to make both timers and wq non-blocking, enabling their use
in NMI context.
Today this code relies on a bpf_spin_lock embedded in the map element to
serialize:
 * init of the async object,
 * setting/changing the callback and bpf_prog
 * starting/cancelling the timer/work
 * tearing down when the map element is deleted or the map’s user ref is
 dropped

The series apply design similar to existing bpf_task_work
approach [1]: RCU and refcount to maintain lifetime guarantees and state
machine to handle data races.

This RFC doesn’t yet fully add NMI support for timers
and workqueue helpers and kfuncs, but it takes the first step by
removing the spinlock from bpf_async_cb struct.

---
1: https://lore.kernel.org/bpf/175864081800.1466288.3242104888617580131.git-patchwork-notify@kernel.org/

Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>

---
Changes in v2:
- Move refcnt initialization and put (from cancel_and_free())
from patch 5 into the patch 4, so that patch 4 has more clear and full
implementation and use of refcnt
- Link to v1: https://lore.kernel.org/r/20251031-timer_nolock-v1-0-b064ae403bfb@meta.com

---
Mykyta Yatsenko (5):
      bpf: refactor bpf_async_cb callback update
      bpf: refactor bpf_async_cb prog swap
      bpf: factor out timer deletion helper
      bpf: add refcnt into struct bpf_async_cb
      bpf: remove lock from bpf_async_cb

 kernel/bpf/helpers.c | 309 +++++++++++++++++++++++++++++++--------------------
 1 file changed, 189 insertions(+), 120 deletions(-)
---
base-commit: 23f852daa4bab4d579110e034e4d513f7d490846
change-id: 20251028-timer_nolock-457f5b9daace

Best regards,
-- 
Mykyta Yatsenko <yatsenko@meta.com>


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2025-11-07 20:21 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-05 15:59 [PATCH RFC v2 0/5] bpf: avoid locks in bpf_timer and bpf_wq Mykyta Yatsenko
2025-11-05 15:59 ` [PATCH RFC v2 1/5] bpf: refactor bpf_async_cb callback update Mykyta Yatsenko
2025-11-06 17:03   ` Kumar Kartikeya Dwivedi
2025-11-05 15:59 ` [PATCH RFC v2 2/5] bpf: refactor bpf_async_cb prog swap Mykyta Yatsenko
2025-11-06 16:57   ` Kumar Kartikeya Dwivedi
2025-11-05 15:59 ` [PATCH RFC v2 3/5] bpf: factor out timer deletion helper Mykyta Yatsenko
2025-11-06 16:58   ` Kumar Kartikeya Dwivedi
2025-11-05 15:59 ` [PATCH RFC v2 4/5] bpf: add refcnt into struct bpf_async_cb Mykyta Yatsenko
2025-11-06 17:48   ` Kumar Kartikeya Dwivedi
2025-11-06 21:41   ` Yonghong Song
2025-11-06 22:36     ` Mykyta Yatsenko
2025-11-05 15:59 ` [PATCH RFC v2 5/5] bpf: remove lock from bpf_async_cb Mykyta Yatsenko
2025-11-06 19:25   ` Kumar Kartikeya Dwivedi
2025-11-07  3:15   ` Alexei Starovoitov
2025-11-07 15:58     ` Mykyta Yatsenko
2025-11-07 20:21       ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).