tools/sched_ext: avoid redefining SCX_ENQ_IMMED
PATCH 1/1 tools/sched_ext: avoid redefining SCX_ENQ_IMMED
From: Zhao Mengmeng <[email protected]>
Newer kernels generate SCX_ENQ_IMMED from enums.autogen.bpf.h, while compat.bpf.h still defines a fallback macro unconditionally. Including both headers then triggers a macro redefinition warning when building BPF schedulers.
warning: 'SCX_ENQ_IMMED' macro redefined [-Wmacro-redefined]
Fix it by defining the compat fallback only when HAVE_SCX_ENQ_IMMED is absent.
--- tools/sched_ext/include/scx/compat.bpf.h | 2 ++ 1 file changed, 2 insertions(+)
tools/sched_ext/include/scx/compat.bpf.h +2 -0
@@ -425,7 +425,9 @@ static inline void scx_bpf_dsq_reenq(u64 dsq_id, u64 reenq_flags)/* * v7.1: %SCX_ENQ_IMMED. */ +#ifndef HAVE_SCX_ENQ_IMMED #define SCX_ENQ_IMMED __COMPAT_ENUM_OR_ZERO(enum scx_enq_flags, SCX_ENQ_IMMED) +#endif /* * Define sched_ext_ops. This may be expanded to define multiple variants for
Signature · 1 line
2.43.0
Tejun Heo
reviewerPATCH 1/1 tools/sched_ext: Remove redundant SCX_ENQ_IMMED compat definition
compat.bpf.h defined a fallback SCX_ENQ_IMMED macro using __COMPAT_ENUM_OR_ZERO(). After 6bf36c68b0a2 ("tools/sched_ext:
Regenerate autogen enum headers") added SCX_ENQ_IMMED to the autogen headers, including both triggers -Wmacro-redefined warnings.
The autogen definition through const volatile __weak already resolves to 0 on older kernels, providing the same backward compatibility. Remove the now-redundant compat fallback.
--- tools/sched_ext/include/scx/compat.bpf.h | 5 ----- 1 file changed, 5 deletions(-)
tools/sched_ext/include/scx/compat.bpf.h +0 -5
@@ -422,11 +422,6 @@ static inline void scx_bpf_dsq_reenq(u64 dsq_id, u64 reenq_flags)scx_bpf_error ("kernel too old to reenqueue foreign local or user DSQs" ); } -/* -* v7.1: %SCX_ENQ_IMMED. -*/ -#define SCX_ENQ_IMMED __COMPAT_ENUM_OR_ZERO(enum scx_enq_flags, SCX_ENQ_IMMED) -/* * Define sched_ext_ops. This may be expanded to define multiple variants for * backward compatibility. See compat.h::SCX_OPS_LOAD/ATTACH().
Signature · 1 line
2.53.0
Re: [PATCH sched_ext/for-7.1] tools/sched_ext: Remove redundant SCX_ENQ_IMMED compat definition
Applied to sched_ext/for-7.1.
Thanks.
--
tejun
Tejun Heo
reviewerHello,
The compat fallback isn't necessary anymore as the autogen definition through const volatile __weak already resolves to 0 on older kernels. I just removed it instead.
Thanks.
--
tejun