From nobody Tue Dec 16 12:21:20 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF79CC4167B for ; Fri, 8 Dec 2023 11:21:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231828AbjLHLVS (ORCPT ); Fri, 8 Dec 2023 06:21:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233367AbjLHLVP (ORCPT ); Fri, 8 Dec 2023 06:21:15 -0500 Received: from out0-196.mail.aliyun.com (out0-196.mail.aliyun.com [140.205.0.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B229C1736 for ; Fri, 8 Dec 2023 03:21:19 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R921e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047203;MF=tiwei.btw@antgroup.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---.VfpW3Bq_1702034472; Received: from ubuntu..(mailfrom:tiwei.btw@antgroup.com fp:SMTPD_---.VfpW3Bq_1702034472) by smtp.aliyun-inc.com; Fri, 08 Dec 2023 19:21:17 +0800 From: "Tiwei Bie" To: peterz@infradead.org, mingo@kernel.org, wuyun.abel@bytedance.com Cc: "Tiwei Bie" , "Juri Lelli" , "Vincent Guittot" , "Dietmar Eggemann" , "Steven Rostedt" , "Ben Segall" , "Mel Gorman" , "Daniel Bristot de Oliveira" , "Valentin Schneider" , Subject: [PATCH -tip] sched/fair: gracefully handle EEVDF scheduling failures Date: Fri, 08 Dec 2023 19:20:59 +0800 Message-Id: <20231208112100.18141-1-tiwei.btw@antgroup.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The EEVDF scheduling might fail due to unforeseen issues. Previously, it handled such situations gracefully, which was helpful in identifying problems, but it no longer does so. Therefore, it would be better to restore its previous capability. Signed-off-by: Tiwei Bie --- kernel/sched/fair.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index bcea3d55d95d..1b83b3a8e630 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -878,7 +878,7 @@ struct sched_entity *__pick_first_entity(struct cfs_rq = *cfs_rq) static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq) { struct rb_node *node =3D cfs_rq->tasks_timeline.rb_root.rb_node; - struct sched_entity *se =3D __pick_first_entity(cfs_rq); + struct sched_entity *first =3D __pick_first_entity(cfs_rq); struct sched_entity *curr =3D cfs_rq->curr; struct sched_entity *best =3D NULL; =20 @@ -887,7 +887,7 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *c= fs_rq) * in this cfs_rq, saving some cycles. */ if (cfs_rq->nr_running =3D=3D 1) - return curr && curr->on_rq ? curr : se; + return curr && curr->on_rq ? curr : first; =20 if (curr && (!curr->on_rq || !entity_eligible(cfs_rq, curr))) curr =3D NULL; @@ -900,14 +900,15 @@ static struct sched_entity *pick_eevdf(struct cfs_rq = *cfs_rq) return curr; =20 /* Pick the leftmost entity if it's eligible */ - if (se && entity_eligible(cfs_rq, se)) { - best =3D se; + if (first && entity_eligible(cfs_rq, first)) { + best =3D first; goto found; } =20 /* Heap search for the EEVD entity */ while (node) { struct rb_node *left =3D node->rb_left; + struct sched_entity *se; =20 /* * Eligible entities in left subtree are always better @@ -937,6 +938,9 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *c= fs_rq) if (!best || (curr && entity_before(curr, best))) best =3D curr; =20 + if (WARN_ONCE(!best, "EEVDF scheduling failed, picking leftmost\n")) + best =3D first; + return best; } =20 --=20 2.34.1