From: Pierre Gondois <pierre.gondois@arm.com>
To: Sumit Gupta <sumitg@nvidia.com>,
rafael@kernel.org, viresh.kumar@linaro.org,
zhenglifeng1@huawei.com, ionela.voinescu@arm.com,
lenb@kernel.org, robert.moore@intel.com, corbet@lwn.net,
rdunlap@infradead.org, ray.huang@amd.com, gautham.shenoy@amd.com,
mario.limonciello@amd.com, perry.yuan@amd.com,
zhanjie9@hisilicon.com, linux-pm@vger.kernel.org,
linux-acpi@vger.kernel.org, linux-doc@vger.kernel.org,
acpica-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: linux-tegra@vger.kernel.org, treding@nvidia.com,
jonathanh@nvidia.com, vsethi@nvidia.com, ksitaraman@nvidia.com,
sanjayc@nvidia.com, nhartman@nvidia.com, bbasu@nvidia.com
Subject: Re: [PATCH v6 7/9] ACPI: CPPC: add APIs and sysfs interface for perf_limited
Date: Mon, 26 Jan 2026 12:23:01 +0100 [thread overview]
Message-ID: <4c76cbfc-2e7e-4937-a838-09c49440d3ad@arm.com> (raw)
In-Reply-To: <7d2ad4f1-7d04-4032-bff9-65eed15c7318@nvidia.com>
On 1/24/26 22:04, Sumit Gupta wrote:
>
> On 22/01/26 17:21, Pierre Gondois wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> On 1/20/26 15:56, Sumit Gupta wrote:
>>> Add sysfs interface to read/write the Performance Limited register.
>>>
>>> The Performance Limited register indicates to the OS that an
>>> unpredictable event (like thermal throttling) has limited processor
>>> performance. It contains two sticky bits set by the platform:
>>> - Bit 0 (Desired_Excursion): Set when delivered performance is
>>> constrained below desired performance. Not used when Autonomous
>>> Selection is enabled.
>>> - Bit 1 (Minimum_Excursion): Set when delivered performance is
>>> constrained below minimum performance.
>>>
>>> These bits remain set until OSPM explicitly clears them. The write
>>> operation accepts a bitmask of bits to clear:
>>> - Write 0x1 to clear bit 0
>>> - Write 0x2 to clear bit 1
>>> - Write 0x3 to clear both bits
>>>
>>> This enables users to detect if platform throttling impacted a
>>> workload.
>>> Users clear the register before execution, run the workload, then check
>>> afterward - if set, hardware throttling occurred during that time
>>> window.
>>>
>>> The interface is exposed as:
>>> /sys/devices/system/cpu/cpuX/cpufreq/perf_limited
>>>
>>> Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
>>> ---
>>> drivers/acpi/cppc_acpi.c | 56
>>> ++++++++++++++++++++++++++++++++++
>>> drivers/cpufreq/cppc_cpufreq.c | 5 +++
>>> include/acpi/cppc_acpi.h | 15 +++++++++
>>> 3 files changed, 76 insertions(+)
>>>
>>> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
>>> index 46bf45f8b0f3..b46f22f58f56 100644
>>> --- a/drivers/acpi/cppc_acpi.c
>>> +++ b/drivers/acpi/cppc_acpi.c
>>> @@ -1787,6 +1787,62 @@ int cppc_set_max_perf(int cpu, u32 max_perf)
>>> }
>>> EXPORT_SYMBOL_GPL(cppc_set_max_perf);
>>>
>>> +/**
>>> + * cppc_get_perf_limited - Get the Performance Limited register value.
>>> + * @cpu: CPU from which to get Performance Limited register.
>>> + * @perf_limited: Pointer to store the Performance Limited value.
>>> + *
>>> + * The returned value contains sticky status bits indicating
>>> platform-imposed
>>> + * performance limitations.
>>> + *
>>> + * Return: 0 for success, -EIO on failure, -EOPNOTSUPP if not
>>> supported.
>>> + */
>>> +int cppc_get_perf_limited(int cpu, u64 *perf_limited)
>>> +{
>>> + return cppc_get_reg_val(cpu, PERF_LIMITED, perf_limited);
>>> +}
>>> +EXPORT_SYMBOL_GPL(cppc_get_perf_limited);
>>> +
>>> +/**
>>> + * cppc_set_perf_limited() - Clear bits in the Performance Limited
>>> register.
>>> + * @cpu: CPU on which to write register.
>>> + * @bits_to_clear: Bitmask of bits to clear in the perf_limited
>>> register.
>>> + *
>>> + * The Performance Limited register contains two sticky bits set by
>>> platform:
>>> + * - Bit 0 (Desired_Excursion): Set when delivered performance is
>>> constrained
>>> + * below desired performance. Not used when Autonomous
>>> Selection is enabled.
>>> + * - Bit 1 (Minimum_Excursion): Set when delivered performance is
>>> constrained
>>> + * below minimum performance.
>>> + *
>>> + * These bits are sticky and remain set until OSPM explicitly
>>> clears them.
>>> + * This function only allows clearing bits (the platform sets them).
>>> + *
>>> + * Return: 0 for success, -EINVAL for invalid bits, -EIO on register
>>> + * access failure, -EOPNOTSUPP if not supported.
>>> + */
>>> +int cppc_set_perf_limited(int cpu, u64 bits_to_clear)
>>> +{
>>> + u64 current_val, new_val;
>>> + int ret;
>>> +
>>> + /* Only bits 0 and 1 are valid */
>>> + if (bits_to_clear & ~CPPC_PERF_LIMITED_MASK)
>>> + return -EINVAL;
>>> +
>>> + if (!bits_to_clear)
>>> + return 0;
>>> +
>>> + ret = cppc_get_perf_limited(cpu, ¤t_val);
>>> + if (ret)
>>> + return ret;
>>> +
>>> + /* Clear the specified bits */
>>> + new_val = current_val & ~bits_to_clear;
>>> +
>>> + return cppc_set_reg_val(cpu, PERF_LIMITED, new_val);
>>> +}
>>> +EXPORT_SYMBOL_GPL(cppc_set_perf_limited);
>>> +
>>> /**
>>> * cppc_set_enable - Set to enable CPPC on the processor by
>>> writing the
>>> * Continuous Performance Control package EnableRegister field.
>>> diff --git a/drivers/cpufreq/cppc_cpufreq.c
>>> b/drivers/cpufreq/cppc_cpufreq.c
>>> index 66e183b45fb0..afb2cdb67a2f 100644
>>> --- a/drivers/cpufreq/cppc_cpufreq.c
>>> +++ b/drivers/cpufreq/cppc_cpufreq.c
>>> @@ -1071,12 +1071,16 @@ static ssize_t store_max_perf(struct
>>> cpufreq_policy *policy, const char *buf,
>>> return count;
>>> }
>>>
>>> +CPPC_CPUFREQ_ATTR_RW_U64(perf_limited, cppc_get_perf_limited,
>>> + cppc_set_perf_limited)
>>> +
>>> cpufreq_freq_attr_ro(freqdomain_cpus);
>>> cpufreq_freq_attr_rw(auto_select);
>>> cpufreq_freq_attr_rw(auto_act_window);
>>> cpufreq_freq_attr_rw(energy_performance_preference_val);
>>> cpufreq_freq_attr_rw(min_perf);
>>> cpufreq_freq_attr_rw(max_perf);
>>> +cpufreq_freq_attr_rw(perf_limited);
>>
>> If the OS wants to get regular feedback about whether the platform had
>> to limit
>> the perf. level, it will likely try to frequently probe the register.
>> In order to see new events, the register must be cleared. So:
>> - is it a good idea to allow users to write this register ?
>> - is it useful to expose this register if the OS frequently clears it ?
>>
>> I think the functions are useful, it might just be questionable to
>> expose
>> the register in the sysfs.
>>
>
> Currently the kernel doesn't automatically poll or clear perf_limited,
> so sysfs exposure is for manual monitoring. I can make it read-only
> but then users can only observe throttling events and can't clear
> them (though bits stay sticky). So, better to expose as RW attribute.
>
Ok right
next prev parent reply other threads:[~2026-01-26 11:24 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-20 14:56 [PATCH v6 0/9] Enhanced autonomous selection and improvements Sumit Gupta
2026-01-20 14:56 ` [PATCH v6 1/9] cpufreq: CPPC: Add generic helpers for sysfs show/store Sumit Gupta
2026-01-22 8:27 ` zhenglifeng (A)
2026-01-27 16:24 ` Rafael J. Wysocki
2026-01-27 19:01 ` Sumit Gupta
2026-01-27 20:17 ` Rafael J. Wysocki
2026-01-20 14:56 ` [PATCH v6 2/9] ACPI: CPPC: Clean up cppc_perf_caps and cppc_perf_ctrls structs Sumit Gupta
2026-01-22 8:28 ` zhenglifeng (A)
2026-01-27 16:27 ` Rafael J. Wysocki
2026-01-27 19:11 ` Sumit Gupta
2026-01-20 14:56 ` [PATCH v6 3/9] ACPI: CPPC: Rename EPP constants for clarity Sumit Gupta
2026-01-22 8:31 ` zhenglifeng (A)
2026-01-20 14:56 ` [PATCH v6 4/9] ACPI: CPPC: Add cppc_get_perf() API to read performance controls Sumit Gupta
2026-01-22 8:56 ` zhenglifeng (A)
2026-01-22 11:30 ` Pierre Gondois
2026-01-22 11:42 ` zhenglifeng (A)
2026-01-24 20:05 ` Sumit Gupta
2026-01-24 20:19 ` Sumit Gupta
2026-01-26 11:20 ` Pierre Gondois
2026-01-27 11:08 ` Sumit Gupta
2026-01-20 14:56 ` [PATCH v6 5/9] ACPI: CPPC: Extend cppc_set_epp_perf() for FFH/SystemMemory Sumit Gupta
2026-01-22 9:18 ` zhenglifeng (A)
2026-01-24 20:08 ` Sumit Gupta
2026-01-26 8:10 ` zhenglifeng (A)
2026-01-27 11:17 ` Sumit Gupta
2026-01-20 14:56 ` [PATCH v6 6/9] ACPI: CPPC: add APIs and sysfs interface for min/max_perf Sumit Gupta
2026-01-22 11:36 ` Pierre Gondois
2026-01-24 20:32 ` Sumit Gupta
2026-01-26 10:51 ` Pierre Gondois
2026-01-27 11:22 ` Sumit Gupta
2026-01-22 12:35 ` zhenglifeng (A)
2026-01-24 20:52 ` Sumit Gupta
2026-01-20 14:56 ` [PATCH v6 7/9] ACPI: CPPC: add APIs and sysfs interface for perf_limited Sumit Gupta
2026-01-22 11:51 ` Pierre Gondois
2026-01-24 21:04 ` Sumit Gupta
2026-01-26 11:23 ` Pierre Gondois [this message]
2026-01-20 14:56 ` [PATCH v6 8/9] cpufreq: CPPC: Add sysfs for min/max_perf and perf_limited Sumit Gupta
2026-01-20 14:56 ` [PATCH v6 9/9] cpufreq: CPPC: Update cached perf_ctrls on sysfs write Sumit Gupta
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=4c76cbfc-2e7e-4937-a838-09c49440d3ad@arm.com \
--to=pierre.gondois@arm.com \
--cc=acpica-devel@lists.linux.dev \
--cc=bbasu@nvidia.com \
--cc=corbet@lwn.net \
--cc=gautham.shenoy@amd.com \
--cc=ionela.voinescu@arm.com \
--cc=jonathanh@nvidia.com \
--cc=ksitaraman@nvidia.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=nhartman@nvidia.com \
--cc=perry.yuan@amd.com \
--cc=rafael@kernel.org \
--cc=ray.huang@amd.com \
--cc=rdunlap@infradead.org \
--cc=robert.moore@intel.com \
--cc=sanjayc@nvidia.com \
--cc=sumitg@nvidia.com \
--cc=treding@nvidia.com \
--cc=viresh.kumar@linaro.org \
--cc=vsethi@nvidia.com \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@huawei.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®