From nobody Wed Dec 31 12:05:03 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6D1F15E5A1 for ; Mon, 27 May 2024 12:07:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716811662; cv=none; b=WGrkARdPQtIeRnRwERsIukPbOoM3m2XEcnKr9sCDl2NmCZe6I2Y6sk1ef3l7UjVc2U99Yp3tXGJGPFewGwOSRsAzqEqdGtroRC6tiJqW3MdQGzYTOEy/CWSoHb+aHHhsAc/vPPIRM/EuPXuTWgCUapJy+MsHhZGhoPSFw6ICxcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716811662; c=relaxed/simple; bh=NDyaoW3Q0zMLZglcicXIeo2NJZBNXM84ySYhq0BL5yo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g3MdB9+PE3umBVfxCBJfZo1vSyCFHNtkGi4xPG6gXHybx0lT2mJLucMKpYRFu7QOSgcZ3KWnGpkNH9J8yTKx3oQ5cXnIf8U5YMTPhOBqyyjHFydse8Xg6ZQddjhUttJXn/U9I4QFO4hrhV77D/A0g695OVwAOvOw+tWh8zXc42c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vPr2yflF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vPr2yflF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A87F4C32789; Mon, 27 May 2024 12:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716811662; bh=NDyaoW3Q0zMLZglcicXIeo2NJZBNXM84ySYhq0BL5yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vPr2yflFqRxoc2GaYKemAj+WW3w2guVJfzqE48MR3fXAcEl1cJ2+30qlA7ZuKuZgV PxRayVXh1XMqTyg65D9nZ7YfbICGl1+Ez29gjR5icOTLg077RVhuepX0IOEiWCQv6N 5fYySXbJtFcZ9wZWgQ51h5reHWplz11AYcMp0fSHZWrph12GjOGTUUNxLlrGiWBXM+ hoje3t+pzPuFqlgDOKJnDsgN5aIkRWoR2y6jdxq+VdIsbdKS7grvfNaL5XZH6sUdQq Dka+SLuJicCz6ncXVz0P2FCypn3eYIWI+w0criGF/ogt2DOohHf3BBdV6YSXllDm/R a9fIvwV6ockcQ== From: Daniel Bristot de Oliveira To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot Cc: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , linux-kernel@vger.kernel.org, Luca Abeni , Tommaso Cucinotta , Thomas Gleixner , Joel Fernandes , Vineeth Pillai , Shuah Khan , bristot@kernel.org, Phil Auld , Suleiman Souhlal , Youssef Esmat Subject: [PATCH V7 7/9] sched/core: Fix priority checking for DL server picks Date: Mon, 27 May 2024 14:06:53 +0200 Message-ID: <48b78521d86f3b33c24994d843c1aad6b987dda9.1716811044.git.bristot@kernel.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Joel Fernandes (Google)" 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 Reported-by: Suleiman Souhlal Signed-off-by: Joel Fernandes (Google) Signed-off-by: Daniel Bristot de Oliveira --- 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 53f0470a1d0a..01336277eac9 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 =3D=3D &stop_sched_class) /* trumps deadline */ return -2; =20 + if (p->dl_server) + return -1; /* deadline */ + if (rt_prio(p->prio)) /* includes deadline */ return p->prio; /* [-1, 99] */ =20 @@ -191,8 +194,24 @@ static inline bool prio_less(const struct task_struct = *a, if (-pb < -pa) return false; =20 - if (pa =3D=3D -1) /* dl_prio() doesn't work because of stop_class above */ - return !dl_time_before(a->dl.deadline, b->dl.deadline); + if (pa =3D=3D -1) { /* dl_prio() doesn't work because of stop_class above= */ + const struct sched_dl_entity *a_dl, *b_dl; + + a_dl =3D &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 =3D a->dl_server; + + b_dl =3D &b->dl; + if (b->dl_server) + b_dl =3D b->dl_server; + + return !dl_time_before(a_dl->deadline, b_dl->deadline); + } =20 if (pa =3D=3D MAX_RT_PRIO + MAX_NICE) /* fair */ return cfs_prio_less(a, b, in_fi); --=20 2.45.1