Skip to content

Commit bf61759

Browse files
committed
Merge tag 'sched_ext-for-6.16-rc6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext
Pull sched_ext fixes from Tejun Heo: - Fix handling of migration disabled tasks in default idle selection - update_locked_rq() called __this_cpu_write() spuriously with NULL when @rq was not locked. As the writes were spurious, it didn't break anything directly. However, the function could be called in a preemptible leading to a context warning in __this_cpu_write(). Skip the spurious NULL writes. - Selftest fix on UP * tag 'sched_ext-for-6.16-rc6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext: sched_ext: idle: Handle migration-disabled tasks in idle selection sched/ext: Prevent update_locked_rq() calls with NULL rq selftests/sched_ext: Fix exit selftest hang on UP
2 parents c64004d + 06efc9f commit bf61759

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

kernel/sched/ext.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,30 +1272,34 @@ static inline struct rq *scx_locked_rq(void)
12721272

12731273
#define SCX_CALL_OP(sch, mask, op, rq, args...) \
12741274
do { \
1275-
update_locked_rq(rq); \
1275+
if (rq) \
1276+
update_locked_rq(rq); \
12761277
if (mask) { \
12771278
scx_kf_allow(mask); \
12781279
(sch)->ops.op(args); \
12791280
scx_kf_disallow(mask); \
12801281
} else { \
12811282
(sch)->ops.op(args); \
12821283
} \
1283-
update_locked_rq(NULL); \
1284+
if (rq) \
1285+
update_locked_rq(NULL); \
12841286
} while (0)
12851287

12861288
#define SCX_CALL_OP_RET(sch, mask, op, rq, args...) \
12871289
({ \
12881290
__typeof__((sch)->ops.op(args)) __ret; \
12891291
\
1290-
update_locked_rq(rq); \
1292+
if (rq) \
1293+
update_locked_rq(rq); \
12911294
if (mask) { \
12921295
scx_kf_allow(mask); \
12931296
__ret = (sch)->ops.op(args); \
12941297
scx_kf_disallow(mask); \
12951298
} else { \
12961299
__ret = (sch)->ops.op(args); \
12971300
} \
1298-
update_locked_rq(NULL); \
1301+
if (rq) \
1302+
update_locked_rq(NULL); \
12991303
__ret; \
13001304
})
13011305

kernel/sched/ext_idle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ s32 select_cpu_from_kfunc(struct task_struct *p, s32 prev_cpu, u64 wake_flags,
903903
* selection optimizations and simply check whether the previously
904904
* used CPU is idle and within the allowed cpumask.
905905
*/
906-
if (p->nr_cpus_allowed == 1) {
906+
if (p->nr_cpus_allowed == 1 || is_migration_disabled(p)) {
907907
if (cpumask_test_cpu(prev_cpu, allowed ?: p->cpus_ptr) &&
908908
scx_idle_test_and_clear_cpu(prev_cpu))
909909
cpu = prev_cpu;

tools/testing/selftests/sched_ext/exit.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ static enum scx_test_status run(void *ctx)
2222
struct bpf_link *link;
2323
char buf[16];
2424

25+
/*
26+
* On single-CPU systems, ops.select_cpu() is never
27+
* invoked, so skip this test to avoid getting stuck
28+
* indefinitely.
29+
*/
30+
if (tc == EXIT_SELECT_CPU && libbpf_num_possible_cpus() == 1)
31+
continue;
32+
2533
skel = exit__open();
2634
SCX_ENUM_INIT(skel);
2735
skel->rodata->exit_point = tc;

0 commit comments

Comments
 (0)