From: Cui Jian <cjian720@163.com>
To: Tejun Heo <tj@kernel.org>
Cc: David Vernet <void@manifault.com>,
Andrea Righi <arighi@nvidia.com>,
Changwoo Min <changwoo@igalia.com>,
sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org,
Cui Jian <cjian720@163.com>
Subject: [PATCH] sched_ext: Fix stale errno in scx_sub_enable_workfn()
Date: Sun, 19 Jul 2026 04:17:13 +0800 [thread overview]
Message-ID: <20260718201713.17890-1-cjian720@163.com> (raw)
scx_sub_enable_workfn() drops the return value of validate_ops().
When validate_ops() fails, the function jumps to err_disable with
ret still holding 0 from the previous call, so the fallback error
added by commit db4e9defd2e8 ("sched_ext: Record an error on
errno-only sub-enable failure") reports "scx_sub_enable() failed
(0)".
This is currently harmless because validate_ops() records its own
scx_error() first and the first error wins, but it leaves the
fallback broken for this path. Save the return value into ret,
like scx_root_enable_workfn() already does.
The nesting depth check and the cgroup online check also reach
err_disable without setting ret. Set -EINVAL and -ENODEV there so
the fallback always reports a real errno.
Signed-off-by: Cui Jian <cjian720@163.com>
---
kernel/sched/ext/ext.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index e3fa7b2fac9d..e623d6375f66 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -7559,6 +7559,7 @@ static void scx_sub_enable_workfn(struct kthread_work *work)
if (sch->level >= SCX_SUB_MAX_DEPTH) {
scx_error(sch, "max nesting depth %d violated",
SCX_SUB_MAX_DEPTH);
+ ret = -EINVAL;
goto err_disable;
}
@@ -7580,7 +7581,8 @@ static void scx_sub_enable_workfn(struct kthread_work *work)
if (ret)
goto err_disable;
- if (validate_ops(sch, ops))
+ ret = validate_ops(sch, ops);
+ if (ret)
goto err_disable;
struct scx_sub_attach_args sub_attach_args = {
@@ -7613,6 +7615,7 @@ static void scx_sub_enable_workfn(struct kthread_work *work)
set_cgroup_sched(sch_cgroup(sch), sch);
if (!(cgrp->self.flags & CSS_ONLINE)) {
scx_error(sch, "cgroup is not online");
+ ret = -ENODEV;
goto err_unlock_and_disable;
}
base-commit: 1229e2e57a5c2980ccd457b9b53ea0eed5a22ab3
--
2.34.1
next reply other threads:[~2026-07-18 20:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-18 20:17 Cui Jian [this message]
2026-07-21 17:32 ` Andrea Righi
2026-07-22 10:03 ` [PATCH v2] " Cui Jian
2026-07-22 13:38 ` Andrea Righi
2026-07-22 18:35 ` Tejun Heo
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=20260718201713.17890-1-cjian720@163.com \
--to=cjian720@163.com \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®