Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35826422rwd; Mon, 10 Jul 2023 13:16:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlHUJJt3svGi5OgXsxv4Ho6uRNlgufOynLt/VjtHdm1TPXmAqd7DQ4iDFvlyn5A1KfSYu4rO X-Received: by 2002:adf:e74d:0:b0:314:2568:7c9a with SMTP id c13-20020adfe74d000000b0031425687c9amr11995985wrn.17.1689020183933; Mon, 10 Jul 2023 13:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689020183; cv=none; d=google.com; s=arc-20160816; b=leAbu+b0dVGoYS6TJd7hYZmviy8oRpa6X2P4ukF6B3R5M3NzT7UdTnxdRKbElPyKyl AqHoUd2SnUpeu5aTSPjULuiwNzMqdCUpw+basqA9YifQh9lpgkzk7fhIaw8sIm4rpBF/ /y4O0knCrF5nd+8x2mxSEacD5ismjc5FbPJO3lp64Mi2D/OlAC1U6sEFOL+hBtNrVklS OYSRO3PR/6Phq2fUd8xA60qg8BoCI4D39dbA2LV2LWM+HrCzBIfg924X3TZyMssqj9ue CDe70TZDOGoTY8eAzBvpfuPuare9FzI/vTJIGSHezavmcF8+24w+NPK0UgrBbMu4eguQ bg1Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=5SBGw2jXOpZgmbGBedJ7/r5mS0Q0qMFpeepfUvmrysc=; fh=GCF3HUaVVQnsrFP0NhazYIuTwTFmsBL5+Yby9S9U12k=; b=adcXrcCqSWh5MEOwJ6Y7UYo6a1q5UXj7ws8iFJYTSISgf4RDB8M+Qdxdpely8wrC18 JvguVcDT1d88rml8hsMujKmKrlFsnzPZQ+1eUyyWhL4uljREVWH4qvtmZ5Oq+LEXOb/1 ZLxARaNfHXT7A9evBVjdCRKAcellqtn/ndoL95A7ma7G74kNLp+MxYA63QRk0K5sE/+O blW+QK4f/8oeP6sEyCLjg2FXJx2jKRhOSip8FNVo93u0G1gy7sWUoSGN0TnnkctH5OQ1 eRpr1ZZwIkbVXHaJ0OGBJJmD5MCSAhJZP5vHkZUjyUsL5Z75seqSmH0iOrg9ujUzFkTr lFPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k18-20020a170906a39200b0099392706398si337486ejz.231.2023.07.10.13.15.59; Mon, 10 Jul 2023 13:16:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231690AbjGJUEM (ORCPT + 99 others); Mon, 10 Jul 2023 16:04:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbjGJUEG (ORCPT ); Mon, 10 Jul 2023 16:04:06 -0400 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CF8F133 for ; Mon, 10 Jul 2023 13:04:05 -0700 (PDT) Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-40355e76338so43937231cf.3 for ; Mon, 10 Jul 2023 13:04:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689019444; x=1691611444; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5SBGw2jXOpZgmbGBedJ7/r5mS0Q0qMFpeepfUvmrysc=; b=IthWIhQjs6zlc88WmpO6Tw+iLkfYLE4qsiPGQbHzR18BIMxjVADrsoqnXTU2Wg0YOx VrH7k7uxvBd9QBOKJQM9JBtYM8AEraUrTufGixUtt9Xv7M1v7bYgvHcWKxIUNtETpKoO MKzQ+eaq/7V5ehlnF66s6e6ZLa+NPJAJUP79oRgcwF5tNKfBzS9UpEM5BqruHRMNSkJ8 TRfNwVXBpkR21ZeEgKqAcwehQfdXcErrgNwYwAr+/1w+laS/cqRcznzytuDDOH87Bpz9 jXPKPvL0aVTPq7IlB77JO8M6HxetvpVRmaDf8V7rdOfxZH3E9QYiz91xP932pqCTZh9G 3Nmg== X-Gm-Message-State: ABy/qLaWEmridOc+HdPJy6oMmp3nAeDFscgjwD0P/djKM1Q45JGUWMBZ ztmC8s8YJp1IUG4lUX1zrJ1NxcWNMjVafumg X-Received: by 2002:ac8:5f13:0:b0:403:b395:b450 with SMTP id x19-20020ac85f13000000b00403b395b450mr2250143qta.2.1689019444299; Mon, 10 Jul 2023 13:04:04 -0700 (PDT) Received: from localhost ([2620:10d:c091:400::5:4850]) by smtp.gmail.com with ESMTPSA id d15-20020ac8668f000000b003f394decd08sm250151qtp.62.2023.07.10.13.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 13:04:03 -0700 (PDT) From: David Vernet To: linux-kernel@vger.kernel.org Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, gautham.shenoy@amd.com, kprateek.nayak@amd.com, aaron.lu@intel.com, clm@meta.com, tj@kernel.org, roman.gushchin@linux.dev, kernel-team@meta.com Subject: [PATCH v2 3/7] sched: Check cpu_active() earlier in newidle_balance() Date: Mon, 10 Jul 2023 15:03:38 -0500 Message-Id: <20230710200342.358255-4-void@manifault.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230710200342.358255-1-void@manifault.com> References: <20230710200342.358255-1-void@manifault.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 In newidle_balance(), we check if the current CPU is inactive, and then decline to pull any remote tasks to the core if so. Before this check, however, we're currently updating rq->idle_stamp. If a core is offline, setting its idle stamp is not useful. The core won't be chosen by any task in select_task_rq_fair(), and setting the rq->idle_stamp is misleading anyways given that the core being inactive should imply that it should have a very cold cache. Let's set rq->idle_stamp in newidle_balance() only if the cpu is active. Signed-off-by: David Vernet --- kernel/sched/fair.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index a80a73909dc2..6e882b7bf5b4 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -11837,18 +11837,18 @@ static int newidle_balance(struct rq *this_rq, struct rq_flags *rf) if (this_rq->ttwu_pending) return 0; - /* - * We must set idle_stamp _before_ calling idle_balance(), such that we - * measure the duration of idle_balance() as idle time. - */ - this_rq->idle_stamp = rq_clock(this_rq); - /* * Do not pull tasks towards !active CPUs... */ if (!cpu_active(this_cpu)) return 0; + /* + * We must set idle_stamp _before_ calling idle_balance(), such that we + * measure the duration of idle_balance() as idle time. + */ + this_rq->idle_stamp = rq_clock(this_rq); + /* * This is OK, because current is on_cpu, which avoids it being picked * for load-balance and preemption/IRQs are still disabled avoiding -- 2.40.1