From: Tejun Heo <tj@kernel.org>
To: David Vernet <void@manifault.com>,
Andrea Righi <arighi@nvidia.com>,
Changwoo Min <changwoo@igalia.com>
Cc: sched-ext@lists.linux.dev, Emil Tsalapatis <emil@etsalapatis.com>,
linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>
Subject: [PATCH 5/5] sched_ext: Report scx_link_sched() failures inline
Date: Fri, 24 Jul 2026 14:50:19 -1000 [thread overview]
Message-ID: <20260725005019.1297049-6-tj@kernel.org> (raw)
In-Reply-To: <20260725005019.1297049-1-tj@kernel.org>
scx_link_sched() carries each failure out of the locked section through
err_msg and ret because scx_error() used to take scx_sched_lock and couldn't
be called under it. That restriction is gone, so report each failure at the
site it's detected and return directly. The scx_error() here claims the exit
on the sched being linked, which has no descendants yet, and the locked
propagation walk is deferred, so nothing reacquires scx_sched_lock inline.
Signed-off-by: Tejun Heo <tj@kernel.org>
---
kernel/sched/ext/ext.c | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index 9f5729c2c5e2..6ed9818491f3 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -5965,31 +5965,30 @@ static void refresh_watchdog(void)
s32 scx_link_sched(struct scx_sched *sch)
{
- const char *err_msg = "";
- s32 ret = 0;
-
scoped_guard(raw_spinlock_irqsave, &scx_bypass_lock) /* for the parent bypass check */
scoped_guard(raw_spinlock, &scx_sched_lock) {
#ifdef CONFIG_EXT_SUB_SCHED
struct scx_sched *parent = scx_parent(sch);
if (parent) {
+ s32 ret;
+
/*
* Bypass state is spread across per-cpu flags and a
* depth count, so inheriting it is tricky and has no
* valid use case. Refuse it.
*/
if (READ_ONCE(parent->bypass_depth)) {
- err_msg = "parent bypassing";
- ret = -EBUSY;
- break;
+ scx_error(sch, "parent bypassing (%d)", -EBUSY);
+ return -EBUSY;
}
ret = rhashtable_lookup_insert_fast(&scx_sched_hash,
&sch->hash_node, scx_sched_hash_params);
if (ret) {
- err_msg = "failed to insert into scx_sched_hash";
- break;
+ scx_error(sch, "failed to insert into scx_sched_hash (%d)",
+ ret);
+ return ret;
}
list_add_tail_rcu(&sch->sibling, &parent->children);
@@ -6004,9 +6003,8 @@ s32 scx_link_sched(struct scx_sched *sch)
rhashtable_remove_fast(&scx_sched_hash, &sch->hash_node,
scx_sched_hash_params);
list_del_rcu(&sch->sibling);
- err_msg = "parent disabled";
- ret = -ENOENT;
- break;
+ scx_error(sch, "parent disabled (%d)", -ENOENT);
+ return -ENOENT;
}
sch->linked = true;
@@ -6016,15 +6014,6 @@ s32 scx_link_sched(struct scx_sched *sch)
list_add_tail_rcu(&sch->all, &scx_sched_all);
}
- /*
- * scx_error() takes scx_sched_lock via scx_claim_exit(), so it must run after
- * the guard above is released.
- */
- if (ret) {
- scx_error(sch, "%s (%d)", err_msg, ret);
- return ret;
- }
-
refresh_watchdog();
return 0;
}
--
2.55.0
prev parent reply other threads:[~2026-07-25 0:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 0:50 [PATCHSET sched_ext/for-7.3] sched_ext: NMI-safe exit handling Tejun Heo
2026-07-25 0:50 ` [PATCH 1/5] sched_ext: Make exit claiming lock-free Tejun Heo
2026-07-25 0:50 ` [PATCH 2/5] sched_ext: Format bstr exit messages after claiming the exit Tejun Heo
2026-07-25 0:50 ` [PATCH 3/5] sched_ext: Report NMI kicks with scx_error() Tejun Heo
2026-07-25 0:50 ` [PATCH 4/5] sched_ext: Abort directly from the hardlockup handler Tejun Heo
2026-07-25 0:50 ` Tejun Heo [this message]
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=20260725005019.1297049-6-tj@kernel.org \
--to=tj@kernel.org \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=emil@etsalapatis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sched-ext@lists.linux.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.