From nobody Mon Feb 9 17:35:52 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFAEF16D9BB for ; Fri, 5 Apr 2024 13:33:44 +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=1712324026; cv=none; b=UdmjxZy79u4jERGKZq72x0kpX8C2i4JpgsFx1YNkshIaWt0oGcOLCjQePJ5CermPylotlNiLgSLkTcTUQEJJQHyzUTKKLr0tcZejSVVnqvxH8ADt9Ms3MuhHdql2FWICYkeVdn85U2UpJFhqTnkdGt2ObyMob9oDCjA7pVAmtUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712324026; c=relaxed/simple; bh=kz+tEnMtEhdbWTieH6GG8+9bRVOB65r+zQVMDMg3TnI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XbtvZY4PX+oz9Ay3GZliPzoytDFYOesdimqMiXLZ1ACp4PxHcTUbdo2N4tgtMszFQ2im92wcsWmStog1qDhHlPOxv0ZrXxXDjzYymCokrasoLOMDJfeq3wlfgCpNp2XSJVFRDyBCfjfWaIKulO0wRFPcjfXRZH9LNlpRyPllksI= 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 161BB169E; Fri, 5 Apr 2024 06:34:15 -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 0B3983F7B4; Fri, 5 Apr 2024 06:33:42 -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 3/4] arm64: Update AMU-based frequency scale factor on entering idle Date: Fri, 5 Apr 2024 14:33:18 +0100 Message-Id: <20240405133319.859813-4-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: quoted-printable Content-Type: text/plain; charset="utf-8" Now that the frequency scale factor has been activated for retrieving current frequency on a given CPU, trigger its update upon entering idle. This will, to an extent, allow querying last known frequency in a non-invasive way. It will also improve the frequency scale factor accuracy when a CPU entering idle did not receive a tick for a while. As a consequence, for idle cores, the reported frequency will be the last one observed before entering the idle state. Suggested-by: Vanshidhar Konda Signed-off-by: Beata Michalska --- arch/arm64/kernel/topology.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index b03fe8617721..f204f6489f98 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -207,6 +207,19 @@ static struct scale_freq_data amu_sfd =3D { .set_freq_scale =3D amu_scale_freq_tick, }; =20 +void arch_cpu_idle_enter(void) +{ + unsigned int cpu =3D smp_processor_id(); + + if (!cpumask_test_cpu(cpu, amu_fie_cpus)) + return; + + /* Kick in AMU update but only if one has not happened already */ + if (housekeeping_cpu(cpu, HK_TYPE_TICK) && + time_is_before_jiffies(per_cpu(cpu_amu_samples.last_update, cpu))) + amu_scale_freq_tick(); +} + #define AMU_SAMPLE_EXP_MS 20 =20 unsigned int arch_freq_get_on_cpu(int cpu) @@ -232,8 +245,8 @@ unsigned int arch_freq_get_on_cpu(int cpu) * this boils down to identifying an active cpu within the same freq * domain, if any. */ - if (!housekeeping_cpu(cpu, HK_TYPE_TICK) || - time_is_before_jiffies(last_update + msecs_to_jiffies(AMU_SAMPLE_EXP_= MS))) { + if (!housekeeping_cpu(cpu, HK_TYPE_TICK) || (!idle_cpu(cpu) && + time_is_before_jiffies(last_update + msecs_to_jiffies(AMU_SAMPLE_EXP_= MS)))) { struct cpufreq_policy *policy =3D cpufreq_cpu_get(cpu); int ref_cpu =3D cpu; =20 --=20 2.25.1