Skip to content

Commit 17d25a3

Browse files
committed
Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler fix from Ingo Molnar: "This contains a single fix that fixes a nohz tick stopping bug when mixed-poliocy SCHED_FIFO and SCHED_RR tasks are present on a runqueue" * 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: nohz/full, sched/rt: Fix missed tick-reenabling bug in sched_can_stop_tick()
2 parents 18fb92c + 2548d54 commit 17d25a3

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

kernel/sched/core.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -596,17 +596,8 @@ bool sched_can_stop_tick(struct rq *rq)
596596
return false;
597597

598598
/*
599-
* FIFO realtime policy runs the highest priority task (after DEADLINE).
600-
* Other runnable tasks are of a lower priority. The scheduler tick
601-
* isn't needed.
602-
*/
603-
fifo_nr_running = rq->rt.rt_nr_running - rq->rt.rr_nr_running;
604-
if (fifo_nr_running)
605-
return true;
606-
607-
/*
608-
* Round-robin realtime tasks time slice with other tasks at the same
609-
* realtime priority.
599+
* If there are more than one RR tasks, we need the tick to effect the
600+
* actual RR behaviour.
610601
*/
611602
if (rq->rt.rr_nr_running) {
612603
if (rq->rt.rr_nr_running == 1)
@@ -615,8 +606,20 @@ bool sched_can_stop_tick(struct rq *rq)
615606
return false;
616607
}
617608

618-
/* Normal multitasking need periodic preemption checks */
619-
if (rq->cfs.nr_running > 1)
609+
/*
610+
* If there's no RR tasks, but FIFO tasks, we can skip the tick, no
611+
* forced preemption between FIFO tasks.
612+
*/
613+
fifo_nr_running = rq->rt.rt_nr_running - rq->rt.rr_nr_running;
614+
if (fifo_nr_running)
615+
return true;
616+
617+
/*
618+
* If there are no DL,RR/FIFO tasks, there must only be CFS tasks left;
619+
* if there's more than one we need the tick for involuntary
620+
* preemption.
621+
*/
622+
if (rq->nr_running > 1)
620623
return false;
621624

622625
return true;

0 commit comments

Comments
 (0)