Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp496419lqb; Wed, 17 Apr 2024 02:40:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWtpdtK546qA37vIu6EFxBs4/ZXt/5xyQdRXCXp1TQ2rTwCyW4Kt6xRf/QF0B3MTg3Hqq4zDov8weMu5AN25Kpuaww1JF1DT4+UDiZWeQ== X-Google-Smtp-Source: AGHT+IFCcegTqyNuB4Ne6DzfaoE9L/2Ut84H1xcxvTV6LvXFiOyM2c05rspEJVrFbIEsBYOdazl7 X-Received: by 2002:a17:90b:164c:b0:2a2:c16:d673 with SMTP id il12-20020a17090b164c00b002a20c16d673mr16309416pjb.36.1713346810407; Wed, 17 Apr 2024 02:40:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713346810; cv=pass; d=google.com; s=arc-20160816; b=QN90inLD7w6Oj+TFmqxKIqXn3mG4Kzjo/3E/RgnM8HG+v2bybGRXBa0yn7ztGv2gVx RGphCJ+VGJhqq20hNes+SDKnZZLEx+xowxl2eSuN7HuHgGART0u+WK3N6wwCVe31nBkL pIY1zSca0NeyNn6tm5uhc1Zvi74uKRohCTZgaL4jCMqxhC+fIqQ1ZhBH4vMjdbxfzWch J8fqP+xpKzbFyJzRUuil5da0BCY8jJUGwZ02bdLvaf8osqz+pomYJCBFiKaSMXh/5RlN jRGCJXCMDYbAxWAJpXRrVmeBu/SA32xwaJlkB6luPWIsyHhFllSEzPy/+ocQ6N9jNi10 CbWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=7Ui0GlQnd8yB7u/mXplsgl7TU5PGF8eWYKvjfZmyx/o=; fh=Q/fJBPnBnMinsWaL+/VHtwI3DR4foDV1ujXNM08oUFo=; b=ejMoIUZc27dTNpYCkW2tiqfLJCVj2ufuRTd895wPtP+IGcafaoqp81Utyt7TI4fGis w+qaEf4mJkt2b2wL9qjsWzw65rcNDs8CaXxKDico6rAAtfbExV0dyc/r3CtaeOMUpuKd d7/U1EpB9ykxa08ZenPZ7bZOh94QjdsTcts2Iizdm3LBsm+MlQXDdL8GdZAI68Yazj1x 9Q0cRXZuxxRFh3yiwGjBmli2bBQgS3CB8itk6XsaNmmT/bROKxXrmgJVT7/nzfPUQAZB q6kkLJ8XqXPM8kOHbCMrxP9ABQqEn6WTSholuKQR8q0EbFEdvo7b9Wiye5v5J6kQI2bb NeVg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-148258-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148258-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id y21-20020a17090a8b1500b002a50b056bdasi985347pjn.109.2024.04.17.02.40.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 02:40:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148258-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-148258-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148258-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B6680B212E0 for ; Wed, 17 Apr 2024 09:40:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B42B213B2B0; Wed, 17 Apr 2024 09:39:04 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2D8D13AA46 for ; Wed, 17 Apr 2024 09:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713346744; cv=none; b=OmUMKVYsDHxCTyBWFv3tsiF8l01XMeEistoL2GgBqFjzf5G/4z5MPwycrMiHLg1J6KgDvyBJaj6XAxXHNH4bQNqWl3Z5ZZoB3C4YDxOxQ0k0mmkVex+3E/KpweBDW4NR6qmv8eXwso4m7Xe1HtETjP2dVuFsDkmQh4hcvguMNjk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713346744; c=relaxed/simple; bh=LE515nvwvBtP8gvCOVvIKqxcZH+UImq3DBTaJCX47A4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=udXTDRX0JJTNDCmpbtA5gOWGUX+Tdsq+uB2lMudJSZ1iXUPulplgckiyYaGJWJZn987P3CiOM4NeDqVdcNMCQep7slcH8jmu0I3dI8y43bLlpcWI/qNhMn05XEGUP0MBMqA16dwaqIXCKVMjFGHzML7PX9SJT50VzoyhUXnjuEA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 20C32DA7; Wed, 17 Apr 2024 02:39:30 -0700 (PDT) Received: from e125905.cambridge.arm.com (e125905.cambridge.arm.com [10.1.194.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 71D283F64C; Wed, 17 Apr 2024 02:39:00 -0700 (PDT) From: Beata Michalska To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ionela.voinescu@arm.com, vanshikonda@os.amperecomputing.com Cc: sudeep.holla@arm.com, will@kernel.org, catalin.marinas@arm.com, vincent.guittot@linaro.org, sumitg@nvidia.com, yang@os.amperecomputing.com, lihuisong@huawei.com, viresh.kumar@linaro.org Subject: [PATCH v5 1/5] arch_topology: init capacity_freq_ref to 0 Date: Wed, 17 Apr 2024 10:38:44 +0100 Message-Id: <20240417093848.1555462-2-beata.michalska@arm.com> In-Reply-To: <20240417093848.1555462-1-beata.michalska@arm.com> References: <20240417093848.1555462-1-beata.michalska@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Ionela Voinescu It's useful to have capacity_freq_ref initialized to 0 for users of arch_scale_freq_ref() to detect when capacity_freq_ref was not yet set. The only scenario affected by this change in the init value is when a cpufreq driver is never loaded. As a result, the only setter of a cpu scale factor remains the call of topology_normalize_cpu_scale() from parse_dt_topology(). There we cannot use the value 0 of capacity_freq_ref so we have to compensate for its uninitialized state. Signed-off-by: Ionela Voinescu Signed-off-by: Beata Michalska Reviewed-by: Vincent Guittot --- drivers/base/arch_topology.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 024b78a0cfc1..7d4c92cd2bad 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -27,7 +27,7 @@ static DEFINE_PER_CPU(struct scale_freq_data __rcu *, sft_data); static struct cpumask scale_freq_counters_mask; static bool scale_freq_invariant; -DEFINE_PER_CPU(unsigned long, capacity_freq_ref) = 1; +DEFINE_PER_CPU(unsigned long, capacity_freq_ref) = 0; EXPORT_PER_CPU_SYMBOL_GPL(capacity_freq_ref); static bool supports_scale_freq_counters(const struct cpumask *cpus) @@ -292,13 +292,15 @@ void topology_normalize_cpu_scale(void) capacity_scale = 1; for_each_possible_cpu(cpu) { - capacity = raw_capacity[cpu] * per_cpu(capacity_freq_ref, cpu); + capacity = raw_capacity[cpu] * + (per_cpu(capacity_freq_ref, cpu) ?: 1); capacity_scale = max(capacity, capacity_scale); } pr_debug("cpu_capacity: capacity_scale=%llu\n", capacity_scale); for_each_possible_cpu(cpu) { - capacity = raw_capacity[cpu] * per_cpu(capacity_freq_ref, cpu); + capacity = raw_capacity[cpu] * + (per_cpu(capacity_freq_ref, cpu) ?: 1); capacity = div64_u64(capacity << SCHED_CAPACITY_SHIFT, capacity_scale); topology_set_cpu_scale(cpu, capacity); -- 2.25.1