selftests/bpf: Use the new NMI_BITS definition
Subsystems (4)
Boqun Feng
reviewerPATCH v3 1/1 selftests/bpf: Use the new NMI_BITS definition
The definition of NMI_BITS was out of sync after the introduction of HAS_SEPARATE_PREEMPT_RESCHED_BITS, hence adjust it.
---
v2: https://lore.kernel.org/lkml/[email protected]/
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(-)
tools/testing/selftests/bpf/bpf_experimental.h +6 -1
@@ -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)
Signature · 1 line
2.51.0
Quoted 9 lines · Boqun Feng
The definition of
NMI_BITSwas out of sync after the introduction ofHAS_SEPARATE_PREEMPT_RESCHED_BITS, hence adjust it.Reported-by Shrikanth Hegde <[email protected]>Fixes 3b0e2a22d408 ("preempt: Introduce HAS_SEPARATE_PREEMPT_RESCHED_BITS")Reviewed-by Shrikanth Hegde <[email protected]>Cc Leon Hwang <[email protected]>Cc Alexei Starovoitov <[email protected]>Signed-off-by Boqun Feng <[email protected]>
lgtm,
One nit below.
Quoted 17 lines
---
v2: https://lore.kernel.org/lkml/[email protected]/
v2 -> v3:* Add Fixes tag.
* AddCONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITSweak symbol because CONFIG_* is not available in bpf programs.tools/testing/selftests/bpf/bpf_experimental.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tools/testing/selftests/bpf/bpf_experimental.h +0
-0
tools/testing/selftests/bpf/bpf_experimental.h extern int bpf_cgroup_read_xattr(struct cgroup *cgroup, const char *name__str, · line 373
Quoted 7 lines
tools/testing/selftests/bpf/bpf_experimental.h +4
-0@@ -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)
NIT: change this to ((cfg) ? 1 : 0) to match IS_ENABLED() semantics.
Thanks,
Leon
Quoted 10 lines
tools/testing/selftests/bpf/bpf_experimental.h +2
-1+#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)
Boqun Feng
reviewerQuoted 37 lines · Leon Hwang
Quoted 9 lines · Boqun Feng
The definition of
NMI_BITSwas out of sync after the introduction ofHAS_SEPARATE_PREEMPT_RESCHED_BITS, hence adjust it.Reported-by Shrikanth Hegde <[email protected]>Fixes 3b0e2a22d408 ("preempt: Introduce HAS_SEPARATE_PREEMPT_RESCHED_BITS")Reviewed-by Shrikanth Hegde <[email protected]>Cc Leon Hwang <[email protected]>Cc Alexei Starovoitov <[email protected]>Signed-off-by Boqun Feng <[email protected]>lgtm,
Acked-by Leon Hwang <[email protected]>One nit below.
Quoted 20 lines
---
v2: https://lore.kernel.org/lkml/[email protected]/
v2 -> v3:* Add Fixes tag.
* AddCONFIG_HAS_SEPARATE_PREEMPT_RESCHED_BITSweak symbol because CONFIG_* is not available in bpf programs.tools/testing/selftests/bpf/bpf_experimental.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tools/testing/selftests/bpf/bpf_experimental.h +0
-0@@ -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;
Quoted 7 lines
tools/testing/selftests/bpf/bpf_experimental.h extern int bpf_cgroup_read_xattr(struct cgroup *cgroup, const char *name__str, · line 373
Quoted 4 lines
tools/testing/selftests/bpf/bpf_experimental.h +4
-0+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)NIT: change this to ((cfg) ? 1 : 0) to match
IS_ENABLED()semantics.
Seems reasonable.
Regards,
Boqun
Quoted 14 lines
Thanks,
LeonQuoted 10 lines
tools/testing/selftests/bpf/bpf_experimental.h +2
-1+#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)