Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp818289lqj; Mon, 3 Jun 2024 01:22:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/DusXlEnDpzuWcxSXA+DH3JONgS+d1My+vly0/v+/z+BuX6dwzAMQok0EzQTK2xUVZ0R3ScMACEs/xBxoBxXoLmIC8bCCpaTTqKhSnw== X-Google-Smtp-Source: AGHT+IEUcElUdNBfV30dyJt5GfjOFv0SvzEa6PVLyE+Np+LrmkkKJdLeO0TMM/I5XmoadpOAeqoo X-Received: by 2002:a17:906:7f06:b0:a68:9ce3:c896 with SMTP id a640c23a62f3a-a689ce3ccabmr402113666b.24.1717402952441; Mon, 03 Jun 2024 01:22:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717402952; cv=pass; d=google.com; s=arc-20160816; b=brUoBGsv6N/CewDlphcSqcY43D0Nt2Y70d25OxRDll6M2s5EwUTu9Rb0MHdUFPF3ui eBcGjAeaJhYCiuleEAWRu01NDJ9coIg3HyoLHkinqWe0bVaA6Ash8QOM2ahYAoHYOx7V Kq3qorlEYi8/eLHyGDsE8Ik3hFtSs4QfJKlWyMCN/rXjoHMNUS/gncZx58QdmO374HyL nI/rewrGnn3db9JlwcuS3cnXGc/VZXq9Evmbtn+zCAQkSqY9CLuUxuz3LAl8QqtklivN jSRN0ZGx8ONjmQTStsqSJM+hrxhSW7nnI21C7ZYT88wSqCf6EDsleOP0brzG6zs2JtRs a2oA== 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=Dp99NDrCq/tU46tY2pd4aXl4nliZ5x/+0M2qrDepqm8=; fh=87IK6MSmzCt0b0c7BJM3BJ7okOQYSFhMEnQqWeNSPl8=; b=vzh3+bWF3YpZh84UPjvFhrvnovm5pl+RoeBGOATtWrIqT5QyeQN0tBEuEib+iUkX/e Xe0ZpXPdDXEvMKMR9A04xGmmVX2BkQW5KerNRh5X2T10n1dvHJ1K/ZIBOsqsGCNK1+Hp O2ZJeXecP7W+56i2F6DFxR5FmVvC9kG7a66I6sv52viZxhVQzqAkz09/O1VkbgKjhsry nMOvTvxSCjL6O5KlgpQXZVtGnyeC4dE2VyUNj7qm3xAabFRNwqnDeU46ynQ7jXLVLKTC kuZBTRBTy26SPLkYwmzkKDf+gbZKuUIcdPqrcSoLSn8lBS6XiUWWkYt+VcUuNVMZQIQ0 WuKw==; 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-198772-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198772-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a68ec85c1c6si150907066b.346.2024.06.03.01.22.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 01:22:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198772-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-198772-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198772-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 296CB1F2279A for ; Mon, 3 Jun 2024 08:22:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 621025B68F; Mon, 3 Jun 2024 08:22:14 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9523757CAB for ; Mon, 3 Jun 2024 08:22:12 +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=1717402933; cv=none; b=F0pPWskCNB7ys+0oelMv0T99yNVkAMH5HoHBsfgbDyDxjuV2kiJoQ3lVlJIYiZ94I773ZNbvb2OXO5mBj03DLu1O68tGVWjvLIv27RKrXIc4odY48m2IkgFoT6MKHL4CdP2yOIQ7GOAokQvURWY/AMmsdKXJlquU/w01nFWfW1w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717402933; c=relaxed/simple; bh=2eSMXYfYYs6HArv4V6/WQUuvgtIzkW1Gs3FiPPKAfJY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OC2SwPAxlvxcw1LukBwy3lLq4aPdsuqhZxflRzXKrwWbkRCAsoQgYkDrfhnMfVOUN9TzUS/KMhBufNxj8CYadFO968ACW6lMi6jaXzvZ3TXI/JCtND7ibYT2Hi2sYgKcxj7V58HG7vRN2NjGT8RZNnBrqRlp6rW0hyFdgJJxwCo= 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 4D70C1063; Mon, 3 Jun 2024 01:22:36 -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 4FDEC3F792; Mon, 3 Jun 2024 01:22:10 -0700 (PDT) From: Beata Michalska To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ionela.voinescu@arm.com, sudeep.holla@arm.com, will@kernel.org, catalin.marinas@arm.com, vincent.guittot@linaro.org, vanshikonda@os.amperecomputing.com Cc: sumitg@nvidia.com, yang@os.amperecomputing.com, lihuisong@huawei.com, viresh.kumar@linaro.org, rafael@kernel.org Subject: [PATCH v6 1/4] arch_topology: init capacity_freq_ref to 0 Date: Mon, 3 Jun 2024 09:21:51 +0100 Message-Id: <20240603082154.3830591-2-beata.michalska@arm.com> In-Reply-To: <20240603082154.3830591-1-beata.michalska@arm.com> References: <20240603082154.3830591-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 Reviewed-by: Sudeep Holla --- 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 c66d070207a0..b8217ce9082c 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