Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4330311rdb; Mon, 11 Dec 2023 16:32:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRs8VQTiwEb/cVljMMt/eoT2ITNALc+/i9oTYa0VjOB94hyCe6bP5MDkONVW2HozO8A0ZB X-Received: by 2002:a05:6870:d18c:b0:1fb:75a:de85 with SMTP id a12-20020a056870d18c00b001fb075ade85mr6545623oac.115.1702341151779; Mon, 11 Dec 2023 16:32:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702341151; cv=none; d=google.com; s=arc-20160816; b=i6wkMDOG/JnBg0MVQwCl7LJYcaB2O9nYQBJbUszDmTeUo6tj2ITxvvVlsIboOmJkJ3 iUs4cVr2mq8r/rkfPY/htSRK3lVQVYBevNcyAvSJAhe/MYSsTWKcMnUYHtBdvR/+wMYe vmNFTRTVGbXcl/ILOmv+Z2BOkuzk6IozfmtMPpKb4tPoY8aqVWXkBKCg92tzs7D0Mmb9 2xReEB1YLYV7uDWo+WVCOVg4YN2KNaw0gfXkT9bXylM05q1cU4C35Z6m8kru3zMzynBl 14obVnd4i3V5rVgAu49ymOjVnOOHhWT/4KwyX0P1aH1ekyROOd0LXQOPJNmk+g9o4oJ8 QVLw== 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=1ozM4BpN3Xt6MsBMcAeU5+sN7FM9jw+H7uMlVGcPsYU=; fh=M1Y4hH0c3aJh0Tk+r5qI6oW+pPzAHXWG1oPGqjHDYxM=; b=inZldbJLoygYYpyZIPT3w/Pu6vtzdMnZQa4TCjZmIhuivC7X8LkfI6ZWzEnJyps0yk 7alr+gYnfctw0g8dFRfE6voEqnnkxampvBI43cxhJjzjPjgNNY1lF6IA1O2bnjFpZgHl UhXgcClucHR6dlB2wzi0vX3HKY3HPMyU2BhZ9Td32he6RX124C35ueIjPG6mJ+BIniyx +SeIjieMCHQIxqMDgKLFGf3f/JKCJoNk9caPCnW2DJt1MECcgFjfPHjiYok/S1BQQzs7 a0Jw8H5t3DVXYx591UogmYK3w7Qyc1+tdu2HAJ9lWt7OaYe9+7gbD9WiXhIEoldG6/S2 JKlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id v18-20020a631512000000b005c65aafd65fsi6850220pgl.93.2023.12.11.16.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 16:32:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E03138053634; Mon, 11 Dec 2023 16:32:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345514AbjLLAcB (ORCPT + 99 others); Mon, 11 Dec 2023 19:32:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231131AbjLLAbw (ORCPT ); Mon, 11 Dec 2023 19:31:52 -0500 Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3000FDB for ; Mon, 11 Dec 2023 16:31:55 -0800 (PST) Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-35d4e557c4bso23274655ab.0 for ; Mon, 11 Dec 2023 16:31:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702341115; x=1702945915; 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=1ozM4BpN3Xt6MsBMcAeU5+sN7FM9jw+H7uMlVGcPsYU=; b=M6fROFzYXqiUvfysdgYd9JyunX57Gbfjd9muWKBsFPOw9QisqV9jZQgPygmbevtprR 3MSiK6BlgahonWwHTRCE0VFkz/4IGNWF51swsD8HtuMMIriFL2+VlnpmBPqoBanxFv8U iaRlVG6kI9fwKfZYy6vHWbP/VDcBIgu8TUNWjigyE172tLdjLlr/1um2TxIKKOI5VlqH Z1kDoChgh8q/RjH+uqRDfc7ro0IOLTosAEDzxH0s7LCl9QoTkRsGYKZ5u20rcZMkDYLQ qSqxPv7Fgj0HpI1feVlod7Iu+UjTglgFWkTKjKzsyx3VB6R9EQkKehpQcp1Fq/NyqRnD oDiw== X-Gm-Message-State: AOJu0YwvYjG5KSZJYiKX2aRPNI22ltV8XhcRIGyvrvkQxStgx+Fc+aaz XkW5JZxzZNpShrZ5Shvh33XBV2IErqVABBaP X-Received: by 2002:a05:6e02:1a4d:b0:35d:a4a9:7bb7 with SMTP id u13-20020a056e021a4d00b0035da4a97bb7mr8463770ilv.63.1702341114970; Mon, 11 Dec 2023 16:31:54 -0800 (PST) Received: from localhost (c-24-1-27-177.hsd1.il.comcast.net. [24.1.27.177]) by smtp.gmail.com with ESMTPSA id u4-20020a056e021a4400b0035d714a68fbsm2619217ilv.78.2023.12.11.16.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 16:31:54 -0800 (PST) From: David Vernet To: linux-kernel@vger.kernel.org Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, youssefesmat@google.com, joelaf@google.com, roman.gushchin@linux.dev, yu.c.chen@intel.com, kprateek.nayak@amd.com, gautham.shenoy@amd.com, aboorvad@linux.vnet.ibm.com, wuyun.abel@bytedance.com, tj@kernel.org, kernel-team@meta.com Subject: [PATCH v4 4/8] sched: Check cpu_active() earlier in newidle_balance() Date: Mon, 11 Dec 2023 18:31:37 -0600 Message-ID: <20231212003141.216236-5-void@manifault.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231212003141.216236-1-void@manifault.com> References: <20231212003141.216236-1-void@manifault.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Mon, 11 Dec 2023 16:32:29 -0800 (PST) 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 be idle for a very long time. 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 e1b676bb1fed..49f047df5d9d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -12284,18 +12284,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); + rcu_read_lock(); sd = rcu_dereference_check_sched_domain(this_rq->sd); -- 2.42.1