tools/sched_ext/include/scx/compat.bpf.h | 2 ++ 1 file changed, 2 insertions(+)
From: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
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.
Fixes: 98d709cba319 ("sched_ext: Implement SCX_ENQ_IMMED")
Signed-off-by: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
---
tools/sched_ext/include/scx/compat.bpf.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/sched_ext/include/scx/compat.bpf.h b/tools/sched_ext/include/scx/compat.bpf.h
index 654b566bd94a..52e6fb9ea211 100644
--- a/tools/sched_ext/include/scx/compat.bpf.h
+++ b/tools/sched_ext/include/scx/compat.bpf.h
@@ -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
--
2.43.0
Hello, 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
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.
Fixes: 6bf36c68b0a2 ("tools/sched_ext: Regenerate autogen enum headers")
Link: https://lore.kernel.org/r/20260326100313.338388-1-zhaomzhao@126.com
Reported-by: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
Signed-off-by: Tejun Heo <tj@kernel.org>
---
tools/sched_ext/include/scx/compat.bpf.h | 5 -----
1 file changed, 5 deletions(-)
diff --git a/tools/sched_ext/include/scx/compat.bpf.h b/tools/sched_ext/include/scx/compat.bpf.h
index 654b566bd94a..8977b5a2caa1 100644
--- a/tools/sched_ext/include/scx/compat.bpf.h
+++ b/tools/sched_ext/include/scx/compat.bpf.h
@@ -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().
--
2.53.0
© 2016 - 2026 Red Hat, Inc.