From: Emil Tsalapatis <emil@etsalapatis.com>
To: bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
eddyz87@gmail.com, Emil Tsalapatis <emil@etsalapatis.com>
Subject: [PATCH 0/2] bpf: Allow bpf_for/bpf_repeat while holding spin
Date: Wed, 1 Jan 2025 15:37:29 -0500 [thread overview]
Message-ID: <20250101203731.1651981-1-emil@etsalapatis.com> (raw)
From: Emil Tsalapatis (Meta) <emil@etsalapatis.com>
In BPF programs, kfunc calls while holding a lock are not allowed
because kfuncs may sleep by default. The exception to this rule are the
functions in special_kfunc_list, which are guaranteed to not sleep. The
bpf_iter_num_* functions used by the bpf_for and bpf_repeat macros make
no function calls themselves, and as such are guaranteed to not sleep.
Add them to special_kfunc_list to allow them within BPF spinlock
critical sections.
Signed-off-by: Emil Tsalapatis (Meta) <emil@etsalapatis.com>
Emil Tsalapatis (2):
bpf: Allow bpf_for/bpf_repeat calls while holding a spinlock
selftests/bpf: test bpf_for within spin lock section
kernel/bpf/verifier.c | 20 +++++++++++++-
.../selftests/bpf/progs/verifier_spin_lock.c | 26 +++++++++++++++++++
2 files changed, 45 insertions(+), 1 deletion(-)
--
2.47.1
next reply other threads:[~2025-01-01 20:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-01 20:37 Emil Tsalapatis [this message]
2025-01-01 20:37 ` [PATCH 1/2] bpf: Allow bpf_for/bpf_repeat calls while holding a spinlock Emil Tsalapatis
2025-01-02 18:02 ` Eduard Zingerman
2025-01-04 19:25 ` Emil Tsalapatis
2025-01-05 0:11 ` Eduard Zingerman
2025-01-06 14:56 ` Emil Tsalapatis
2025-01-06 18:59 ` Alexei Starovoitov
2025-01-01 20:37 ` [PATCH 2/2] selftests/bpf: test bpf_for within spin lock section Emil Tsalapatis
2025-01-02 18:05 ` Eduard Zingerman
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=20250101203731.1651981-1-emil@etsalapatis.com \
--to=emil@etsalapatis.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.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