lkml.org 
[lkml]   [2024]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 03/10] sched/core: Fix priority checking for DL server picks
    Date
    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.

    Reviewed-by: Vineeth Pillai <vineeth@bitbyteword.org>
    Reported-by: Suleiman Souhlal <suleiman@google.com>
    Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
    ---
    kernel/sched/core.c | 23 +++++++++++++++++++++--
    1 file changed, 21 insertions(+), 2 deletions(-)

    diff --git a/kernel/sched/core.c b/kernel/sched/core.c
    index 63f41453b79e..0a05caf9d3d7 100644
    --- a/kernel/sched/core.c
    +++ b/kernel/sched/core.c
    @@ -162,6 +162,9 @@ static inline int __task_prio(const struct task_struct *p)
    if (p->sched_class == &stop_sched_class) /* trumps deadline */
    return -2;

    + if (p->dl_server)
    + return -1; /* deadline */
    +
    if (rt_prio(p->prio)) /* includes deadline */
    return p->prio; /* [-1, 99] */

    @@ -191,8 +194,24 @@ static inline bool prio_less(const struct task_struct *a,
    if (-pb < -pa)
    return false;

    - if (pa == -1) /* dl_prio() doesn't work because of stop_class above */
    - return !dl_time_before(a->dl.deadline, b->dl.deadline);
    + if (pa == -1) { /* dl_prio() doesn't work because of stop_class above */
    + const struct sched_dl_entity *a_dl, *b_dl;
    +
    + a_dl = &a->dl;
    + /*
    + * Since,'a' and 'b' can be CFS tasks served by DL server,
    + * __task_prio() can return -1 (for DL) even for those. In that
    + * case, get to the dl_server's DL entity.
    + */
    + if (a->dl_server)
    + a_dl = a->dl_server;
    +
    + b_dl = &b->dl;
    + if (b->dl_server)
    + b_dl = b->dl_server;
    +
    + return !dl_time_before(a_dl->deadline, b_dl->deadline);
    + }

    if (pa == MAX_RT_PRIO + MAX_NICE) /* fair */
    return cfs_prio_less(a, b, in_fi);
    --
    2.34.1

    \
     
     \ /
      Last update: 2024-05-27 15:07    [W:7.218 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site