All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Oleg Keri <okerixx@gmail.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Sumit Gupta <sumitg@nvidia.com>,
	Prasanna Kumar T S M <ptsm@linux.microsoft.com>,
	Beata Michalska <beata.michalska@arm.com>,
	Russell King <linux@armlinux.org.uk>,
	Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	Sudeep Holla <sudeep.holla@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>
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: Re: [PATCH v3 2/2] cpufreq: update capacity_freq_ref when the boost state changes
Date: Thu, 17 Sep 2026 11:57:57 +0200	[thread overview]
Message-ID: <f8b0745c-d265-4112-90fe-79a08ad01553@arm.com> (raw)
In-Reply-To: <20260910063440.4677-3-okerixx@gmail.com>

On 10.09.26 08:34, Oleg Keri wrote:
> 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

IMHO, this is where the concept of 'cpufreq pressure' on CPU capacity
comes in.

The cpu_capacity value is calculated based on highest_perf.	(1)

In case you start with 'boost == 0' nominal_perf might might be lower
than highest_perf.

cpufreq_update_pressure() calculates this value:

cpufreq_pressure = Cmax * (1 - fcapped - fmax)			(2)

[ fcapped = policy->max, fmax = capacity_freq_ref ]

Example on RADXA Orion 06 CPU10:

