Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/core: Fix priority checking for DL server picks

In core scheduling, a DL server pick (which is CFS task) should be
given higher priority than tasks in other classes.

Not doing so causes CFS starvation. A kselftest is added later to
demonstrate this. A CFS task that is competing with RT tasks can
be completely starved without this and the DL server's boosting
completely ignored.

Fix these problems.

Reported-by: Suleiman Souhlal <suleiman@google.com>
Signed-off-by: "Joel Fernandes (Google)" <joel@joelfernandes.org>
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vineeth Pillai <vineeth@bitbyteword.org>
Tested-by: Juri Lelli <juri.lelli@redhat.com>
Link: https://lore.kernel.org/r/48b78521d86f3b33c24994d843c1aad6b987dda9.1716811044.git.bristot@kernel.org

authored by

Joel Fernandes (Google) and committed by
Peter Zijlstra
4b26cfdd d741f297

+21 -2
+21 -2
kernel/sched/core.c
··· 163 163 if (p->sched_class == &stop_sched_class) /* trumps deadline */ 164 164 return -2; 165 165 166 + if (p->dl_server) 167 + return -1; /* deadline */ 168 + 166 169 if (rt_prio(p->prio)) /* includes deadline */ 167 170 return p->prio; /* [-1, 99] */ 168 171 ··· 195 192 if (-pb < -pa) 196 193 return false; 197 194 198 - if (pa == -1) /* dl_prio() doesn't work because of stop_class above */ 199 - return !dl_time_before(a->dl.deadline, b->dl.deadline); 195 + if (pa == -1) { /* dl_prio() doesn't work because of stop_class above */ 196 + const struct sched_dl_entity *a_dl, *b_dl; 197 + 198 + a_dl = &a->dl; 199 + /* 200 + * Since,'a' and 'b' can be CFS tasks served by DL server, 201 + * __task_prio() can return -1 (for DL) even for those. In that 202 + * case, get to the dl_server's DL entity. 203 + */ 204 + if (a->dl_server) 205 + a_dl = a->dl_server; 206 + 207 + b_dl = &b->dl; 208 + if (b->dl_server) 209 + b_dl = b->dl_server; 210 + 211 + return !dl_time_before(a_dl->deadline, b_dl->deadline); 212 + } 200 213 201 214 if (pa == MAX_RT_PRIO + MAX_NICE) /* fair */ 202 215 return cfs_prio_less(a, b, in_fi);