From patchwork Fri Dec 8 11:20:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiwei Bie X-Patchwork-Id: 175787 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5385516vqy; Fri, 8 Dec 2023 03:21:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1sQQuw5YRJQ5mct7wQ0xvX7wre5IHn8BpfueCQDWBh+LM8zeagKPUhCbw+a3OxYfFuwOg X-Received: by 2002:a17:902:70c8:b0:1d0:9e5a:e886 with SMTP id l8-20020a17090270c800b001d09e5ae886mr3346717plt.127.1702034500237; Fri, 08 Dec 2023 03:21:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702034500; cv=none; d=google.com; s=arc-20160816; b=QqjkQtDwt2j0wPnh7TvBNECy3vhJ8xNuzeRaMkrii7/AhYmbQQRBVyQ+tocKrJUWpP vDfdBP6oy/4dnpnCEpkgse8S4JNzrTfIp990feMOK3l7GtR3ylIBBH3KkdmJB/n8dxAP 8dpBP1Kcb8U+poiqY+3sv5xOO1zB+vLXydNI/hkZvb6hHE4ABcI+imaL5neFG6XMcHMo osLSVxhkAz6DyY3q9GP3CKJIHs7+zzNr7iBdr+4pmvaZjSjlVBRZIC6NCUZC0hJUid6B /s3huR2aMd2hQSi53N9wHT8TkZCxH/k4RMBtnVQORsSdndxT+OzkJ2zSL0bXVXP5n1ie PiSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=tkcF1JVLMysDU1e7rIQz6bYPdhrXALpp7V7gnzd8GHc=; fh=V58bPj9/Zsh/S5sroMIiQcADsiz2gtPKEGSy1MEzjVs=; b=uy0b5nfdlfmzdnsF97KzOI+QlDLDT1mrD3KXAuPVi4gDZRNXuBQ61VdSd7bWXiNTnn /BvD2XbWy/u+g6ES1K4rSomVbLgTJg6E2qWC2oVRfsBr5+QOyUkkNgr7m5SuiZFknTpn kusqyAWDBmXdanBdXEil2kxn3Q9H5gyyOpjE0is8U97dpf+GxPU4yPTAduHhetwRmWmY ExyU64qs5X7KIeqMa1ToRTFSj0T1z0w9FCiJK5W1jCFFNk035wVTjYVVK3hcvJnt/jkJ IFeaLEiiCAXpytI1K/jL0ixUbsBjUno7Mxitme0yKBI6rINouI6SC2aR/DFdr0Y5Eh8C 7YBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u5-20020a170903124500b001d07b6a0af2si1448275plh.204.2023.12.08.03.21.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 03:21:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9530E80FA9D5; Fri, 8 Dec 2023 03:21:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573534AbjLHLVS (ORCPT + 99 others); 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 08 Dec 2023 03:21:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784712528290591654 X-GMAIL-MSGID: 1784712528290591654 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 = cfs_rq->tasks_timeline.rb_root.rb_node; - struct sched_entity *se = __pick_first_entity(cfs_rq); + struct sched_entity *first = __pick_first_entity(cfs_rq); struct sched_entity *curr = cfs_rq->curr; struct sched_entity *best = NULL; @@ -887,7 +887,7 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq) * in this cfs_rq, saving some cycles. */ if (cfs_rq->nr_running == 1) - return curr && curr->on_rq ? curr : se; + return curr && curr->on_rq ? curr : first; if (curr && (!curr->on_rq || !entity_eligible(cfs_rq, curr))) curr = NULL; @@ -900,14 +900,15 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq) return curr; /* Pick the leftmost entity if it's eligible */ - if (se && entity_eligible(cfs_rq, se)) { - best = se; + if (first && entity_eligible(cfs_rq, first)) { + best = first; goto found; } /* Heap search for the EEVD entity */ while (node) { struct rb_node *left = node->rb_left; + struct sched_entity *se; /* * Eligible entities in left subtree are always better @@ -937,6 +938,9 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq) if (!best || (curr && entity_before(curr, best))) best = curr; + if (WARN_ONCE(!best, "EEVDF scheduling failed, picking leftmost\n")) + best = first; + return best; }