diff mbox series

[2/9] cpufreq: intel_pstate: Use topology_cpu_type() to get cpu-type

Message ID 20240617-add-cpu-type-v1-2-b88998c01e76@linux.intel.com (mailing list archive)
State Not Applicable, archived
Headers show
Series Add CPU-type to topology | expand

Commit Message

Pawan Gupta June 17, 2024, 9:11 a.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 and can be
avoided as cpu-type is also available in the per-cpu topology structure.

Use topology_cpu_type() to get the cpu-type.

Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
---
 drivers/cpufreq/intel_pstate.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

Comments

Srinivas Pandruvada June 17, 2024, 9:27 a.m. UTC | #1
On Mon, 2024-06-17 at 02:11 -0700, Pawan Gupta 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 and can
> be
> avoided as cpu-type is also available in the per-cpu topology
> structure.
> 
> Use topology_cpu_type() to get the cpu-type.
> 
> 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(-)
> 
> diff --git a/drivers/cpufreq/intel_pstate.c
> b/drivers/cpufreq/intel_pstate.c
> index 65d3f79104bd..40f5e5b0b45e 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -1951,24 +1951,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_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_CPU_TYPE_INTEL_CORE)
>  		return hybrid_scaling_factor;
>  
>  	/* Use default core scaling for E-cores */
> -	if (cpu_type == 0x20)
> +	if (cpu_type == X86_CPU_TYPE_INTEL_ATOM)
>  		return core_get_scaling();
>  
>  	/*
>
kernel test robot June 17, 2024, 2:01 p.m. UTC | #2
Hi Pawan,

kernel test robot noticed the following build errors:

[auto build test ERROR on 83a7eefedc9b56fe7bfeff13b6c7356688ffa670]

url:    https://github.com/intel-lab-lkp/linux/commits/Pawan-Gupta/x86-cpu-topology-Add-x86_cpu_type-to-struct-cpuinfo_topology/20240617-172542
base:   83a7eefedc9b56fe7bfeff13b6c7356688ffa670
patch link:    https://lore.kernel.org/r/20240617-add-cpu-type-v1-2-b88998c01e76%40linux.intel.com
patch subject: [PATCH PATCH 2/9] cpufreq: intel_pstate: Use topology_cpu_type() to get cpu-type
config: i386-buildonly-randconfig-001-20240617 (https://download.01.org/0day-ci/archive/20240617/202406172134.ICqkbkNm-lkp@intel.com/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240617/202406172134.ICqkbkNm-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406172134.ICqkbkNm-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/cpufreq/intel_pstate.c: In function 'hwp_get_cpu_scaling':
>> drivers/cpufreq/intel_pstate.c:1959:25: error: 'X86_CPU_TYPE_INTEL_CORE' undeclared (first use in this function)
    1959 |         if (cpu_type == X86_CPU_TYPE_INTEL_CORE)
         |                         ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/cpufreq/intel_pstate.c:1959:25: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/cpufreq/intel_pstate.c:1963:25: error: 'X86_CPU_TYPE_INTEL_ATOM' undeclared (first use in this function)
    1963 |         if (cpu_type == X86_CPU_TYPE_INTEL_ATOM)
         |                         ^~~~~~~~~~~~~~~~~~~~~~~


vim +/X86_CPU_TYPE_INTEL_CORE +1959 drivers/cpufreq/intel_pstate.c

  1953	
  1954	static int hwp_get_cpu_scaling(int cpu)
  1955	{
  1956		u8 cpu_type = topology_cpu_type(cpu);
  1957	
  1958		/* P-cores have a smaller perf level-to-freqency scaling factor. */
> 1959		if (cpu_type == X86_CPU_TYPE_INTEL_CORE)
  1960			return hybrid_scaling_factor;
  1961	
  1962		/* Use default core scaling for E-cores */
> 1963		if (cpu_type == X86_CPU_TYPE_INTEL_ATOM)
  1964			return core_get_scaling();
  1965	
  1966		/*
  1967		 * If reached here, this system is either non-hybrid (like Tiger
  1968		 * Lake) or hybrid-capable (like Alder Lake or Raptor Lake) with
  1969		 * no E cores (in which case CPUID for hybrid support is 0).
  1970		 *
  1971		 * The CPPC nominal_frequency field is 0 for non-hybrid systems,
  1972		 * so the default core scaling will be used for them.
  1973		 */
  1974		return intel_pstate_cppc_get_scaling(cpu);
  1975	}
  1976
Pawan Gupta June 17, 2024, 6:36 p.m. UTC | #3
On Mon, Jun 17, 2024 at 02:27:02AM -0700, srinivas pandruvada wrote:
> On Mon, 2024-06-17 at 02:11 -0700, Pawan Gupta 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 and can
> > be
> > avoided as cpu-type is also available in the per-cpu topology
> > structure.
> > 
> > Use topology_cpu_type() to get the cpu-type.
> > 
> > Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

Thanks.
diff mbox series

Patch

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 65d3f79104bd..40f5e5b0b45e 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1951,24 +1951,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_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_CPU_TYPE_INTEL_CORE)
 		return hybrid_scaling_factor;
 
 	/* Use default core scaling for E-cores */
-	if (cpu_type == 0x20)
+	if (cpu_type == X86_CPU_TYPE_INTEL_ATOM)
 		return core_get_scaling();
 
 	/*