From: Cheng-Yang Chou <yphbchou0911@gmail.com>
To: sched-ext@lists.linux.dev, Tejun Heo <tj@kernel.org>,
David Vernet <void@manifault.com>,
Andrea Righi <arighi@nvidia.com>,
Changwoo Min <changwoo@igalia.com>
Cc: Ching-Chun Huang <jserv@ccns.ncku.edu.tw>,
Chia-Ping Tsai <chia7712@gmail.com>,
chengyang.chou@mediatek.com,
Cheng-Yang Chou <yphbchou0911@gmail.com>
Subject: [PATCH sched_ext/for-7.4] tools/sched_ext: Skip scx_lib_init_probe() without CONFIG_FUNCTION_TRACER
Date: Mon, 24 Aug 2026 23:50:04 +0800 [thread overview]
Message-ID: <20260824155051.20841-1-yphbchou0911@gmail.com> (raw)
scx_lib_init_probe() is a fentry probe auto-attached by every scheduler
via SCX_OPS_LOAD()/SCX_OPS_ATTACH(). Without CONFIG_FUNCTION_TRACER it
can't attach, and skel__attach()'s all-or-nothing semantics takes the
whole scheduler down.
Skip its autoload when /proc/sys/kernel/ftrace_enabled is absent, and
skip disabled programs in the post-load struct_ops association loop so
it doesn't try to associate a program with no FD. Reproduced and fixed
in vng with a CONFIG_FUNCTION_TRACER=n kernel.
Syncs the fix from https://github.com/sched-ext/scx/pull/3758. As
discussed in GitHub, once we stop supporting pre-6.18 kernels, this
workaround can be removed.
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
---
tools/sched_ext/include/scx/compat.h | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/tools/sched_ext/include/scx/compat.h b/tools/sched_ext/include/scx/compat.h
index 7c12df45fdba..faf608cbed55 100644
--- a/tools/sched_ext/include/scx/compat.h
+++ b/tools/sched_ext/include/scx/compat.h
@@ -361,13 +361,27 @@ static inline void __scx_ops_assoc_prog(struct bpf_program *prog,
}
#endif
+/*
+ * Whether the kernel supports function tracing (CONFIG_FUNCTION_TRACER),
+ * needed for fentry/fexit BPF programs to load or attach.
+ * /proc/sys/kernel/ftrace_enabled only exists when it's compiled in, so its
+ * presence is a cheap proxy.
+ */
+static inline bool __COMPAT_function_tracer_available(void)
+{
+ return access("/proc/sys/kernel/ftrace_enabled", F_OK) == 0;
+}
+
/* See SCX_OPS_OPEN() above for backward-compatibility handling. */
#define SCX_OPS_LOAD(__skel, __ops_name, __scx_name, __uei_name) ({ \
struct bpf_program *__prog; \
UEI_SET_SIZE(__skel, __ops_name, __uei_name); \
+ if (!__COMPAT_function_tracer_available()) \
+ bpf_program__set_autoload((__skel)->progs.scx_lib_init_probe, false); \
SCX_BUG_ON(__scx_name##__load((__skel)), "Failed to load skel"); \
bpf_object__for_each_program(__prog, (__skel)->obj) { \
- if (bpf_program__type(__prog) == BPF_PROG_TYPE_STRUCT_OPS) \
+ if (bpf_program__type(__prog) == BPF_PROG_TYPE_STRUCT_OPS || \
+ !bpf_program__autoload(__prog)) \
continue; \
__scx_ops_assoc_prog(__prog, (__skel)->maps.__ops_name, \
#__ops_name); \
--
2.43.0
next reply other threads:[~2026-08-24 15:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 15:50 Cheng-Yang Chou [this message]
2026-08-24 16:02 ` [PATCH sched_ext/for-7.4] tools/sched_ext: Skip scx_lib_init_probe() without CONFIG_FUNCTION_TRACER sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260824155051.20841-1-yphbchou0911@gmail.com \
--to=yphbchou0911@gmail.com \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=chengyang.chou@mediatek.com \
--cc=chia7712@gmail.com \
--cc=jserv@ccns.ncku.edu.tw \
--cc=sched-ext@lists.linux.dev \
--cc=tj@kernel.org \
--cc=void@manifault.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox