All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched_ext: Delete sub-scheduler kobjects before releasing scx_enable_mutex
@ 2026-09-01 10:22 Qiurong Fang
  2026-09-01 19:56 ` Tejun Heo
  2026-09-01 20:17 ` Andrea Righi
  0 siblings, 2 replies; 6+ messages in thread
From: Qiurong Fang @ 2026-09-01 10:22 UTC (permalink / raw)
  To: tj; +Cc: void, arighi, changwoo, sched-ext

From: fangqiurong <fangqiurong@kylinos.cn>

The sub-scheduler disable path deletes the scheduler's kobjects after
releasing scx_enable_mutex, while the root path deletes them before
releasing it. A concurrent enable on the same cgroup can therefore hit
kobject_add() with the same "sub-%llu" name still in the hierarchy and
fail with -EEXIST, tearing down an otherwise healthy scheduler.

Move the two kobject_del() calls above mutex_unlock() to match the root
path.

Fixes: ebeca1f930ea ("sched_ext: Introduce cgroup sub-sched support")
Signed-off-by: fangqiurong <fangqiurong@kylinos.cn>
---
 kernel/sched/ext/sub.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/ext/sub.c b/kernel/sched/ext/sub.c
index a17d84db93bd..1923e3023bff 100644
--- a/kernel/sched/ext/sub.c
+++ b/kernel/sched/ext/sub.c
@@ -1631,6 +1631,12 @@ void scx_sub_disable(struct scx_sched *sch)
 
 	scx_unlink_sched(sch);
 
+	if (sch->sub_kset)
+		kobject_del(&sch->sub_kset->kobj);
+	/* not added if enable failed before scx_sched_sysfs_add() */
+	if (sch->kobj.state_in_sysfs)
+		kobject_del(&sch->kobj);
+
 	mutex_unlock(&scx_enable_mutex);
 
 	/*
@@ -1661,12 +1667,6 @@ void scx_sub_disable(struct scx_sched *sch)
 	 */
 	WRITE_ONCE(sch->dead, true);
 	synchronize_rcu();
-
-	if (sch->sub_kset)
-		kobject_del(&sch->sub_kset->kobj);
-	/* not added if enable failed before scx_sched_sysfs_add() */
-	if (sch->kobj.state_in_sysfs)
-		kobject_del(&sch->kobj);
 }
 
 /* verify that a scheduler can be attached to @cgrp and return the parent */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* Re: [PATCH] sched_ext: Delete sub-scheduler kobjects before releasing scx_enable_mutex
@ 2026-09-02  6:20 Qiurong Fang
  0 siblings, 0 replies; 6+ messages in thread
From: Qiurong Fang @ 2026-09-02  6:20 UTC (permalink / raw)
  To: tj; +Cc: arighi, sched-ext

Hello Tejun,

Understood - it's the expected behavior. Withdrawing the patch.

Thanks for the explanation.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-02  6:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-01 10:22 [PATCH] sched_ext: Delete sub-scheduler kobjects before releasing scx_enable_mutex Qiurong Fang
2026-09-01 19:56 ` Tejun Heo
2026-09-02  3:22   ` Qiurong Fang
2026-09-02  6:02     ` Tejun Heo
2026-09-01 20:17 ` Andrea Righi
  -- strict thread matches above, loose matches on Subject: below --
2026-09-02  6:20 Qiurong Fang

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.