Commit bf61759d authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'sched_ext-for-6.16-rc6-fixes' of...

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
parents c64004df 06efc9fe
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -1272,6 +1272,7 @@ static inline struct rq *scx_locked_rq(void)

#define SCX_CALL_OP(sch, mask, op, rq, args...)					\
do {										\
	if (rq)									\
		update_locked_rq(rq);						\
	if (mask) {								\
		scx_kf_allow(mask);						\
@@ -1280,6 +1281,7 @@ do { \
	} else {								\
		(sch)->ops.op(args);						\
	}									\
	if (rq)									\
		update_locked_rq(NULL);						\
} while (0)

@@ -1287,6 +1289,7 @@ do { \
({										\
	__typeof__((sch)->ops.op(args)) __ret;					\
										\
	if (rq)									\
		update_locked_rq(rq);						\
	if (mask) {								\
		scx_kf_allow(mask);						\
@@ -1295,6 +1298,7 @@ do { \
	} else {								\
		__ret = (sch)->ops.op(args);					\
	}									\
	if (rq)									\
		update_locked_rq(NULL);						\
	__ret;									\
})
+1 −1
Original line number Diff line number Diff line
@@ -903,7 +903,7 @@ s32 select_cpu_from_kfunc(struct task_struct *p, s32 prev_cpu, u64 wake_flags,
	 * selection optimizations and simply check whether the previously
	 * used CPU is idle and within the allowed cpumask.
	 */
	if (p->nr_cpus_allowed == 1) {
	if (p->nr_cpus_allowed == 1 || is_migration_disabled(p)) {
		if (cpumask_test_cpu(prev_cpu, allowed ?: p->cpus_ptr) &&
		    scx_idle_test_and_clear_cpu(prev_cpu))
			cpu = prev_cpu;
+8 −0
Original line number Diff line number Diff line
@@ -22,6 +22,14 @@ static enum scx_test_status run(void *ctx)
		struct bpf_link *link;
		char buf[16];

		/*
		 * On single-CPU systems, ops.select_cpu() is never
		 * invoked, so skip this test to avoid getting stuck
		 * indefinitely.
		 */
		if (tc == EXIT_SELECT_CPU && libbpf_num_possible_cpus() == 1)
			continue;

		skel = exit__open();
		SCX_ENUM_INIT(skel);
		skel->rodata->exit_point = tc;