mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] selftests/bpf: Use the new NMI_BITS definition
@ 2026-10-02 10:29 Boqun Feng
  2026-10-02 13:50 ` Leon Hwang
  0 siblings, 1 reply; 2+ messages in thread
From: Boqun Feng @ 2026-10-02 10:29 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long, Gary Guo,
	Alice Ryhl, Lyude Paul, Daniel Almeida, Onur Özkan,
	Miguel Ojeda, Danilo Krummrich, Thomas Gleixner, linux-kernel,
	rust-for-linux, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Kumar Kartikeya Dwivedi, Martin KaFai Lau,
	Song Liu, Yonghong Song, Jiri Olsa, Emil Tsalapatis,
	Ihor Solodrai, Shuah Khan, bpf, linux-kselftest, Shrikanth Hegde,
	Leon Hwang, Alexei Starovoitov

The definition of NMI_BITS was out of sync after the introduction of
HAS_SEPARATE_PREEMPT_RESCHED_BITS, hence adjust it.

Reported-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Fixes: 3b0e2a22d408 ("preempt: Introduce HAS_SEPARATE_PREEMPT_RESCHED_BITS")
Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: Leon Hwang <leon.hwang@linux.dev>
Cc: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Boqun Feng <boqun@kernel.org>
---
v2: https://lore.kernel.org/lkml/20261001082519.16195-4-boqun@kernel.org/
v2 -> v3:

* Add Fixes tag.
* Add CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS weak symbol because
  CONFIG_* is not available in bpf programs.


 tools/testing/selftests/bpf/bpf_experimental.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h
index 2893bf06ff25..a09448347966 100644
--- a/tools/testing/selftests/bpf/bpf_experimental.h
+++ b/tools/testing/selftests/bpf/bpf_experimental.h
@@ -367,11 +367,16 @@ extern int bpf_cgroup_read_xattr(struct cgroup *cgroup, const char *name__str,
 extern int bpf_sock_read_xattr(struct socket *sock, const char *name__str,
 			       struct bpf_dynptr *value_p) __weak __ksym;
 
+extern bool CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS __kconfig __weak;
+
+/* A trivial macro to make NMI_BITS exactly the same as in <linux/preempt.h> */
+#define IS_ENABLED(cfg)	(cfg)
+
 #define PREEMPT_BITS	8
 #define SOFTIRQ_BITS	8
 #define HARDIRQ_DISABLE_BITS	8
 #define HARDIRQ_BITS	4
-#define NMI_BITS	1
+#define NMI_BITS	(1 + 3*IS_ENABLED(CONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITS))
 
 #define PREEMPT_SHIFT	0
 #define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
-- 
2.51.0


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

end of thread, other threads:[~2026-10-02 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-02 10:29 [PATCH v3] selftests/bpf: Use the new NMI_BITS definition Boqun Feng
2026-10-02 13:50 ` Leon Hwang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®