diff mbox series

[v2,2/9] cpufreq: intel_pstate: Use topology_cpu_type()

Message ID 20240627-add-cpu-type-v2-2-f927bde83ad0@linux.intel.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series Add CPU-type to topology | expand

Commit Message

Pawan Gupta June 27, 2024, 8:44 p.m. UTC
Intel pstate driver uses hybrid_get_type() to get the cpu-type of a given
CPU. It uses smp_call_function_single() which is sub-optimal. Avoid it by
using topology_hw_cpu_type(cpu) that returns the cached cpu-type.

Suggested-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/cpufreq/intel_pstate.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

Comments

Rafael J. Wysocki July 1, 2024, 5:08 p.m. UTC | #1
On Thu, Jun 27, 2024 at 10:44 PM Pawan Gupta
<pawan.kumar.gupta@linux.intel.com> wrote:
>
> Intel pstate driver uses hybrid_get_type() to get the cpu-type of a given
> CPU. It uses smp_call_function_single() which is sub-optimal. Avoid it by
> using topology_hw_cpu_type(cpu) that returns the cached cpu-type.
>
> Suggested-by: Dave Hansen <dave.hansen@linux.intel.com>
> Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

and I'm assuming that it will be routed along with the rest of the series.

Thanks!

> ---
>  drivers/cpufreq/intel_pstate.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index 15de5e3d96fd..0a1e832c7536 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -1956,24 +1956,16 @@ static int knl_get_turbo_pstate(int cpu)
>         return ret;
>  }
>
> -static void hybrid_get_type(void *data)
> -{
> -       u8 *cpu_type = data;
> -
> -       *cpu_type = get_this_hybrid_cpu_type();
> -}
> -
>  static int hwp_get_cpu_scaling(int cpu)
>  {
> -       u8 cpu_type = 0;
> +       u8 cpu_type = topology_hw_cpu_type(cpu);
>
> -       smp_call_function_single(cpu, hybrid_get_type, &cpu_type, 1);
>         /* P-cores have a smaller perf level-to-freqency scaling factor. */
> -       if (cpu_type == 0x40)
> +       if (cpu_type == X86_HW_CPU_TYPE_INTEL_CORE)
>                 return hybrid_scaling_factor;
>
>         /* Use default core scaling for E-cores */
> -       if (cpu_type == 0x20)
> +       if (cpu_type == X86_HW_CPU_TYPE_INTEL_ATOM)
>                 return core_get_scaling();
>
>         /*
>
> --
Pawan Gupta July 1, 2024, 5:14 p.m. UTC | #2
On Mon, Jul 01, 2024 at 07:08:41PM +0200, Rafael J. Wysocki wrote:
> On Thu, Jun 27, 2024 at 10:44 PM Pawan Gupta
> <pawan.kumar.gupta@linux.intel.com> wrote:
> >
> > Intel pstate driver uses hybrid_get_type() to get the cpu-type of a given
> > CPU. It uses smp_call_function_single() which is sub-optimal. Avoid it by
> > using topology_hw_cpu_type(cpu) that returns the cached cpu-type.
> >
> > Suggested-by: Dave Hansen <dave.hansen@linux.intel.com>
> > Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
> > Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> 
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Thanks.

> and I'm assuming that it will be routed along with the rest of the series.

I believe yes, as it has a dependency on the first patch.
diff mbox series

Patch

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 15de5e3d96fd..0a1e832c7536 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1956,24 +1956,16 @@  static int knl_get_turbo_pstate(int cpu)
 	return ret;
 }
 
-static void hybrid_get_type(void *data)
-{
-	u8 *cpu_type = data;
-
-	*cpu_type = get_this_hybrid_cpu_type();
-}
-
 static int hwp_get_cpu_scaling(int cpu)
 {
-	u8 cpu_type = 0;
+	u8 cpu_type = topology_hw_cpu_type(cpu);
 
-	smp_call_function_single(cpu, hybrid_get_type, &cpu_type, 1);
 	/* P-cores have a smaller perf level-to-freqency scaling factor. */
-	if (cpu_type == 0x40)
+	if (cpu_type == X86_HW_CPU_TYPE_INTEL_CORE)
 		return hybrid_scaling_factor;
 
 	/* Use default core scaling for E-cores */
-	if (cpu_type == 0x20)
+	if (cpu_type == X86_HW_CPU_TYPE_INTEL_ATOM)
 		return core_get_scaling();
 
 	/*