From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380581; b=0deKq7DeunldIr2F6ZD4N11W7lzBc6eWhThue6a1XqV3sRnmftumAjn9CcT72Yt6c8wE tI0XIjbInz5AOHlOGiTSHW5OtyxKVoxkx3UI0tsKjMmwCq8xGV2ufAuNvJpkUtKbERUEc AQIkH05dZBd5knf2xJlqVhxnl1F9eX5WyR7/dZZtFVt3LwYFpEKytb5nYUZWiaH8kBvas BtHCNSPXVVkjTFeGl6v5abdJdo9z5I7quL7kMZlMqaL1id4aeFlhd6YeUTtKujmgw7g72 faZenTEvKtlovNXy/gH0lqT0vdDsJ1RCIgQihcTiNuuGfXGr7j+LUSbmGdTurC9zGlQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380581; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=OvvLGfr79f1+fr0l8DqYzrTRcjCUIKrqasR+GpbClHg=; b=TzcxkLxU/XcEGHP+yfq0ZLN0Qq2Dqpda1ra7O1YdqiqM2TveQo/mHZcqJ9CvNowo3I3O FzGlvVWZKTPSiwgoMsBZFoW39RJ7KEDNahu5JPfiTD1Kph/iZLCI7+01ZcVahnl/O/uER rNSSNKw3NBZW1c1dVStA5Q2cbdExLsIFNRlVuEyVegFeXkMr2pMWQ4yAaxfznqSO1nGID TAlE4lR0O24Dioeq6EEYKqRLzdfDPdjB/B00FxgV+keqjHjx4vmpJ4OW/ZuT21bQxGjQX LLCKgHSfcATAs0/B7k9CKP8YuifkZtvXJi1Z2BbxOiDeO00BdaL2qSOBPDuzrh93r+A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=oz7SmyDo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDD51606A681; Fri, 4 Dec 2026 10:36:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=oz7SmyDo Received: by smtp.kernel.org (Postfix) with ESMTPSA id 511F01F000CE; Fri, 4 Dec 2026 10:36:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380581; bh=OvvLGfr79f1+fr0l8DqYzrTRcjCUIKrqasR+GpbClHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oz7SmyDohAK62cjCBIVxNL6IqSpT4jqj3iR8gqN3VFKDFUr02N//XXdbuCvmjHtyh DLE22kelJAYBxGGaqzpNXj1VdkP3e+8exnNMSQI50v/dQCNOunaBGAVO589W+Itx3I nC+9M75oDiW/abFm5SAFfhU7L1NRI/hjoHh4zxZU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Fernand Sieber , "Peter Zijlstra (Intel)" , Ingo Molnar , Sasha Levin Subject: [PATCH 7.3 336/742] sched/core: Rank DL server picks as deadline in the core-wide pick Date: Fri, 4 Dec 2026 19:03:20 +0900 Message-ID: <20261204100643.975206867@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fernand Sieber [ Upstream commit edf8ee40167473828c1ae20ab9c6442f2e66dded ] Commit 4b26cfdd3956 ("sched/core: Fix priority checking for DL server picks") made the core-wide selection rank a task picked through a DL server as deadline, so that a fair task competing with RT tasks under core scheduling still gets its server's bandwidth. It keys on p->dl_server, which pick_task() used to set. Since commit bd9bbc96e835 ("sched: Rework dl_server"), pick_task() records the server in rq->dl_server and p->dl_server is only set once the task is switched in. The core-wide selection still ranks each sibling's pick with prio_less(), so a task the sibling's server has just picked ranks as a plain fair or ext task and loses to an RT task on another sibling. The server's CPU then runs a task with the RT task's cookie or is forced idle, and the fair task gets none of the server's bandwidth for as long as the RT task runs. Rank each sibling's pick by the server it came through, rq_i->dl_server. prio_less() keeps using p->dl_server for the core tree, whose tasks are not being picked. Fixes: bd9bbc96e835 ("sched: Rework dl_server") Signed-off-by: Fernand Sieber Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Link: https://patch.msgid.link/20261112161548.78189-4-sieberf@amazon.com Signed-off-by: Sasha Levin --- kernel/sched/core.c | 51 +++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 645111c09d7ea..9c518ba210c14 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -196,12 +196,13 @@ __read_mostly int scheduler_running; DEFINE_STATIC_KEY_FALSE(__sched_core_enabled); /* kernel prio, less is more */ -static inline int __task_prio(const struct task_struct *p) +static inline int __task_prio(const struct task_struct *p, + const struct sched_dl_entity *dl_server) { if (p->sched_class == &stop_sched_class) /* trumps deadline */ return -2; - if (p->dl_server) + if (dl_server) return -1; /* deadline */ if (rt_or_dl_prio(p->prio)) @@ -223,12 +224,19 @@ static inline int __task_prio(const struct task_struct *p) * ge(a,b) := !l(a,b) */ -/* real prio, less is less */ -static inline bool prio_less(const struct task_struct *a, - const struct task_struct *b, bool in_fi) +/* + * real prio, less is less + * + * @a_dl_server and @b_dl_server are the DL servers @a and @b run on + * behalf of, if any. + */ +static inline bool __prio_less(const struct task_struct *a, + const struct sched_dl_entity *a_dl_server, + const struct task_struct *b, + const struct sched_dl_entity *b_dl_server, + bool in_fi) { - - int pa = __task_prio(a), pb = __task_prio(b); + int pa = __task_prio(a, a_dl_server), pb = __task_prio(b, b_dl_server); if (-pa < -pb) return true; @@ -239,18 +247,13 @@ static inline bool prio_less(const struct task_struct *a, 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, + * Since 'a' and 'b' can be tasks served by a 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; + a_dl = a_dl_server ?: &a->dl; + b_dl = b_dl_server ?: &b->dl; return !dl_time_before(a_dl->deadline, b_dl->deadline); } @@ -266,6 +269,12 @@ static inline bool prio_less(const struct task_struct *a, return false; } +static inline bool prio_less(const struct task_struct *a, + const struct task_struct *b, bool in_fi) +{ + return __prio_less(a, a->dl_server, b, b->dl_server, in_fi); +} + static inline bool __sched_core_less(const struct task_struct *a, const struct task_struct *b) { @@ -6251,6 +6260,7 @@ pick_next_task(struct rq *rq, struct rq_flags *rf) __must_hold(__rq_lockp(rq)) { struct task_struct *next, *p, *max; + struct sched_dl_entity *max_dl_server; bool fi_before = false; bool core_clock_updated = (rq == rq->core); unsigned long cookie; @@ -6365,6 +6375,7 @@ pick_next_task(struct rq *rq, struct rq_flags *rf) * Tie-break prio towards the current CPU */ max = NULL; + max_dl_server = NULL; for_each_core_cpu_wrap(i, rq) { rq_i = cpu_rq(i); @@ -6388,8 +6399,16 @@ pick_next_task(struct rq *rq, struct rq_flags *rf) rq_i->core_pick = p; rq_i->core_dl_server = rq_i->dl_server; - if (!max || prio_less(max, p, fi_before)) + /* + * p->dl_server is only set once @p runs; rank a pick that + * came through a DL server by that server. + */ + if (!max || __prio_less(max, max_dl_server, + p, rq_i->dl_server, + fi_before)) { max = p; + max_dl_server = rq_i->dl_server; + } } cookie = rq->core->core_cookie = max->core_cookie; -- 2.53.0