$ grep . /sys/devices/system/cpu/cpu10/acpi_cppc/*
...
/sys/devices/system/cpu/cpu10/acpi_cppc/highest_perf:7876
/sys/devices/system/cpu/cpu10/acpi_cppc/lowest_freq:800
/sys/devices/system/cpu/cpu10/acpi_cppc/lowest_nonlinear_perf:2520
/sys/devices/system/cpu/cpu10/acpi_cppc/lowest_perf:2520
/sys/devices/system/cpu/cpu10/acpi_cppc/nominal_freq:2500
/sys/devices/system/cpu/cpu10/acpi_cppc/nominal_perf:6600   <-- hacked
/sys/devices/system/cpu/cpu10/acpi_cppc/reference_perf:1000
...

# cat /sys/devices/system/cpu/cpu10/cpu_capacity	<-- (1)
984

# cat /sys/devices/system/cpu/cpu10/cpufreq/boost
0

dmesg (added log)

[    8.065337] cpufreq_update_pressure(): policy->related_cpus=[10-11]
policy->max=2500000 pressure=173			<-- (2)

# echo 1 > /sys/devices/system/cpu/cpufreq/boost

# cat /sys/devices/system/cpu/cpu10/cpufreq/boost
1

dmesg (added log)

[38137.194134] cpufreq_update_pressure(): policy->related_cpus=[10-11]
policy->max=3031666 pressure=0				<-- (2)

The task scheduler gets informed via:

get_actual_cpu_capacity(int cpu)

  capacity = arch_scale_cpu_capacity(cpu);

  capacity -= max(hw_load_avg(cpu_rq(cpu)), cpufreq_get_pressure(cpu));
                                            ^^^^^^^^^^^^^^^^^^^^
  return capacity;

[...]


WARNING: multiple messages have this Message-ID (diff)
From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Oleg Keri <okerixx@gmail.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Sumit Gupta <sumitg@nvidia.com>,
	Prasanna Kumar T S M <ptsm@linux.microsoft.com>,
	Beata Michalska <beata.michalska@arm.com>,
	Russell King <linux@armlinux.org.uk>,
	Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	Sudeep Holla <sudeep.holla@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>
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: Re: [PATCH v3 2/2] cpufreq: update capacity_freq_ref when the boost state changes
Date: Thu, 17 Sep 2026 11:57:57 +0200	[thread overview]
Message-ID: <f8b0745c-d265-4112-90fe-79a08ad01553@arm.com> (raw)
In-Reply-To: <20260910063440.4677-3-okerixx@gmail.com>

On 10.09.26 08:34, Oleg Keri wrote:
> 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

IMHO, this is where the concept of 'cpufreq pressure' on CPU capacity
comes in.

The cpu_capacity value is calculated based on highest_perf.	(1)

In case you start with 'boost == 0' nominal_perf might might be lower
than highest_perf.

cpufreq_update_pressure() calculates this value:

cpufreq_pressure = Cmax * (1 - fcapped - fmax)			(2)

[ fcapped = policy->max, fmax = capacity_freq_ref ]

Example on RADXA Orion 06 CPU10:

$ grep . /sys/devices/system/cpu/cpu10/acpi_cppc/*
...
/sys/devices/system/cpu/cpu10/acpi_cppc/highest_perf:7876
/sys/devices/system/cpu/cpu10/acpi_cppc/lowest_freq:800
/sys/devices/system/cpu/cpu10/acpi_cppc/lowest_nonlinear_perf:2520
/sys/devices/system/cpu/cpu10/acpi_cppc/lowest_perf:2520
/sys/devices/system/cpu/cpu10/acpi_cppc/nominal_freq:2500
/sys/devices/system/cpu/cpu10/acpi_cppc/nominal_perf:6600   <-- hacked
/sys/devices/system/cpu/cpu10/acpi_cppc/reference_perf:1000
...

# cat /sys/devices/system/cpu/cpu10/cpu_capacity	<-- (1)
984

# cat /sys/devices/system/cpu/cpu10/cpufreq/boost
0

dmesg (added log)

[    8.065337] cpufreq_update_pressure(): policy->related_cpus=[10-11]
policy->max=2500000 pressure=173			<-- (2)

# echo 1 > /sys/devices/system/cpu/cpufreq/boost

# cat /sys/devices/system/cpu/cpu10/cpufreq/boost
1

dmesg (added log)

[38137.194134] cpufreq_update_pressure(): policy->related_cpus=[10-11]
policy->max=3031666 pressure=0				<-- (2)

The task scheduler gets informed via:

get_actual_cpu_capacity(int cpu)

  capacity = arch_scale_cpu_capacity(cpu);

  capacity -= max(hw_load_avg(cpu_rq(cpu)), cpufreq_get_pressure(cpu));
                                            ^^^^^^^^^^^^^^^^^^^^
  return capacity;

[...]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2026-09-17  9:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10  6:34 [PATCH v3 0/2] arm64/cpufreq: report and track frequencies above 4.19 GHz Oleg Keri
2026-09-10  6:34 ` Oleg Keri
2026-09-10  6:34 ` [PATCH v3 1/2] arm64: topology: fix arch_freq_get_on_cpu() overflow " Oleg Keri
2026-09-10  6:34   ` Oleg Keri
2026-09-14  7:04   ` Beata Michalska
2026-09-14  7:04     ` Beata Michalska
2026-09-16 10:52   ` Dietmar Eggemann
2026-09-16 10:52     ` Dietmar Eggemann
2026-09-16 11:23     ` Oleg Keri
2026-09-17 10:01       ` Dietmar Eggemann
2026-09-10  6:34 ` [PATCH v3 2/2] cpufreq: update capacity_freq_ref when the boost state changes Oleg Keri
2026-09-10  6:34   ` Oleg Keri
2026-09-17  9:57   ` Dietmar Eggemann [this message]
2026-09-17  9:57     ` Dietmar Eggemann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f8b0745c-d265-4112-90fe-79a08ad01553@arm.com \
    --to=dietmar.eggemann@arm.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=beata.michalska@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=jonathan.cameron@oss.qualcomm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=okerixx@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=ptsm@linux.microsoft.com \
    --cc=rafael@kernel.org \
    --cc=sibi.sankar@oss.qualcomm.com \
    --cc=sudeep.holla@kernel.org \
    --cc=sumitg@nvidia.com \
    --cc=viresh.kumar@linaro.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.