BPF List
 help / color / mirror / Atom feed
From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Mykyta Yatsenko <yatsenko@meta.com>,
	kkd@meta.com, kernel-team@meta.com
Subject: [RFC PATCH bpf-next v1 2/6] bpf: Allow timing functions in lock critical sections
Date: Wed, 11 Feb 2026 10:12:42 -0800	[thread overview]
Message-ID: <20260211181248.3040142-3-memxor@gmail.com> (raw)
In-Reply-To: <20260211181248.3040142-1-memxor@gmail.com>

Allow timing related functions in critical sections, which is useful to
measure the time spent acquiring a lock inside BPF programs.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 kernel/bpf/verifier.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index edf5342b982f..4acd8e848c88 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -21044,7 +21044,11 @@ static int do_check_insn(struct bpf_verifier_env *env, bool *do_print_state)
 
 			if (env->cur_state->active_locks) {
 				if ((insn->src_reg == BPF_REG_0 &&
-				     insn->imm != BPF_FUNC_spin_unlock) ||
+				     insn->imm != BPF_FUNC_spin_unlock &&
+				     insn->imm != BPF_FUNC_ktime_get_ns &&
+				     insn->imm != BPF_FUNC_ktime_get_boot_ns &&
+				     insn->imm != BPF_FUNC_ktime_get_coarse_ns &&
+				     insn->imm != BPF_FUNC_ktime_get_tai_ns) ||
 				    (insn->src_reg == BPF_PSEUDO_KFUNC_CALL &&
 				     (insn->off != 0 || !kfunc_spin_allowed(insn->imm)))) {
 					verbose(env,
-- 
2.47.3


  parent reply	other threads:[~2026-02-11 18:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-11 18:12 [RFC PATCH bpf-next v1 0/6] Concurrency Testing Kumar Kartikeya Dwivedi
2026-02-11 18:12 ` [RFC PATCH bpf-next v1 1/6] bpf: Support repeat, duration fields for syscall prog runs Kumar Kartikeya Dwivedi
2026-02-11 22:02   ` Alexei Starovoitov
2026-02-11 18:12 ` Kumar Kartikeya Dwivedi [this message]
2026-02-11 18:12 ` [RFC PATCH bpf-next v1 3/6] bpf: Enable rqspinlock in tracing progs Kumar Kartikeya Dwivedi
2026-02-11 22:04   ` Alexei Starovoitov
2026-02-11 18:12 ` [RFC PATCH bpf-next v1 4/6] selftests/bpf: Introduce concurrency testing tool Kumar Kartikeya Dwivedi
2026-02-11 22:08   ` Alexei Starovoitov
2026-02-11 18:12 ` [RFC PATCH bpf-next v1 5/6] selftests/bpf: Generate various conctest permutations Kumar Kartikeya Dwivedi
2026-02-11 22:09   ` Alexei Starovoitov
2026-02-11 18:12 ` [RFC PATCH bpf-next v1 6/6] selftests/bpf: Extend conctest to wq and task_work Kumar Kartikeya Dwivedi

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=20260211181248.3040142-3-memxor@gmail.com \
    --to=memxor@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=kkd@meta.com \
    --cc=martin.lau@kernel.org \
    --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