From nobody Fri Sep 25 17:42:50 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9500B3D6689 for ; Thu, 10 Sep 2026 06:35:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789022103; cv=none; b=KXHn8rtgDeoRlErj3unC55BW93Ik1FY/WPgubajjUNygVv+3hRPBdVy/WjihxfdRr0pPQN2aPAG4q7Rs6OC6iKJAKdAUlc0+fI+s5J8MW3uid2rEe2Xr6sz0wFHEZ64IixpKZ+LHqVoWPQ11bSt96X5AajlbUPh3ICB9mUqUAPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789022103; c=relaxed/simple; bh=3dlewbAKl8NocA7IwnXM4yE78ovk2+W6PMjEtEdYDR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UPdVbpttCSHY9wfkwnNMDNhLnMHIxACuOL66/pku1NE3ZRm7i7/AqiuSI/Mz1xQd0qG+tE0/0bFsYzHR8S0Lv6BGi9QLq5sioxY7rVMyGVHheaogjRzmN2ZC0AOoh09FgVp9cjrwX+wG/0V1tNlfjVDnZcGz8aeDeP19yFriK9Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VuULb4aY; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VuULb4aY" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4998b5a63e2so77142535e9.1 for ; Wed, 09 Sep 2026 23:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789022099; x=1789626899; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=wrGQmgTiJm55JhKTBWHPGvE5gvx0Uq3tjEPdNSRkMAU=; b=VuULb4aYGg10uCYiwO2FpuTRTloAidOako1+/EOH2nNgUsjkApKAxVM1QavLD9zmEZ RtyaZvWScW8bt+eHSsXsxK/3Djcoyxdvsg8zT0jZq72Z0o7yJPWpfPGZxDwHNgYkdZf3 HL7BuS5mKq5CiCO0oIiO+tlIcHT7HqPdQp5GOfgAe9Z184sm76L89U3lhEYM1dHT8lsf rp+MJh5f57OFest34CossKusRfXBv8QaWAoRAEVxusPfPLG7gE1Xjz2EPP6jqR8s8R9X rvqDW5lAudkZjuJsqNFmCO0WbEh1dQJcU51SaE2D2hd5e1sfCedOhs3a+r7DoCzBdN6h /WoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789022099; x=1789626899; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=wrGQmgTiJm55JhKTBWHPGvE5gvx0Uq3tjEPdNSRkMAU=; b=rEmMubRhysytsa9NrWcz1rX54XIzXUJL9h5ZnOlyN82EjxHOjRMEX954Opuj6wJ4rO fwxx36HMlW/HIf3zyJCYteSwSCw7kMi5nRIjWaJqXR8Jf0XIrPQi6A5LoIfpXv6cK2Fx fLKdSeJp9DoJpoaYk/7dqBcyQUsCOGe81ASeRKlQGiyB6aOBngG2di9Gm3MewbGTzFa7 T91EAAa6QXcR3d7/laOh6y2OArKkY/fEI8zYvoWs7zY3+Eke4ipFAKCr0YoGBjYAfwUl mBa6KlkbUnEYJaWR74fGLJhoUsqFXs8MF6JDkdVa1Wll/Ort+HqK85Xnb5QU+MoJsjDw X6jg== X-Forwarded-Encrypted: i=1; AKwUvBwKfVSlBwdu3QZhIjoNVM6KoNqGKdmLt8stOtBGzIuMqRf5kexjfvMIOxF4C69tGn7pfvI47qKSWmIsr4c=@vger.kernel.org X-Gm-Message-State: AFuF++l/BCGzZEJ+O/415zOPG1gyRLdWM4mbMpcUInkCfVyxPxxH0AvW k8EyoR+xFc0XK/lRe5nP0JB+ocvu6JwvEhVj3XUWXRsmq/sOECu0GT5u X-Gm-Gg: AYBFou1OZni0GsnnjotXLMsn5VUbP9VgBp+c3ojb0DLzVOVKaprfrLj5quC4ejAeCAi rQ7ycAFr9DQ+7nnKAs7xcUnxGvU7ISCpLhCOadsizTkw9ZkR5or9ocJLv3EN/S5pGOR4GzBXgxK ssF+Toy63cdT19V72zfaN7TJTny59Lkbp5t8Y2tY3voAK9gVYmuHUBv0bAcWP5KRSmTp4XQggai IhqQEN+lnVFAn+NStRDs2nLJlT1euEEPBcPxg5HvSQJ1xAqdhtotO7jxQ+BeZydtM4zWRoiXxjf Y1rs8tgpBRJHjW7RGvTllnOWH0sslaQLdiaXhJcEX8Zn78IBHOw4QET6ZHxPCe3602yuNL6qZl7 oat6/gXR7969G7oDg55lEZfpVpZR4C0Gy1Ah5c4ohE0WFzN712eHYx9VbZ8etcwpd/DtrFgYfeh pcy9vkHkD+86B9QOfEzLpYHe3xSw1xbTFWugSB6wUsAi2idSiWBTljXA6mXNQyvHHq3qunr3xnd ybeZ5jcNqdSg5wPyeD/XlPfKGknFmEYjstcdC2uBvw= X-Received: by 2002:a05:600c:5254:b0:49d:5ff:f404 with SMTP id 5b1f17b1804b1-49d05fff5abmr273112235e9.1.1789022099342; Wed, 09 Sep 2026 23:34:59 -0700 (PDT) Received: from localhost.localdomain (mob-31-26-103-238.net.vodafone.it. [31.26.103.238]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-49e2212193esm2595255e9.1.2026.09.09.23.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 23:34:58 -0700 (PDT) From: Oleg Keri To: Catalin Marinas , Will Deacon , Mark Rutland , Sumit Gupta , Prasanna Kumar T S M , Beata Michalska , Russell King , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Sudeep Holla , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Viresh Kumar Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, jonathan.cameron@oss.qualcomm.com, sibi.sankar@oss.qualcomm.com Subject: [PATCH v3 1/2] arm64: topology: fix arch_freq_get_on_cpu() overflow above 4.19 GHz Date: Thu, 10 Sep 2026 08:34:39 +0200 Message-ID: <20260910063440.4677-2-okerixx@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260910063440.4677-1-okerixx@gmail.com> References: <20260910063440.4677-1-okerixx@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" arch_freq_get_on_cpu() computes the product of the frequency scale and the reference frequency as a u64, but assigns it to an unsigned int before shifting it back down: freq =3D scale * arch_scale_freq_ref(cpu); freq >>=3D SCHED_CAPACITY_SHIFT; The product is truncated to 32 bits before the shift, so the result wraps once arch_scale_freq_ref() exceeds 2^32 / SCHED_CAPACITY_SCALE, i.e. 4194304 kHz. On a Snapdragon X2 Elite (Glymur) laptop, whose boost OPP is 4723200 kHz, cpuinfo_avg_freq reports 524283 kHz instead of ~4723200 kHz while the CPU demonstrably runs at the boost frequency: a fixed workload completes in 1.72 s at the 4723200 kHz OPP versus 2.01 s at 4032000 kHz, matching the 1.171 frequency ratio. Keep the arithmetic in 64 bits until after the shift. Fixes: 16d1e27475f6 ("arm64: Provide an AMU-based version of arch_freq_get_= on_cpu") Signed-off-by: Oleg Keri --- arch/arm64/kernel/topology.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index d28438f8b83f..0eca321ff113 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -245,8 +245,7 @@ int arch_freq_get_on_cpu(int cpu) * (see amu_scale_freq_tick for details) */ scale =3D arch_scale_freq_capacity(cpu); - freq =3D scale * arch_scale_freq_ref(cpu); - freq >>=3D SCHED_CAPACITY_SHIFT; + freq =3D (scale * arch_scale_freq_ref(cpu)) >> SCHED_CAPACITY_SHIFT; return freq; } =20 --=20 2.55.0 From nobody Fri Sep 25 17:42:50 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33CAC3D6663 for ; Thu, 10 Sep 2026 06:35:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789022106; cv=none; b=ApsJZ1p6sxlojvJU0GxPdciKryTXqPXu+inK8fy75IKXVXHvIqzXu3JLzBTbX5qMRUvjp8KqPVt+upPJdG8E3mXT6cyahN5xVNazZTEo3JyI33Ceaxp06SNkDam8uNOgGErgfqPbo8hS5R3I/JFe0cwkUJMIlj5eVBx0pad/smo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789022106; c=relaxed/simple; bh=nEewE9vNn2GKeus40xjVARF+cnc+CRqiCdYnkkQKlwc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oo0hmkJl4qCp4L0Mkfy7J5Zf0nbV0VgbYwv7zd642ECdvQ2frihTV+PXhMaaW5cyb+XpZbXNvlpQ7iaBPRe26aU60nd70IYcaco7wPd1BGilpMp4MSEjWMwWyukesBpronyYqA1nLLEnZcC46ZjUxk9wScnzcQiZUtwGEVaZpQ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MCYAiiWE; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MCYAiiWE" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-49b392ccaacso96688605e9.2 for ; Wed, 09 Sep 2026 23:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789022102; x=1789626902; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xU/TVU9R6QqVQBU8DMj4Dr025QCTEz1Y5w5z0voxEUA=; b=MCYAiiWELRscgsudVA4df+1wbbJaS9lpxoqjYTEc0xmzbaDHn1Q4raWAfuo2QTcba+ Tq/emfS1eitUgTTcybOiPfT69Lvq86b63UNRKED3TUtlGNgsaYyDeynEYh/3zZkL5PjH 1Vk9FQuApyhD8XCqjTxfhvfmhKzbl3Fq0ZzJpxgsvuR1CRrwzFUkUZShm3Oz0xJQzDdO XwWEuqkxM3oHRieIrfwE/FSnfVmB75e/tOQI4THrhibjdZB5iXa53pT+vJlUz3NElQNd 60tCtXNZBV4tolx2XpKZVQm6lXXARnE1ijTb1Y0uTdWWNCPQ3CUVDnR5Gc0bA3WEh88n Bu2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789022102; x=1789626902; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=xU/TVU9R6QqVQBU8DMj4Dr025QCTEz1Y5w5z0voxEUA=; b=Jvx8Cf47ggEMCrtdiAvFszFv2yIpdMb9bC7Rav5xnDUmX5ZeN6j87BWmyOMrC+Q5eb 6lyXGuoYXFZuj3f4xYRM1f+yoW4tdMcMPpI3TysUU5j9NzmsNFz1MzAqdoxxNakh4IRw rzvddQhfWMF+EN0Rj6ggtTZArPYmVvJrBBQH8y6+MXgUHUUsodT7sjTbJCrvjwGZ+hFC rwlzG5rRY/s1BppkcpGm00utArmZToVonrTJiaIW6s+1uJDZU9U1QOjh/h5LgRByUhQM 4nuHeJ4ICaBERU2apaBClB51w7c3YroO69KnEb/FuG7W32GTrsDF5gjdWAg7ZE3PCO1L LUmw== X-Forwarded-Encrypted: i=1; AKwUvByhPqQ/N5oyN6Csj9Fa6znAJlRQ4HsiaRdrsgrUhCt8QPLpJg+6tRdfKKr+/rveBIi65KoHvnCS3Dh1cnM=@vger.kernel.org X-Gm-Message-State: AFuF++kmYrcsdqAsXDvb6a1a2JqY+xN2AFHV/vSYfI/kUiLEjWiZH85a FRPM0tNd9DnjeRPKkctKsIQY15FI7tOsmAN/A3Vg99ilHTxRsfDLCqG7 X-Gm-Gg: AYBFou1nKdbn0BUaK9XFO+5UOyyCXcBBxUNpMKUuYy9XhEx29vP7Fx+I94shixR04Xh GppCQub6sXEpouVfg6CcVS5ZV/BqZJOefHVTM65WfS3AryibtZqPOaiAh6a/KjbgVgoYdZ8rhhx jq4zP7G2ZYd9e0Y81XiVNSKCoLxpgcEsSAfN0BEWvTh0iyUeLL0PfNJmM7rVsYI6xEr9AQp/7WY yh11Hi5ME4goKVtPh3Jhkac7QgtmeYFvzElsNeh2ZACegYjPJV06PQsyAsottxQ983KAzmh0P2L CLiZWSKZUK/pZXAuDEMERo47CA4pbc97X8UhC7CEe+dMOgVlqJtV0mvcrWOd+YOMLxfVY2JY1dI hq5lJz5UBzn3CPGfCkkhcd1dkVLC2NxIMk2PEGrxEQl0VtoUg4YsAwRcIhZKtcYuRD08b9jG3xH UcRU5jkyx92hOpMptuGVNAZXh7QDO9y8t2NdHcYYTg0XA7zC7P9Eg8w7inoVeNbLgdvZUQ4P6J/ VSkYybMcNPrPkr4/R/b8vLw6+2NVPOMngI09EZJQMs= X-Received: by 2002:a05:600c:8b05:b0:49c:edd2:855 with SMTP id 5b1f17b1804b1-49cf823c411mr418633405e9.6.1789022102030; Wed, 09 Sep 2026 23:35:02 -0700 (PDT) Received: from localhost.localdomain (mob-31-26-103-238.net.vodafone.it. [31.26.103.238]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-49e2212193esm2595255e9.1.2026.09.09.23.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 23:35:01 -0700 (PDT) From: Oleg Keri To: Catalin Marinas , Will Deacon , Mark Rutland , Sumit Gupta , Prasanna Kumar T S M , Beata Michalska , Russell King , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Sudeep Holla , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Viresh Kumar Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, driver-core@lists.linux.dev, linux-pm@vger.kernel.org, jonathan.cameron@oss.qualcomm.com, sibi.sankar@oss.qualcomm.com Subject: [PATCH v3 2/2] cpufreq: update capacity_freq_ref when the boost state changes Date: Thu, 10 Sep 2026 08:34:40 +0200 Message-ID: <20260910063440.4677-3-okerixx@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260910063440.4677-1-okerixx@gmail.com> References: <20260910063440.4677-1-okerixx@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" capacity_freq_ref is latched from policy->cpuinfo.max_freq by init_cpu_capacity_callback() on CPUFREQ_CREATE_POLICY, and never updated afterwards. cpufreq_frequency_table_cpuinfo() excludes CPUFREQ_BOOST_FREQ entries while boost is disabled, so on a system that boots with boost off the latched value is the non-boost maximum. Enabling boost later raises policy->cpuinfo.max_freq but leaves capacity_freq_ref behind. Two things then go wrong on arm64, where the AMU drives frequency invariance. amu_scale_freq_tick() caps the computed scale at SCHED_CAPACITY_SCALE, so a CPU running above capacity_freq_ref saturates at 1024: the scheduler cannot tell a boosted CPU from one at the sustained maximum, and utilisation is underestimated. And arch_freq_get_on_cpu(), which reverses that computation, cannot report more than capacity_freq_ref, so cpuinfo_avg_freq is pinned to the non-boost maximum. On a Snapdragon X2 Elite (Glymur) laptop with a 4032000 kHz sustained and a 4723200 kHz boost OPP, cpuinfo_avg_freq reads exactly 4032000 while the CPU runs at 4723200; a fixed workload completes in 1.72 s rather than the 2.01 s that frequency would imply. Factor the update out of init_cpu_capacity_callback() into topology_update_freq_ref() and call it from policy_set_boost(), which is the common path for the global boost knob, the per-policy one, and the CPU online path. Signed-off-by: Oleg Keri --- arch/arm/include/asm/topology.h | 1 + arch/arm64/include/asm/topology.h | 1 + arch/riscv/include/asm/topology.h | 1 + drivers/base/arch_topology.c | 19 +++++++++++++------ drivers/cpufreq/cpufreq.c | 2 ++ include/linux/arch_topology.h | 1 + include/linux/cpufreq.h | 7 +++++++ 7 files changed, 26 insertions(+), 6 deletions(-) diff --git a/arch/arm/include/asm/topology.h b/arch/arm/include/asm/topolog= y.h index ad36b6570067..a776a79885ee 100644 --- a/arch/arm/include/asm/topology.h +++ b/arch/arm/include/asm/topology.h @@ -11,6 +11,7 @@ #ifndef CONFIG_BL_SWITCHER /* Replace task scheduler's default frequency-invariant accounting */ #define arch_set_freq_scale topology_set_freq_scale +#define arch_update_freq_ref topology_update_freq_ref #define arch_scale_freq_capacity topology_get_freq_scale #define arch_scale_freq_invariant topology_scale_freq_invariant #define arch_scale_freq_ref topology_get_freq_ref diff --git a/arch/arm64/include/asm/topology.h b/arch/arm64/include/asm/top= ology.h index b9eaf4ad7085..a4b96a7ee4a5 100644 --- a/arch/arm64/include/asm/topology.h +++ b/arch/arm64/include/asm/topology.h @@ -22,6 +22,7 @@ void update_freq_counters_refs(void); /* Replace task scheduler's default frequency-invariant accounting */ #define arch_scale_freq_tick topology_scale_freq_tick #define arch_set_freq_scale topology_set_freq_scale +#define arch_update_freq_ref topology_update_freq_ref #define arch_scale_freq_capacity topology_get_freq_scale #define arch_scale_freq_invariant topology_scale_freq_invariant #define arch_scale_freq_ref topology_get_freq_ref diff --git a/arch/riscv/include/asm/topology.h b/arch/riscv/include/asm/top= ology.h index fe1a8bf6902d..a363d72c174f 100644 --- a/arch/riscv/include/asm/topology.h +++ b/arch/riscv/include/asm/topology.h @@ -11,6 +11,7 @@ /* Replace task scheduler's default frequency-invariant accounting */ #define arch_scale_freq_tick topology_scale_freq_tick #define arch_set_freq_scale topology_set_freq_scale +#define arch_update_freq_ref topology_update_freq_ref #define arch_scale_freq_capacity topology_get_freq_scale #define arch_scale_freq_invariant topology_scale_freq_invariant #define arch_scale_freq_ref topology_get_freq_ref diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 8c5e47c28d9a..79eb1681065d 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -317,6 +317,18 @@ bool __init topology_parse_cpu_capacity(struct device_= node *cpu_node, int cpu) return !ret; } =20 +void topology_update_freq_ref(const struct cpumask *cpus, unsigned int max= _freq) +{ + int cpu; + + for_each_cpu(cpu, cpus) { + per_cpu(capacity_freq_ref, cpu) =3D max_freq; + freq_inv_set_max_ratio(cpu, + per_cpu(capacity_freq_ref, cpu) * HZ_PER_KHZ); + } +} +EXPORT_SYMBOL_GPL(topology_update_freq_ref); + void __weak freq_inv_set_max_ratio(int cpu, u64 max_rate) { } @@ -392,7 +404,6 @@ init_cpu_capacity_callback(struct notifier_block *nb, void *data) { struct cpufreq_policy *policy =3D data; - int cpu; =20 if (val !=3D CPUFREQ_CREATE_POLICY) return 0; @@ -403,11 +414,7 @@ init_cpu_capacity_callback(struct notifier_block *nb, =20 cpumask_andnot(cpus_to_visit, cpus_to_visit, policy->related_cpus); =20 - for_each_cpu(cpu, policy->related_cpus) { - per_cpu(capacity_freq_ref, cpu) =3D policy->cpuinfo.max_freq; - freq_inv_set_max_ratio(cpu, - per_cpu(capacity_freq_ref, cpu) * HZ_PER_KHZ); - } + topology_update_freq_ref(policy->related_cpus, policy->cpuinfo.max_freq); =20 if (cpumask_empty(cpus_to_visit)) { if (raw_capacity) { diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 96515880b4ac..a70805a1d9d3 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -594,6 +594,8 @@ static int policy_set_boost(struct cpufreq_policy *poli= cy, bool enable) return ret; } =20 + arch_update_freq_ref(policy->related_cpus, policy->cpuinfo.max_freq); + return 0; } =20 diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h index ebd7f8935f96..4974f5e1a7fe 100644 --- a/include/linux/arch_topology.h +++ b/include/linux/arch_topology.h @@ -31,6 +31,7 @@ static inline unsigned long topology_get_freq_scale(int c= pu) =20 void topology_set_freq_scale(const struct cpumask *cpus, unsigned long cur= _freq, unsigned long max_freq); +void topology_update_freq_ref(const struct cpumask *cpus, unsigned int max= _freq); bool topology_scale_freq_invariant(void); =20 enum scale_freq_source { diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 35ce665edfd8..5b904e13eb21 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -1235,6 +1235,13 @@ void arch_set_freq_scale(const struct cpumask *cpus, } #endif =20 +#ifndef arch_update_freq_ref +static __always_inline +void arch_update_freq_ref(const struct cpumask *cpus, unsigned int max_fre= q) +{ +} +#endif + /* the following are really really optional */ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs; --=20 2.55.0