On 2026/10/2 18:29, Boqun Feng wrote:
> 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 <[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.

> ---
> 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(-)
> 
> 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)

NIT: change this to ((cfg) ? 1 : 0) to match IS_ENABLED() semantics.

Thanks,
Leon

> +
>  #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)


Reply via email to