* [PATCH 1/1] sched_ext: Add error logging for dsq creation failures
@ 2026-01-07 6:28 George Guo
2026-01-07 17:32 ` Emil Tsalapatis
0 siblings, 1 reply; 5+ messages in thread
From: George Guo @ 2026-01-07 6:28 UTC (permalink / raw)
To: tj, void, arighi, changwoo; +Cc: sched-ext, linux-kernel, George Guo
From: George Guo <guodongtai@kylinos.cn>
Add scx_bpf_error() calls when scx_bpf_create_dsq() fails in multiple
schedulers to improve debuggability:
- scx_central.bpf.c: central_init()
- scx_flatcg.bpf.c: fcg_cgroup_init() and fcg_init()
- scx_qmap.bpf.c: qmap_init()
- scx_simple.bpf.c: simple_init()
Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
tools/sched_ext/scx_central.bpf.c | 4 +++-
tools/sched_ext/scx_flatcg.bpf.c | 12 ++++++++++--
tools/sched_ext/scx_qmap.bpf.c | 8 ++++++--
tools/sched_ext/scx_simple.bpf.c | 8 +++++++-
4 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/tools/sched_ext/scx_central.bpf.c b/tools/sched_ext/scx_central.bpf.c
index 55df8b798865..1c2376b75b5d 100644
--- a/tools/sched_ext/scx_central.bpf.c
+++ b/tools/sched_ext/scx_central.bpf.c
@@ -301,8 +301,10 @@ int BPF_STRUCT_OPS_SLEEPABLE(central_init)
int ret;
ret = scx_bpf_create_dsq(FALLBACK_DSQ_ID, -1);
- if (ret)
+ if (ret) {
+ scx_bpf_error("scx_bpf_create_dsq failed (%d)", ret);
return ret;
+ }
timer = bpf_map_lookup_elem(¢ral_timer, &key);
if (!timer)
diff --git a/tools/sched_ext/scx_flatcg.bpf.c b/tools/sched_ext/scx_flatcg.bpf.c
index 2c720e3ecad5..f7830e14b9af 100644
--- a/tools/sched_ext/scx_flatcg.bpf.c
+++ b/tools/sched_ext/scx_flatcg.bpf.c
@@ -842,8 +842,10 @@ int BPF_STRUCT_OPS_SLEEPABLE(fcg_cgroup_init, struct cgroup *cgrp,
* unlikely case that it breaks.
*/
ret = scx_bpf_create_dsq(cgid, -1);
- if (ret)
+ if (ret) {
+ scx_bpf_error("scx_bpf_create_dsq failed (%d)", ret);
return ret;
+ }
cgc = bpf_cgrp_storage_get(&cgrp_ctx, cgrp, 0,
BPF_LOCAL_STORAGE_GET_F_CREATE);
@@ -927,7 +929,13 @@ void BPF_STRUCT_OPS(fcg_cgroup_move, struct task_struct *p,
s32 BPF_STRUCT_OPS_SLEEPABLE(fcg_init)
{
- return scx_bpf_create_dsq(FALLBACK_DSQ, -1);
+ s32 ret;
+
+ ret = scx_bpf_create_dsq(FALLBACK_DSQ, -1);
+ if (ret)
+ scx_bpf_error("scx_bpf_create_dsq failed (%d)", ret);
+
+ return ret;
}
void BPF_STRUCT_OPS(fcg_exit, struct scx_exit_info *ei)
diff --git a/tools/sched_ext/scx_qmap.bpf.c b/tools/sched_ext/scx_qmap.bpf.c
index 3072b593f898..16ed8f867ad9 100644
--- a/tools/sched_ext/scx_qmap.bpf.c
+++ b/tools/sched_ext/scx_qmap.bpf.c
@@ -852,12 +852,16 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(qmap_init)
print_cpus();
ret = scx_bpf_create_dsq(SHARED_DSQ, -1);
- if (ret)
+ if (ret) {
+ scx_bpf_error("scx_bpf_create_dsq failed (%d)", ret);
return ret;
+ }
ret = scx_bpf_create_dsq(HIGHPRI_DSQ, -1);
- if (ret)
+ if (ret) {
+ scx_bpf_error("scx_bpf_create_dsq failed (%d)", ret);
return ret;
+ }
timer = bpf_map_lookup_elem(&monitor_timer, &key);
if (!timer)
diff --git a/tools/sched_ext/scx_simple.bpf.c b/tools/sched_ext/scx_simple.bpf.c
index e6de99dba7db..50e4555459de 100644
--- a/tools/sched_ext/scx_simple.bpf.c
+++ b/tools/sched_ext/scx_simple.bpf.c
@@ -131,7 +131,13 @@ void BPF_STRUCT_OPS(simple_enable, struct task_struct *p)
s32 BPF_STRUCT_OPS_SLEEPABLE(simple_init)
{
- return scx_bpf_create_dsq(SHARED_DSQ, -1);
+ s32 ret;
+
+ ret = scx_bpf_create_dsq(SHARED_DSQ, -1);
+ if (ret)
+ scx_bpf_error("scx_bpf_create_dsq failed (%d)", ret);
+
+ return ret;
}
void BPF_STRUCT_OPS(simple_exit, struct scx_exit_info *ei)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] sched_ext: Add error logging for dsq creation failures
2026-01-07 6:28 [PATCH 1/1] sched_ext: Add error logging for dsq creation failures George Guo
@ 2026-01-07 17:32 ` Emil Tsalapatis
2026-01-08 3:23 ` George Guo
0 siblings, 1 reply; 5+ messages in thread
From: Emil Tsalapatis @ 2026-01-07 17:32 UTC (permalink / raw)
To: George Guo, tj, void, arighi, changwoo
Cc: sched-ext, linux-kernel, George Guo
Hi George,
(sorry for the formatting, my email client has decided not to indent the email)
________________________________________
From: George Guo <dongtai.guo@linux.dev>
Sent: Wednesday, January 7, 2026 1:28 AM
To: tj@kernel.org; void@manifault.com; arighi@nvidia.com; changwoo@igalia.com
Cc: sched-ext@lists.linux.dev; linux-kernel@vger.kernel.org; George Guo
Subject: [PATCH 1/1] sched_ext: Add error logging for dsq creation failures
From: George Guo <guodongtai@kylinos.cn>
Add scx_bpf_error() calls when scx_bpf_create_dsq() fails in multiple
schedulers to improve debuggability:
- scx_central.bpf.c: central_init()
- scx_flatcg.bpf.c: fcg_cgroup_init() and fcg_init()
- scx_qmap.bpf.c: qmap_init()
- scx_simple.bpf.c: simple_init()
Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
While the change looks correct, is there any benefit to it?
- Failing to create a dsq will already cause init() to fail with the error code
from the failed call. In scx_simple in particular, the change adds no new
info because the function amounts to a single scx_bpf_create_dsq() call.
- Regressions to scx_bpf_dsq_create() from kernel-side (as opposed to
BPF scheduler-side) changes will be caught by the selftests.
Not opposed to it, just curious what the advantages are.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] sched_ext: Add error logging for dsq creation failures
2026-01-07 17:32 ` Emil Tsalapatis
@ 2026-01-08 3:23 ` George Guo
2026-01-08 6:25 ` Andrea Righi
0 siblings, 1 reply; 5+ messages in thread
From: George Guo @ 2026-01-08 3:23 UTC (permalink / raw)
To: etsal
Cc: arighi, changwoo, dongtai.guo, guodongtai, linux-kernel,
sched-ext, tj, void
Hi Etsal,
Thanks for reviewing!
> While the change looks correct, is there any benefit to it?
Yes, definitely. I found this issue while adding sched_ext support for
LoongArch. When scx_bpf_create_dsq() failed during my development, there
were no error messages at all, which made debugging difficult.
Specifically:
1. The failure was silent - no log, no error message in dmesg
2. I had to add bpf_printk() temporarily to confirm it was dsq creation failing
So the benefit is improved debuggability and faster issue diagnosis.
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] sched_ext: Add error logging for dsq creation failures
2026-01-08 3:23 ` George Guo
@ 2026-01-08 6:25 ` Andrea Righi
2026-01-09 10:02 ` George Guo
0 siblings, 1 reply; 5+ messages in thread
From: Andrea Righi @ 2026-01-08 6:25 UTC (permalink / raw)
To: George Guo; +Cc: etsal, changwoo, guodongtai, linux-kernel, sched-ext, tj, void
Hi George,
On Thu, Jan 08, 2026 at 11:23:28AM +0800, George Guo wrote:
> Hi Etsal,
> Thanks for reviewing!
>
> > While the change looks correct, is there any benefit to it?
> Yes, definitely. I found this issue while adding sched_ext support for
> LoongArch. When scx_bpf_create_dsq() failed during my development, there
> were no error messages at all, which made debugging difficult.
>
> Specifically:
> 1. The failure was silent - no log, no error message in dmesg
Which kernel is that?
In theory you should get a clear message in dmesg. For example, if I try to
create an invalid DSQ in scx_simple I get this in dmesg:
[690301.673313] sched_ext: BPF scheduler "simple" disabled (runtime error)
[690301.673324] sched_ext: simple: ops.init() failed (-22)
[690301.673327] scx_enable.isra.0+0xc8b/0x11f0
[690301.673343] bpf_struct_ops_link_create+0x141/0x1b0
[690301.673352] __sys_bpf+0x1c0c/0x2de0
[690301.673357] __x64_sys_bpf+0x21/0x30
[690301.673359] do_syscall_64+0x81/0x820
[690301.673368] entry_SYSCALL_64_after_hwframe+0x76/0x7e
And in stdout:
DEBUG DUMP
================================================================================
scx_simple[364999] triggered exit kind 1024:
runtime error (ops.init() failed (-22))
Backtrace:
scx_enable.isra.0+0xc8b/0x11f0
bpf_struct_ops_link_create+0x141/0x1b0
__sys_bpf+0x1c0c/0x2de0
__x64_sys_bpf+0x21/0x30
do_syscall_64+0x81/0x820
entry_SYSCALL_64_after_hwframe+0x76/0x7e
CPU states
----------
CPU 2 : nr_run=0 flags=0x1 cpu_rel=0 ops_qseq=87907495 pnt_seq=66861592
curr=scx_simple[364999] class=fair_sched_class
CPU 3 : nr_run=0 flags=0x1 cpu_rel=0 ops_qseq=85461608 pnt_seq=64229201
curr=pacman[364201] class=fair_sched_class
Event counters
--------------
SCX_EV_SELECT_CPU_FALLBACK: 0
SCX_EV_DISPATCH_LOCAL_DSQ_OFFLINE: 0
SCX_EV_DISPATCH_KEEP_LAST: 0
SCX_EV_ENQ_SKIP_EXITING: 0
SCX_EV_ENQ_SKIP_MIGRATION_DISABLED: 0
SCX_EV_REFILL_SLICE_DFL: 0
SCX_EV_BYPASS_DURATION: 0
SCX_EV_BYPASS_DISPATCH: 0
SCX_EV_BYPASS_ACTIVATE: 0
================================================================================
EXIT: runtime error (ops.init() failed (-22))
> 2. I had to add bpf_printk() temporarily to confirm it was dsq creation failing
>
> So the benefit is improved debuggability and faster issue diagnosis.
>
> Thanks!
>
Thanks,
-Andrea
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] sched_ext: Add error logging for dsq creation failures
2026-01-08 6:25 ` Andrea Righi
@ 2026-01-09 10:02 ` George Guo
0 siblings, 0 replies; 5+ messages in thread
From: George Guo @ 2026-01-09 10:02 UTC (permalink / raw)
To: arighi
Cc: changwoo, dongtai.guo, etsal, guodongtai, linux-kernel,
sched-ext, tj, void
Hi Andrea,
I got the similar dmesg too.
It seems that it's not necessry in scx_simple.bpf.c indeed.
I will send v2 later for your review.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-01-09 10:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-07 6:28 [PATCH 1/1] sched_ext: Add error logging for dsq creation failures George Guo
2026-01-07 17:32 ` Emil Tsalapatis
2026-01-08 3:23 ` George Guo
2026-01-08 6:25 ` Andrea Righi
2026-01-09 10:02 ` George Guo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome