From: "Gautham R. Shenoy" <gautham.shenoy@amd.com>
To: Mario Limonciello <superm1@kernel.org>
Cc: Perry Yuan <perry.yuan@amd.com>,
"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<linux-kernel@vger.kernel.org>,
"open list:CPU FREQUENCY SCALING FRAMEWORK"
<linux-pm@vger.kernel.org>,
Mario Limonciello <mario.limonciello@amd.com>
Subject: Re: [PATCH v5 1/5] cpufreq/amd-pstate: Add dynamic energy performance preference
Date: Fri, 27 Mar 2026 12:13:25 +0530 [thread overview]
Message-ID: <acYnDaMzU8cU9tjk@BLRRASHENOY1.amd.com> (raw)
In-Reply-To: <20260106051441.60093-2-superm1@kernel.org>
Hello Mario,
On Mon, Jan 05, 2026 at 11:14:37PM -0600, Mario Limonciello wrote:
> From: Mario Limonciello <mario.limonciello@amd.com>
>
> Dynamic energy performance preference will change the EPP profile
> based on whether the machine is running on AC or DC power.
>
> A notification chain from the power supply core is used to adjust
> EPP values on plug in or plug out events.
>
> For non-server systems:
> * the default EPP for AC mode is `performance`.
> * the default EPP for DC mode is `balance_performance`.
In addition to these, the commit also adds a sysfs toggle, blocks
manual EPP, forces PERFORMANCE policy.
Might be good to mention these in the commit log.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
[..snip..]
> +static int amd_pstate_set_dynamic_epp(struct cpufreq_policy *policy)
> +{
> + struct amd_cpudata *cpudata = policy->driver_data;
> + int ret;
> + u8 epp;
> +
> + epp = amd_pstate_get_balanced_epp(policy);
> + ret = amd_pstate_set_epp(policy, epp);
> + if (ret)
> + return ret;
> +
> + /* only enable notifier if things will actually change */
> + if (cpudata->epp_default_ac != cpudata->epp_default_dc) {
> + ret = power_supply_reg_notifier(&cpudata->power_nb);
> + if (ret)
> + goto cleanup;
> + cpudata->power_nb.notifier_call = amd_pstate_power_supply_notifier;
> + }
> +
> + cpudata->dynamic_epp = true;
> +
> + return 0;
> +
> +cleanup:
> + amd_pstate_clear_dynamic_epp(policy);
> +
> + return ret;
> +}
Can the notifier_call assignment and registration be reordered?
The cpudata struct is allocated with kzalloc, so
power_nb.notifier_call is NULL when power_supply_reg_notifier() is
called. power_supply_reg_notifier() calls
blocking_notifier_chain_register(), which adds the notifier block to
the chain and then releases the rwsem.
If power_supply_changed_work() fires between the registration and the
assignment, the notification path reaches notifier_call_chain():
kernel/notifier.c:notifier_call_chain() {
...
ret = nb->notifier_call(nb, val, v);
...
}
At this point notifier_call is still NULL, resulting in a NULL pointer
dereference. Setting notifier_call before calling
power_supply_reg_notifier() would close this window.
> +
> /* Sysfs attributes */
>
[..snip..]
>
> static struct freq_attr *amd_pstate_attr[] = {
> &amd_pstate_max_freq,
> @@ -1421,6 +1528,7 @@ static struct freq_attr *amd_pstate_epp_attr[] = {
> static struct attribute *pstate_global_attributes[] = {
> &dev_attr_status.attr,
> &dev_attr_prefcore.attr,
> + &dev_attr_dynamic_epp.attr,
> NULL
> };
>
> @@ -1512,15 +1620,20 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
> if (amd_pstate_acpi_pm_profile_server() ||
> amd_pstate_acpi_pm_profile_undefined()) {
> policy->policy = CPUFREQ_POLICY_PERFORMANCE;
> - cpudata->epp_default = amd_pstate_get_epp(cpudata);
> + cpudata->epp_default_ac = cpudata->epp_default_dc = amd_pstate_get_epp(cpudata);
I wonder if we can set dynamic_epp to false for Server platforms.
The reason being that there are Server users who switch to the
powersave governor via a systemd startup script to set the right EPP.
With dynamic_epp = true, this is no longer possible. The user has to
first disable dynamic_epp and then switch to the powersave govenor.
Or perhaps you have a commandline override to disable dynamic_epp at boot time ?
--
Thanks and Regards
gautham.
next prev parent reply other threads:[~2026-03-27 6:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-06 5:14 [PATCH v5 0/5] amd-pstate Dynamic EPP and raw EPP Mario Limonciello (AMD)
2026-01-06 5:14 ` [PATCH v5 1/5] cpufreq/amd-pstate: Add dynamic energy performance preference Mario Limonciello (AMD)
2026-03-27 6:43 ` Gautham R. Shenoy [this message]
2026-01-06 5:14 ` [PATCH v5 2/5] cpufreq/amd-pstate: add kernel command line to override dynamic epp Mario Limonciello (AMD)
2026-03-27 6:45 ` Gautham R. Shenoy
2026-01-06 5:14 ` [PATCH v5 3/5] cpufreq/amd-pstate: Add support for platform profile class Mario Limonciello (AMD)
2026-03-27 6:58 ` Gautham R. Shenoy
2026-01-06 5:14 ` [PATCH v5 4/5] cpufreq/amd-pstate: Add support for raw EPP writes Mario Limonciello (AMD)
2026-03-27 8:41 ` Gautham R. Shenoy
2026-01-06 5:14 ` [PATCH v5 5/5] cpufreq/amd-pstate-ut: Add a unit test for raw EPP Mario Limonciello (AMD)
2026-03-27 8:59 ` Gautham R. Shenoy
2026-03-31 12:09 ` [PATCH v5 0/5] amd-pstate Dynamic EPP and " Mario Limonciello
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=acYnDaMzU8cU9tjk@BLRRASHENOY1.amd.com \
--to=gautham.shenoy@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=perry.yuan@amd.com \
--cc=superm1@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox