History

sched_ext: Report scx_link_sched() failures inline

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.

Tejun Heo committed 3 months ago

Commit ee7aece1 parent 3c4b3801 file · +9 −20Browse files

Unified · Split

kernel/sched/ext/ext.c+9−20
@@ -5975,31 +5975,30 @@ static void refresh_watchdog(void) · 5974 unmodified lines
59755975
59765976 s32 scx_link_sched(struct scx_sched *sch)
59775977 {
5978− const char *err_msg = "";
5979− s32 ret = 0;
5980−
59815978 scoped_guard(raw_spinlock_irqsave, &scx_bypass_lock) /* for the parent bypass check */
59825979 scoped_guard(raw_spinlock, &scx_sched_lock) {
59835980 #ifdef CONFIG_EXT_SUB_SCHED
59845981 struct scx_sched *parent = scx_parent(sch);
59855982
59865983 if (parent) {
5984+ s32 ret;
5985+
59875986 /*
59885987 * Bypass state is spread across per-cpu flags and a
59895988 * depth count, so inheriting it is tricky and has no
59905989 * valid use case. Refuse it.
59915990 */
59925991 if (READ_ONCE(parent->bypass_depth)) {
5993− err_msg = "parent bypassing";
5994− ret = -EBUSY;
5995− break;
5992+ scx_error(sch, "parent bypassing (%d)", -EBUSY);
5993+ return -EBUSY;
59965994 }
59975995
59985996 ret = rhashtable_lookup_insert_fast(&scx_sched_hash,
59995997 &sch->hash_node, scx_sched_hash_params);
60005998 if (ret) {
6001− err_msg = "failed to insert into scx_sched_hash";
6002− break;
5999+ scx_error(sch, "failed to insert into scx_sched_hash (%d)",
6000+ ret);
6001+ return ret;
60036002 }
60046003
60056004 list_add_tail_rcu(&sch->sibling, &parent->children);
@@ -6014,9 +6013,8 @@ s32 scx_link_sched(struct scx_sched *sch) · 8 unmodified lines
60146013 rhashtable_remove_fast(&scx_sched_hash, &sch->hash_node,
60156014 scx_sched_hash_params);
60166015 list_del_rcu(&sch->sibling);
6017− err_msg = "parent disabled";
6018− ret = -ENOENT;
6019− break;
6016+ scx_error(sch, "parent disabled (%d)", -ENOENT);
6017+ return -ENOENT;
60206018 }
60216019
60226020 sch->linked = true;
@@ -6026,15 +6024,6 @@ s32 scx_link_sched(struct scx_sched *sch) · 3 unmodified lines
60266024 list_add_tail_rcu(&sch->all, &scx_sched_all);
60276025 }
60286026
6029− /*
6030− * scx_error() takes scx_sched_lock via scx_claim_exit(), so it must run after
6031− * the guard above is released.
6032− */
6033− if (ret) {
6034− scx_error(sch, "%s (%d)", err_msg, ret);
6035− return ret;
6036− }
6037−
60386027 refresh_watchdog();
60396028 return 0;
60406029 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t