From: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
To: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, kafai@meta.com, kernel-team@meta.com,
memxor@gmail.com, eddyz87@gmail.com
Cc: Mykyta Yatsenko <yatsenko@meta.com>
Subject: [PATCH RFC v2 0/5] bpf: avoid locks in bpf_timer and bpf_wq
Date: Wed, 05 Nov 2025 15:59:02 +0000 [thread overview]
Message-ID: <20251105-timer_nolock-v2-0-32698db08bfa@meta.com> (raw)
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>
next reply other threads:[~2025-11-05 15:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-05 15:59 Mykyta Yatsenko [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251105-timer_nolock-v2-0-32698db08bfa@meta.com \
--to=mykyta.yatsenko5@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kafai@meta.com \
--cc=kernel-team@meta.com \
--cc=memxor@gmail.com \
--cc=yatsenko@meta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).