Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp379887rwl; Wed, 9 Aug 2023 16:24:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+Qey7ly1v6HzqURmVrbp0QtnUhkY2zmT9fdDkkGojNffQ8ckDBSXZkPURczKJiIu/kgCz X-Received: by 2002:aa7:c542:0:b0:51d:f5bd:5a88 with SMTP id s2-20020aa7c542000000b0051df5bd5a88mr535020edr.38.1691623496533; Wed, 09 Aug 2023 16:24:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691623496; cv=none; d=google.com; s=arc-20160816; b=y3oS6EhUonWVlXLQy9brxGcJrbauftI12pxxOrEqjRhg0U5XZO96TPNyYM5tfe3df7 nKQaHoO7UlouBEv8cx4Lv7OB6iRKGq/Wps4YACxsOIxSVkC9njdtrgUoyBTgfBH5zodd u51YDMcLDbhE9aoGvlZG+y3rVVjROZbE20q9v9+NHRmxTgV1CAmopA56bIXLcNPakse/ xSdMpshML3gA0CHKI1KW308kW/s5yK/7RbklTweKTaVkuzudxGbkZ3TruRN0zolW/Dm6 X8+hsl8cqL1xHsXFoLeOA77WjhvHkx+EJiqKIhpKzAKbfGHnej+7PiYsq/c2AqHH2639 0jdA== 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=NCs/KK1OPApuPq1wtS/IBD+prxoRkH0tsLIOpWbu+9s=; fh=20RY08rsve2lwti6V2FQSjrHvxbvm4llznoKqUOZSeY=; b=ZeujvvAvxzbxb/MmMgyTmGsgK+t91/WIl0Yw5/7oDVf5XYXCqrVqsab8FeADErhCQO CMpH6lu8IOI2SOHeCsw62w0MbcSur+Wnt4OIRKR4KhmnkNiBm5UnwHK2sRWb9/jPiS+d uillAk3aLsG4VJyfIP9z6ZUVQAwAtcmNC2bJzdRFwZxAKOMLQGu6mLuJtv88H8z0L6mc CSng6s2o+/WYdNWC+82J/hglz6k8scBK7yoT2y23xIF5/QUh+eO4mW521fF98+aCjGrR WrURdPdTGw2gV7widAmraoIjUjgiv9QGDb+exZJqgs50rVN2rQ42shsQLKCNPf47qfFv xyUQ== 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 w18-20020aa7cb52000000b0052338133e02si190562edt.41.2023.08.09.16.24.32; Wed, 09 Aug 2023 16:24:56 -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 S232332AbjHIWM6 (ORCPT + 99 others); Wed, 9 Aug 2023 18:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231703AbjHIWMx (ORCPT ); Wed, 9 Aug 2023 18:12:53 -0400 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C97EEB9 for ; Wed, 9 Aug 2023 15:12:52 -0700 (PDT) Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-7658752ce2fso24202985a.1 for ; Wed, 09 Aug 2023 15:12:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691619171; x=1692223971; 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=NCs/KK1OPApuPq1wtS/IBD+prxoRkH0tsLIOpWbu+9s=; b=WcbPqdOLJiZ38sbu3c/K7zpXLMjMYiwAbdzXRo5A40rCdOA1KKpma0zsYT5dmK/+WJ CYfyxzXU1DbUAAhUa46BB3ScOs4r8lFI8aOQrA9dKt+GG3J7IQb4i1AEjsJpOTX4enOd 9JI8VDqFGkIim56Y219HPSm43W8scNqD67gybuAnb8S1pZlQ9UPt4xnGviO/GDnERUfj /Z7d5yEMjp9gYSoUgXWu1+7ZmUXEB9wKUqTF3Xws4WF39tR+/iuhweo7SlqhUPEloGBN tqdAuKLVhSlIncbjTYMOiDQb9uV7u4y7z9gf5YkIE7SWAIlnlljzkh0vCh5k6arP60IA 4XHA== X-Gm-Message-State: AOJu0YxfmnUv18IYAVK7VOuTmTbmVe6cPg87pDqfc0J/XyxoXFmoZWcO INfd7aXdWFYelpdEej0Cr8sbSy0ah4MZGFP7 X-Received: by 2002:a05:620a:29d2:b0:765:7d7b:7197 with SMTP id s18-20020a05620a29d200b007657d7b7197mr386020qkp.31.1691619171616; Wed, 09 Aug 2023 15:12:51 -0700 (PDT) Received: from localhost ([2620:10d:c091:400::5:ed08]) by smtp.gmail.com with ESMTPSA id g20-20020a05620a13d400b00767d6ec578csm23080qkl.20.2023.08.09.15.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 15:12:51 -0700 (PDT) From: David Vernet To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, 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, tj@kernel.org, roman.gushchin@linux.dev, gautham.shenoy@amd.com, kprateek.nayak@amd.com, aaron.lu@intel.com, wuyun.abel@bytedance.com, kernel-team@meta.com Subject: [PATCH v3 3/7] sched: Check cpu_active() earlier in newidle_balance() Date: Wed, 9 Aug 2023 17:12:14 -0500 Message-ID: <20230809221218.163894-4-void@manifault.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230809221218.163894-1-void@manifault.com> References: <20230809221218.163894-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_H2,SPF_HELO_NONE,SPF_PASS 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 c28206499a3d..eb15d6f46479 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -12037,18 +12037,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.41.0