[PATCH] cpufreq: intel_pstate: Enable asym capacity only when cpu smt is not possible

Yaxiong Tian posted 1 patch 1 week, 5 days ago
There is a newer version of this series
drivers/cpufreq/intel_pstate.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
[PATCH] cpufreq: intel_pstate: Enable asym capacity only when cpu smt is not possible
Posted by Yaxiong Tian 1 week, 5 days ago
According to the description in the intel_pstate.rst documentation,
Capacity-Aware Scheduling and Energy-Aware Scheduling are only
supported on a hybrid processor without SMT. Previously, the system
used sched_smt_active() for judgment, which is not a strict condition
because users can switch it on or off via /sys at any time.

This could lead to incorrect driver settings in certain scenarios.
 For example, on a CPU that supports SMT, a user can disable SMT
via the nosmt parameter to enable asym capacity, and then re-enable
SMT via /sys. In such cases, some settings in the driver would no
longer be correct.

To address this issue, replace sched_smt_active() with cpu_smt_possible(),
and only enable asym capacity when cpu smt is not possible.

Fixes: 929ebc93ccaa ("cpufreq: intel_pstate: Set asymmetric CPU capacity on hybrid systems")
Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
---
 drivers/cpufreq/intel_pstate.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index ec4abe374573..8105c41861a3 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1142,8 +1142,11 @@ static void hybrid_refresh_cpu_capacity_scaling(void)
 
 static void hybrid_init_cpu_capacity_scaling(bool refresh)
 {
-	/* Bail out if enabling capacity-aware scheduling is prohibited. */
-	if (no_cas)
+	/*
+	 * Bail out if capacity-aware scheduling is prohibited, or if SMT is
+	 * possible, as the capacity of SMT threads cannot be determined reliably.
+	 */
+	if (no_cas || cpu_smt_possible())
 		return;
 
 	/*
@@ -1156,12 +1159,8 @@ static void hybrid_init_cpu_capacity_scaling(bool refresh)
 		return;
 	}
 
-	/*
-	 * On hybrid systems, use asym capacity instead of ITMT, but because
-	 * the capacity of SMT threads is not deterministic even approximately,
-	 * do not do that when SMT is in use.
-	 */
-	if (hwp_is_hybrid && !sched_smt_active() && arch_enable_hybrid_capacity_scale()) {
+	/* On hybrid systems, use asym capacity instead of ITMT */
+	if (hwp_is_hybrid && arch_enable_hybrid_capacity_scale()) {
 		hybrid_refresh_cpu_capacity_scaling();
 		/*
 		 * Disabling ITMT causes sched domains to be rebuilt to disable asym
-- 
2.25.1
Re: [PATCH] cpufreq: intel_pstate: Enable asym capacity only when cpu smt is not possible
Posted by Rafael J. Wysocki 1 week, 4 days ago
On Wed, Jan 28, 2026 at 4:15 AM Yaxiong Tian <tianyaxiong@kylinos.cn> wrote:
>
> According to the description in the intel_pstate.rst documentation,
> Capacity-Aware Scheduling and Energy-Aware Scheduling are only
> supported on a hybrid processor without SMT. Previously, the system
> used sched_smt_active() for judgment, which is not a strict condition
> because users can switch it on or off via /sys at any time.
>
> This could lead to incorrect driver settings in certain scenarios.
>  For example, on a CPU that supports SMT, a user can disable SMT
> via the nosmt parameter to enable asym capacity, and then re-enable
> SMT via /sys. In such cases, some settings in the driver would no
> longer be correct.
>
> To address this issue, replace sched_smt_active() with cpu_smt_possible(),
> and only enable asym capacity when cpu smt is not possible.
>
> Fixes: 929ebc93ccaa ("cpufreq: intel_pstate: Set asymmetric CPU capacity on hybrid systems")
> Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
> ---
>  drivers/cpufreq/intel_pstate.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index ec4abe374573..8105c41861a3 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -1142,8 +1142,11 @@ static void hybrid_refresh_cpu_capacity_scaling(void)
>
>  static void hybrid_init_cpu_capacity_scaling(bool refresh)
>  {
> -       /* Bail out if enabling capacity-aware scheduling is prohibited. */
> -       if (no_cas)
> +       /*
> +        * Bail out if capacity-aware scheduling is prohibited, or if SMT is
> +        * possible, as the capacity of SMT threads cannot be determined reliably.
> +        */
> +       if (no_cas || cpu_smt_possible())
>                 return;
>
>         /*
> @@ -1156,12 +1159,8 @@ static void hybrid_init_cpu_capacity_scaling(bool refresh)
>                 return;
>         }
>
> -       /*
> -        * On hybrid systems, use asym capacity instead of ITMT, but because
> -        * the capacity of SMT threads is not deterministic even approximately,
> -        * do not do that when SMT is in use.
> -        */
> -       if (hwp_is_hybrid && !sched_smt_active() && arch_enable_hybrid_capacity_scale()) {

Why don't you replace sched_smt_active() here with cpu_smt_possible()?

There's no point calling arch_enable_hybrid_capacity_scale() if the
latter is true.

> +       /* On hybrid systems, use asym capacity instead of ITMT */
> +       if (hwp_is_hybrid && arch_enable_hybrid_capacity_scale()) {
>                 hybrid_refresh_cpu_capacity_scaling();
>                 /*
>                  * Disabling ITMT causes sched domains to be rebuilt to disable asym
> --
Re: [PATCH] cpufreq: intel_pstate: Enable asym capacity only when cpu smt is not possible
Posted by Yaxiong Tian 1 week, 4 days ago
在 2026/1/29 05:21, Rafael J. Wysocki 写道:
> On Wed, Jan 28, 2026 at 4:15 AM Yaxiong Tian <tianyaxiong@kylinos.cn> wrote:
>> According to the description in the intel_pstate.rst documentation,
>> Capacity-Aware Scheduling and Energy-Aware Scheduling are only
>> supported on a hybrid processor without SMT. Previously, the system
>> used sched_smt_active() for judgment, which is not a strict condition
>> because users can switch it on or off via /sys at any time.
>>
>> This could lead to incorrect driver settings in certain scenarios.
>>   For example, on a CPU that supports SMT, a user can disable SMT
>> via the nosmt parameter to enable asym capacity, and then re-enable
>> SMT via /sys. In such cases, some settings in the driver would no
>> longer be correct.
>>
>> To address this issue, replace sched_smt_active() with cpu_smt_possible(),
>> and only enable asym capacity when cpu smt is not possible.
>>
>> Fixes: 929ebc93ccaa ("cpufreq: intel_pstate: Set asymmetric CPU capacity on hybrid systems")
>> Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
>> ---
>>   drivers/cpufreq/intel_pstate.c | 15 +++++++--------
>>   1 file changed, 7 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
>> index ec4abe374573..8105c41861a3 100644
>> --- a/drivers/cpufreq/intel_pstate.c
>> +++ b/drivers/cpufreq/intel_pstate.c
>> @@ -1142,8 +1142,11 @@ static void hybrid_refresh_cpu_capacity_scaling(void)
>>
>>   static void hybrid_init_cpu_capacity_scaling(bool refresh)
>>   {
>> -       /* Bail out if enabling capacity-aware scheduling is prohibited. */
>> -       if (no_cas)
>> +       /*
>> +        * Bail out if capacity-aware scheduling is prohibited, or if SMT is
>> +        * possible, as the capacity of SMT threads cannot be determined reliably.
>> +        */
>> +       if (no_cas || cpu_smt_possible())
>>                  return;
>>
>>          /*
>> @@ -1156,12 +1159,8 @@ static void hybrid_init_cpu_capacity_scaling(bool refresh)
>>                  return;
>>          }
>>
>> -       /*
>> -        * On hybrid systems, use asym capacity instead of ITMT, but because
>> -        * the capacity of SMT threads is not deterministic even approximately,
>> -        * do not do that when SMT is in use.
>> -        */
>> -       if (hwp_is_hybrid && !sched_smt_active() && arch_enable_hybrid_capacity_scale()) {
> Why don't you replace sched_smt_active() here with cpu_smt_possible()?
>
> There's no point calling arch_enable_hybrid_capacity_scale() if the
> latter is true.
Because I think cpu_smt_possible() becomes fixed after kernel startup. 
Placing this check earlier can also prevent calling 
arch_enable_hybrid_capacity_scale(). Additionally, when users switch the 
cpufreq driver via /sys/devices/system/cpu/intel_pstate/status, it's 
unnecessary to proceed with further checks.
>> +       /* On hybrid systems, use asym capacity instead of ITMT */
>> +       if (hwp_is_hybrid && arch_enable_hybrid_capacity_scale()) {
>>                  hybrid_refresh_cpu_capacity_scaling();
>>                  /*
>>                   * Disabling ITMT causes sched domains to be rebuilt to disable asym
>> --
Re: [PATCH] cpufreq: intel_pstate: Enable asym capacity only when cpu smt is not possible
Posted by Yaxiong Tian 1 week, 4 days ago
在 2026/1/29 09:21, Yaxiong Tian 写道:
>
> 在 2026/1/29 05:21, Rafael J. Wysocki 写道:
>> On Wed, Jan 28, 2026 at 4:15 AM Yaxiong Tian <tianyaxiong@kylinos.cn> 
>> wrote:
>>> According to the description in the intel_pstate.rst documentation,
>>> Capacity-Aware Scheduling and Energy-Aware Scheduling are only
>>> supported on a hybrid processor without SMT. Previously, the system
>>> used sched_smt_active() for judgment, which is not a strict condition
>>> because users can switch it on or off via /sys at any time.
>>>
>>> This could lead to incorrect driver settings in certain scenarios.
>>>   For example, on a CPU that supports SMT, a user can disable SMT
>>> via the nosmt parameter to enable asym capacity, and then re-enable
>>> SMT via /sys. In such cases, some settings in the driver would no
>>> longer be correct.
>>>
>>> To address this issue, replace sched_smt_active() with 
>>> cpu_smt_possible(),
>>> and only enable asym capacity when cpu smt is not possible.
>>>
>>> Fixes: 929ebc93ccaa ("cpufreq: intel_pstate: Set asymmetric CPU 
>>> capacity on hybrid systems")
>>> Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
>>> ---
>>>   drivers/cpufreq/intel_pstate.c | 15 +++++++--------
>>>   1 file changed, 7 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/cpufreq/intel_pstate.c 
>>> b/drivers/cpufreq/intel_pstate.c
>>> index ec4abe374573..8105c41861a3 100644
>>> --- a/drivers/cpufreq/intel_pstate.c
>>> +++ b/drivers/cpufreq/intel_pstate.c
>>> @@ -1142,8 +1142,11 @@ static void 
>>> hybrid_refresh_cpu_capacity_scaling(void)
>>>
>>>   static void hybrid_init_cpu_capacity_scaling(bool refresh)
>>>   {
>>> -       /* Bail out if enabling capacity-aware scheduling is 
>>> prohibited. */
>>> -       if (no_cas)
>>> +       /*
>>> +        * Bail out if capacity-aware scheduling is prohibited, or 
>>> if SMT is
>>> +        * possible, as the capacity of SMT threads cannot be 
>>> determined reliably.
>>> +        */
>>> +       if (no_cas || cpu_smt_possible())
>>>                  return;
>>>
>>>          /*
>>> @@ -1156,12 +1159,8 @@ static void 
>>> hybrid_init_cpu_capacity_scaling(bool refresh)
>>>                  return;
>>>          }
>>>
>>> -       /*
>>> -        * On hybrid systems, use asym capacity instead of ITMT, but 
>>> because
>>> -        * the capacity of SMT threads is not deterministic even 
>>> approximately,
>>> -        * do not do that when SMT is in use.
>>> -        */
>>> -       if (hwp_is_hybrid && !sched_smt_active() && 
>>> arch_enable_hybrid_capacity_scale()) {
>> Why don't you replace sched_smt_active() here with cpu_smt_possible()?
>>
>> There's no point calling arch_enable_hybrid_capacity_scale() if the
>> latter is true.
> Because I think cpu_smt_possible() becomes fixed after kernel startup. 
> Placing this check earlier can also prevent calling 
> arch_enable_hybrid_capacity_scale(). Additionally, when users switch 
> the cpufreq driver via /sys/devices/system/cpu/intel_pstate/status, 
> it's unnecessary to proceed with further checks.


Sorry, `cpu_smt_possible()` can also be changed via the `/sys` interface, but only once.

When the CPU supports SMT and SMT is switched to "force", if the user immediately switches the cpufreq driver afterwards, the initialization path will be triggered, which re-executes the relevant initialization. At this point, `cpu_smt_possible()` becomes fixed. If switching is performed again later, the refresh path will be taken and `arch_enable_hybrid_capacity_scale()` will not be called again, to prevent warning messages.

If the CPU does not support SMT from the beginning, `cpu_smt_possible()` is fixed from kernel boot and can also be refreshed without calling `arch_enable_hybrid_capacity_scale()`.

Placing this logic earlier has the advantage of reducing some condition checks when `cpu_smt_possible()` is true.

>>> +       /* On hybrid systems, use asym capacity instead of ITMT */
>>> +       if (hwp_is_hybrid && arch_enable_hybrid_capacity_scale()) {
>>>                  hybrid_refresh_cpu_capacity_scaling();
>>>                  /*
>>>                   * Disabling ITMT causes sched domains to be 
>>> rebuilt to disable asym
>>> -- 
[PATCH v2] cpufreq: intel_pstate: Enable asym capacity only when cpu smt is not possible
Posted by Yaxiong Tian 6 days, 4 hours ago
According to the description in the intel_pstate.rst documentation,
Capacity-Aware Scheduling and Energy-Aware Scheduling are only
supported on a hybrid processor without SMT. Previously, the system
used sched_smt_active() for judgment, which is not a strict condition
because users can switch it on or off via /sys at any time.

This could lead to incorrect driver settings in certain scenarios.
 For example, on a CPU that supports SMT, a user can disable SMT
via the nosmt parameter to enable asym capacity, and then re-enable
SMT via /sys. In such cases, some settings in the driver would no
longer be correct.

To address this issue, replace sched_smt_active() with cpu_smt_possible(),
and only enable asym capacity when cpu smt is not possible.

Fixes: 929ebc93ccaa ("cpufreq: intel_pstate: Set asymmetric CPU capacity on hybrid systems")
Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
---
 drivers/cpufreq/intel_pstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index ec4abe374573..1625ec2d0d06 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1161,7 +1161,7 @@ static void hybrid_init_cpu_capacity_scaling(bool refresh)
 	 * the capacity of SMT threads is not deterministic even approximately,
 	 * do not do that when SMT is in use.
 	 */
-	if (hwp_is_hybrid && !sched_smt_active() && arch_enable_hybrid_capacity_scale()) {
+	if (hwp_is_hybrid && !cpu_smt_possible() && arch_enable_hybrid_capacity_scale()) {
 		hybrid_refresh_cpu_capacity_scaling();
 		/*
 		 * Disabling ITMT causes sched domains to be rebuilt to disable asym
-- 
2.25.1
Re: [PATCH v2] cpufreq: intel_pstate: Enable asym capacity only when cpu smt is not possible
Posted by Rafael J. Wysocki 5 days, 9 hours ago
On Tue, Feb 3, 2026 at 3:49 AM Yaxiong Tian <tianyaxiong@kylinos.cn> wrote:
>
> According to the description in the intel_pstate.rst documentation,
> Capacity-Aware Scheduling and Energy-Aware Scheduling are only
> supported on a hybrid processor without SMT. Previously, the system
> used sched_smt_active() for judgment, which is not a strict condition
> because users can switch it on or off via /sys at any time.
>
> This could lead to incorrect driver settings in certain scenarios.
>  For example, on a CPU that supports SMT, a user can disable SMT
> via the nosmt parameter to enable asym capacity, and then re-enable
> SMT via /sys. In such cases, some settings in the driver would no
> longer be correct.
>
> To address this issue, replace sched_smt_active() with cpu_smt_possible(),
> and only enable asym capacity when cpu smt is not possible.
>
> Fixes: 929ebc93ccaa ("cpufreq: intel_pstate: Set asymmetric CPU capacity on hybrid systems")
> Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
> ---
>  drivers/cpufreq/intel_pstate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index ec4abe374573..1625ec2d0d06 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -1161,7 +1161,7 @@ static void hybrid_init_cpu_capacity_scaling(bool refresh)
>          * the capacity of SMT threads is not deterministic even approximately,
>          * do not do that when SMT is in use.
>          */
> -       if (hwp_is_hybrid && !sched_smt_active() && arch_enable_hybrid_capacity_scale()) {
> +       if (hwp_is_hybrid && !cpu_smt_possible() && arch_enable_hybrid_capacity_scale()) {
>                 hybrid_refresh_cpu_capacity_scaling();
>                 /*
>                  * Disabling ITMT causes sched domains to be rebuilt to disable asym
> --

Applied as 6.20/7.0 material, thanks!