Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp704448lqp; Fri, 5 Apr 2024 06:36:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURrC4NVSCOlkzp/z3Wi8ow3rZu7CCBaK+dXxZnRPbtcbMV6Wdt726enqYv2ubsrWRfzr4i9UB31Pm2j7IVqZonarBKduxS02jXFXgemQ== X-Google-Smtp-Source: AGHT+IFZpL1Nk3GDREwJEh2NuFVwGVGLS8kC66HWVVjecfLq0gusPilf+WMk78UnIV0/Uw8HWz5x X-Received: by 2002:a05:6a21:329d:b0:1a7:17a:9ac1 with SMTP id yt29-20020a056a21329d00b001a7017a9ac1mr2599783pzb.1.1712324181766; Fri, 05 Apr 2024 06:36:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712324181; cv=pass; d=google.com; s=arc-20160816; b=t0D1qM9HZJlopjGq63EEfuP8/j1H29cQLo5CqIxGR1ZNVWhq5Mmqynz1YBJlTEKEpl anXVDVVg4LyPGGGbUuLZ0skOOgmayizLSGrE+CwGZVWFmdxQvSQhMV8wJenWIuLp2SP/ x0r4xCNsThQLkFa/IvN2mDA9rrMMKnO0/nlE5HxVVylCXopgPAiFl9tTZNWm5cy8t9be 4ns74z12zaCYUiIbia8P5ptm563E+1ZpjZeIcUpThdJtNIsPlY2juAxQX5DAgHeFUnIY Gz+vBRYOoCvbdmnNc+xQd9DFtAZ2gDd6ZhYLWhkRltmG9+RTmoP/LDS3th3oHptzEZe0 9F5g== 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=RKhb5aV+piGVFKnCrjPql1BLANBIHYkggQUJQUo1fwU=; fh=cyDp+t11qGExQGVvcee9BaXo/5kV7bnnsUJA2sJhI3s=; b=T0mf4yCHtcyfCC1+GtbNausi38ifSG623mUsmcCvDO2SXSjShEa1rje37I9Vm7Sxui knLEYpUvlz1W2r4Ho/cBswTv4QVwfyFDtLntW1f3qUHEjEjcGkPI+L+kosEd8ZMD6ILs ksq5zhaVGiwahR0S+JqtsZyVQ7D9a+ukhWNAtMw9uA/Km/n8DLqRLgRbIafU3qH+Jajm kpNPY099dbDwAwWh2l3bNj6sJu3tV+h5Ulo2pBDd+8U5dl4vY6s/lRrxc5DX5iii0+zu KCjss5UlJTo4wuoUj2XwXgXg6Cholc2DWomvJgHRzhLiXHCyt0C94IVYaZPcT4u9VL9P W6Qw==; 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-133068-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133068-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b189-20020a62cfc6000000b006ea88c317f0si1408566pfg.53.2024.04.05.06.36.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 06:36:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133068-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-133068-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133068-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BF358282F4C for ; Fri, 5 Apr 2024 13:33:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D57116D9B0; Fri, 5 Apr 2024 13:33:44 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EBC5E16D4DB for ; Fri, 5 Apr 2024 13:33:41 +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=1712324024; cv=none; b=IHepgF+a4LHKtDUvHpzgEFZtsA6RNTfXoFle7pPDxT6/RzThv2aKA0uklPAjcik6yimJxgNqFTp1D+zv08GGIfWCPYHTw9uDnFg9g9deLHs4XIYD+V75jJ9U9wN+Z4SE82ZaMQp1uouU/NchWootjyBzSYtpesPO8lVwS55qTDI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712324024; c=relaxed/simple; bh=3m++agGg9LMrEIrVry1NTk+nR2ElsK5com/aXDFqL/g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hyx7ccNQnlh80zL+/mfFWVCr4gmpeLp0qsqsfaD4IeJY5PUlqb2QhbU7QX7OQ0vyv3XUfuIVkMJHX6QtVKYN9Q3B62yuLCYYnW6i6ZUPUxsbc3Hrrh3yrX9dcyHX0mz65AFxDoSbk9m0r4gsxCbB/22U7DN3yj2vd3EFHcz0lYk= 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 C7BE81007; Fri, 5 Apr 2024 06:34:11 -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 BD0503F7B4; Fri, 5 Apr 2024 06:33:39 -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 Subject: [PATCH v4 1/4] arch_topology: init capacity_freq_ref to 0 Date: Fri, 5 Apr 2024 14:33:16 +0100 Message-Id: <20240405133319.859813-2-beata.michalska@arm.com> In-Reply-To: <20240405133319.859813-1-beata.michalska@arm.com> References: <20240405133319.859813-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 --- 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