Skip to content

Commit d4ac164

Browse files
yu-chen-surfPeter Zijlstra
authored andcommitted
sched/eevdf: Fix wakeup-preempt by checking cfs_rq->nr_running
Commit 85e511d ("sched/eevdf: Allow shorter slices to wakeup-preempt") introduced a mechanism that a wakee with shorter slice could preempt the current running task. It also lower the bar for the current task to be preempted, by checking the rq->nr_running instead of cfs_rq->nr_running when the current task has ran out of time slice. But there is a scenario that is problematic. Say, if there is 1 cfs task and 1 rt task, before 85e511d, update_deadline() will not trigger a reschedule, and after 85e511d, since rq->nr_running is 2 and resched is true, a resched_curr() would happen. Some workloads (like the hackbench reported by lkp) do not like over-scheduling. We can see that the preemption rate has been increased by 2.2%: 1.654e+08 +2.2% 1.69e+08 hackbench.time.involuntary_context_switches Restore its previous check criterion. Fixes: 85e511d ("sched/eevdf: Allow shorter slices to wakeup-preempt") Closes: https://lore.kernel.org/oe-lkp/[email protected] Reported-by: kernel test robot <[email protected]> Suggested-by: K Prateek Nayak <[email protected]> Signed-off-by: Chen Yu <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Honglei Wang <[email protected]> Tested-by: K Prateek Nayak <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9b5ce1a commit d4ac164

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/sched/fair.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ static void update_curr(struct cfs_rq *cfs_rq)
12471247

12481248
account_cfs_rq_runtime(cfs_rq, delta_exec);
12491249

1250-
if (rq->nr_running == 1)
1250+
if (cfs_rq->nr_running == 1)
12511251
return;
12521252

12531253
if (resched || did_preempt_short(cfs_rq, curr)) {

0 commit comments

Comments
 (0)