Skip to content

Commit 664e78f

Browse files
htejungregkh
authored andcommitted
sched_ext: Don't kick CPUs running higher classes
commit a9c1fbb upstream. When a sched_ext scheduler tries to kick a CPU, the CPU may be running a higher class task. sched_ext has no control over such CPUs. A sched_ext scheduler couldn't have expected to get access to the CPU after kicking it anyway. Skip kicking when the target CPU is running a higher class. Reviewed-by: Andrea Righi <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Christian Loehle <christian.loehle@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent edb9fab commit 664e78f

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

kernel/sched/ext.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5164,18 +5164,23 @@ static bool kick_one_cpu(s32 cpu, struct rq *this_rq, unsigned long *pseqs)
51645164
{
51655165
struct rq *rq = cpu_rq(cpu);
51665166
struct scx_rq *this_scx = &this_rq->scx;
5167+
const struct sched_class *cur_class;
51675168
bool should_wait = false;
51685169
unsigned long flags;
51695170

51705171
raw_spin_rq_lock_irqsave(rq, flags);
5172+
cur_class = rq->curr->sched_class;
51715173

51725174
/*
51735175
* During CPU hotplug, a CPU may depend on kicking itself to make
5174-
* forward progress. Allow kicking self regardless of online state.
5176+
* forward progress. Allow kicking self regardless of online state. If
5177+
* @cpu is running a higher class task, we have no control over @cpu.
5178+
* Skip kicking.
51755179
*/
5176-
if (cpu_online(cpu) || cpu == cpu_of(this_rq)) {
5180+
if ((cpu_online(cpu) || cpu == cpu_of(this_rq)) &&
5181+
!sched_class_above(cur_class, &ext_sched_class)) {
51775182
if (cpumask_test_cpu(cpu, this_scx->cpus_to_preempt)) {
5178-
if (rq->curr->sched_class == &ext_sched_class)
5183+
if (cur_class == &ext_sched_class)
51795184
rq->curr->scx.slice = 0;
51805185
cpumask_clear_cpu(cpu, this_scx->cpus_to_preempt);
51815186
}

0 commit comments

Comments
 (0)