All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] drivers core: Introduce CPU type sysfs interface
@ 2020-10-03  1:17 Ricardo Neri
  2020-10-03  1:17 ` [PATCH 1/4] " Ricardo Neri
                   ` (5 more replies)
  0 siblings, 6 replies; 37+ messages in thread
From: Ricardo Neri @ 2020-10-03  1:17 UTC (permalink / raw)
  To: Greg Kroah-Hartman, x86, Borislav Petkov, Ingo Molnar,
	Thomas Gleixner, Rafael J. Wysocki
  Cc: Tony Luck, Len Brown, Ravi V. Shankar, linux-kernel, Ricardo Neri

Hybrid CPU topologies combine processors with more than one type of
micro-architecture. Hence, it is possible that individual CPUs support
slightly different features (e.g., performance counters) and different
performance properties. Thus, there may be user space entities interested
in knowing the topology of the system based on the types of available
CPUs.

Currently, there exists an interface for the CPU capacity (/sys/devices/
system/cpu/cpuX/cpu_capacity). However, CPU capacity does not always map
to CPU types (by the way, I will submit a separate series to bring such
interface to x86).

This series proposes the new interface /sys/devices/system/cpu/types
which, in hybrid parts, creates a subdirectory for each type of CPU.
Each subdirectory contains a CPU list and a CPU map that user space can
query.

Patch 1 of the series proposes the generic interface, with hooks
that architectures can override to suit their needs. The three patches
patches implement such interface for x86 (as per request from Boris,
I pulled patch 2 from a separate submission [1]).

Thanks and BR,
Ricardo

[1]. https://lkml.org/lkml/2020/10/2/1013

Ricardo Neri (4):
  drivers core: Introduce CPU type sysfs interface
  x86/cpu: Describe hybrid CPUs in cpuinfo_x86
  x86/cpu/intel: Add function to get name of hybrid CPU types
  x86/cpu/topology: Implement the CPU type sysfs interface

 .../ABI/testing/sysfs-devices-system-cpu      |  13 ++
 arch/x86/include/asm/intel-family.h           |   4 +
 arch/x86/include/asm/processor.h              |  13 ++
 arch/x86/include/asm/topology.h               |   2 +
 arch/x86/kernel/cpu/common.c                  |   3 +
 arch/x86/kernel/cpu/cpu.h                     |   3 +
 arch/x86/kernel/cpu/intel.c                   |  23 ++
 arch/x86/kernel/cpu/topology.c                |  23 ++
 drivers/base/cpu.c                            | 214 ++++++++++++++++++
 include/linux/cpu.h                           |  12 +
 include/linux/cpuhotplug.h                    |   1 +
 11 files changed, 311 insertions(+)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 37+ messages in thread
* Re: [PATCH 1/4] drivers core: Introduce CPU type sysfs interface
@ 2020-10-03  8:07 kernel test robot
  0 siblings, 0 replies; 37+ messages in thread
From: kernel test robot @ 2020-10-03  8:07 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 7355 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20201003011745.7768-2-ricardo.neri-calderon@linux.intel.com>
References: <20201003011745.7768-2-ricardo.neri-calderon@linux.intel.com>
TO: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
TO: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
TO: x86(a)kernel.org
TO: Borislav Petkov <bp@suse.de>
TO: Ingo Molnar <mingo@kernel.org>
TO: Thomas Gleixner <tglx@linutronix.de>
TO: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Len Brown <len.brown@intel.com>
CC: "Ravi V. Shankar" <ravi.v.shankar@intel.com>
CC: linux-kernel(a)vger.kernel.org

Hi Ricardo,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tip/x86/core]
[also build test WARNING on tip/master driver-core/driver-core-testing linus/master v5.9-rc7 next-20201002]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Ricardo-Neri/drivers-core-Introduce-CPU-type-sysfs-interface/20201003-091754
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 238c91115cd05c71447ea071624a4c9fe661f970
:::::: branch date: 7 hours ago
:::::: commit date: 7 hours ago
config: s390-randconfig-m031-20201002 (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/base/cpu.c:735 cpu_type_sysfs_online() warn: we never enter this loop
drivers/base/cpu.c:772 cpu_type_sysfs_offline() warn: we never enter this loop

Old smatch warnings:
drivers/base/cpu.c:747 cpu_type_sysfs_online() error: we previously assumed 'mask' could be null (see line 747)
drivers/base/cpu.c:779 cpu_type_sysfs_offline() error: we previously assumed 'mask' could be null (see line 779)

vim +735 drivers/base/cpu.c

110646cfb07328 Ricardo Neri 2020-10-02  728  
110646cfb07328 Ricardo Neri 2020-10-02  729  static int cpu_type_sysfs_online(unsigned int cpu)
110646cfb07328 Ricardo Neri 2020-10-02  730  {
110646cfb07328 Ricardo Neri 2020-10-02  731  	u32 cpu_type = arch_get_cpu_type(cpu);
110646cfb07328 Ricardo Neri 2020-10-02  732  	struct cpumask *mask;
110646cfb07328 Ricardo Neri 2020-10-02  733  	int i;
110646cfb07328 Ricardo Neri 2020-10-02  734  
110646cfb07328 Ricardo Neri 2020-10-02 @735  	for (i = 0; i < ARRAY_SIZE(cpu_type_devices); i++) {
110646cfb07328 Ricardo Neri 2020-10-02  736  		u32 this_cpu_type;
110646cfb07328 Ricardo Neri 2020-10-02  737  
110646cfb07328 Ricardo Neri 2020-10-02  738  		/*
110646cfb07328 Ricardo Neri 2020-10-02  739  		 * The first devices in the array are used first. Thus, create
110646cfb07328 Ricardo Neri 2020-10-02  740  		 * a new device as well as sysfs directory and for the type of
110646cfb07328 Ricardo Neri 2020-10-02  741  		 * @cpu.
110646cfb07328 Ricardo Neri 2020-10-02  742  		 */
110646cfb07328 Ricardo Neri 2020-10-02  743  		if (!cpu_type_devices[i])
110646cfb07328 Ricardo Neri 2020-10-02  744  			return cpu_type_create_device(cpu, i);
110646cfb07328 Ricardo Neri 2020-10-02  745  
110646cfb07328 Ricardo Neri 2020-10-02  746  		mask = dev_get_drvdata(cpu_type_devices[i]);
110646cfb07328 Ricardo Neri 2020-10-02  747  		if (!mask && !cpumask_weight(mask)) {
110646cfb07328 Ricardo Neri 2020-10-02  748  			/*
110646cfb07328 Ricardo Neri 2020-10-02  749  			 * We should not be here. Be paranoid about
110646cfb07328 Ricardo Neri 2020-10-02  750  			 * NULL pointers.
110646cfb07328 Ricardo Neri 2020-10-02  751  			 */
110646cfb07328 Ricardo Neri 2020-10-02  752  			dev_err(cpu_type_devices[i], "CPU mask is invalid");
110646cfb07328 Ricardo Neri 2020-10-02  753  			return -EINVAL;
110646cfb07328 Ricardo Neri 2020-10-02  754  		}
110646cfb07328 Ricardo Neri 2020-10-02  755  
110646cfb07328 Ricardo Neri 2020-10-02  756  		this_cpu_type = arch_get_cpu_type(cpumask_first(mask));
110646cfb07328 Ricardo Neri 2020-10-02  757  		if (cpu_type == this_cpu_type) {
110646cfb07328 Ricardo Neri 2020-10-02  758  			cpumask_set_cpu(cpu, mask);
110646cfb07328 Ricardo Neri 2020-10-02  759  			return 0;
110646cfb07328 Ricardo Neri 2020-10-02  760  		}
110646cfb07328 Ricardo Neri 2020-10-02  761  	}
110646cfb07328 Ricardo Neri 2020-10-02  762  
110646cfb07328 Ricardo Neri 2020-10-02  763  	return -ENODEV;
110646cfb07328 Ricardo Neri 2020-10-02  764  }
110646cfb07328 Ricardo Neri 2020-10-02  765  
110646cfb07328 Ricardo Neri 2020-10-02  766  static int cpu_type_sysfs_offline(unsigned int cpu)
110646cfb07328 Ricardo Neri 2020-10-02  767  {
110646cfb07328 Ricardo Neri 2020-10-02  768  	u32 cpu_type = arch_get_cpu_type(cpu);
110646cfb07328 Ricardo Neri 2020-10-02  769  	struct cpumask *mask;
110646cfb07328 Ricardo Neri 2020-10-02  770  	int i;
110646cfb07328 Ricardo Neri 2020-10-02  771  
110646cfb07328 Ricardo Neri 2020-10-02 @772  	for (i = 0; i < ARRAY_SIZE(cpu_type_devices); i++) {
110646cfb07328 Ricardo Neri 2020-10-02  773  		u32 this_cpu_type;
110646cfb07328 Ricardo Neri 2020-10-02  774  
110646cfb07328 Ricardo Neri 2020-10-02  775  		if (!cpu_type_devices[i])
110646cfb07328 Ricardo Neri 2020-10-02  776  			continue;
110646cfb07328 Ricardo Neri 2020-10-02  777  
110646cfb07328 Ricardo Neri 2020-10-02  778  		mask = dev_get_drvdata(cpu_type_devices[i]);
110646cfb07328 Ricardo Neri 2020-10-02  779  		if (!mask && !cpumask_weight(mask)) {
110646cfb07328 Ricardo Neri 2020-10-02  780  			/*
110646cfb07328 Ricardo Neri 2020-10-02  781  			 * We should not be here. Be paranoid about
110646cfb07328 Ricardo Neri 2020-10-02  782  			 * NULL pointers.
110646cfb07328 Ricardo Neri 2020-10-02  783  			 */
110646cfb07328 Ricardo Neri 2020-10-02  784  			dev_err(cpu_type_devices[i], "CPU mask is invalid");
110646cfb07328 Ricardo Neri 2020-10-02  785  			continue;
110646cfb07328 Ricardo Neri 2020-10-02  786  		}
110646cfb07328 Ricardo Neri 2020-10-02  787  
110646cfb07328 Ricardo Neri 2020-10-02  788  		this_cpu_type = arch_get_cpu_type(cpumask_first(mask));
110646cfb07328 Ricardo Neri 2020-10-02  789  		if (cpu_type == this_cpu_type) {
110646cfb07328 Ricardo Neri 2020-10-02  790  			cpumask_clear_cpu(cpu, mask);
110646cfb07328 Ricardo Neri 2020-10-02  791  			return 0;
110646cfb07328 Ricardo Neri 2020-10-02  792  		}
110646cfb07328 Ricardo Neri 2020-10-02  793  	}
110646cfb07328 Ricardo Neri 2020-10-02  794  
110646cfb07328 Ricardo Neri 2020-10-02  795  	/*
110646cfb07328 Ricardo Neri 2020-10-02  796  	 * If we are here, no matching cpu_type was found. This CPU was not
110646cfb07328 Ricardo Neri 2020-10-02  797  	 * accounted for@hotplug online.
110646cfb07328 Ricardo Neri 2020-10-02  798  	 */
110646cfb07328 Ricardo Neri 2020-10-02  799  	pr_warn("Unexpected CPU offline!\n");
110646cfb07328 Ricardo Neri 2020-10-02  800  
110646cfb07328 Ricardo Neri 2020-10-02  801  	return -ENODEV;
110646cfb07328 Ricardo Neri 2020-10-02  802  }
110646cfb07328 Ricardo Neri 2020-10-02  803  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 20713 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2020-11-19  8:26 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-03  1:17 [PATCH 0/4] drivers core: Introduce CPU type sysfs interface Ricardo Neri
2020-10-03  1:17 ` [PATCH 1/4] " Ricardo Neri
2020-10-03  3:27   ` Randy Dunlap
2020-10-06  1:15     ` Ricardo Neri
2020-10-10  3:14       ` Randy Dunlap
2020-10-03  8:53   ` Greg Kroah-Hartman
2020-10-03 11:05     ` Greg Kroah-Hartman
2020-10-06  1:08       ` Ricardo Neri
2020-10-06  0:57     ` Ricardo Neri
2020-10-06  7:37       ` Greg Kroah-Hartman
2020-10-07  3:14         ` Ricardo Neri
2020-10-07  5:15           ` Greg Kroah-Hartman
2020-10-08  3:34             ` Ricardo Neri
2020-11-12  6:19             ` Brice Goglin
2020-11-12  6:42               ` Greg Kroah-Hartman
2020-11-12  9:10                 ` Brice Goglin
2020-11-12 10:49                   ` Greg Kroah-Hartman
2020-11-17 15:55                     ` Brice Goglin
2020-11-18 10:45                       ` Brice Goglin
2020-11-18 10:57                         ` Greg Kroah-Hartman
     [not found]                     ` <38f290d2-4c3a-d1b0-f3cc-a0897ea10abd@gmail.com>
2020-11-12 11:34                       ` Greg Kroah-Hartman
2020-11-19  8:25                       ` Fox Chen
2020-10-03  1:17 ` [PATCH 2/4] x86/cpu: Describe hybrid CPUs in cpuinfo_x86 Ricardo Neri
2020-10-03  4:07   ` kernel test robot
2020-10-03  4:07     ` kernel test robot
2020-10-03  1:17 ` [PATCH 3/4] x86/cpu/intel: Add function to get name of hybrid CPU types Ricardo Neri
2020-10-03  1:17 ` [PATCH 4/4] x86/cpu/topology: Implement the CPU type sysfs interface Ricardo Neri
2020-10-03  3:33   ` Randy Dunlap
2020-10-03  5:28   ` kernel test robot
2020-10-03  5:28     ` kernel test robot
2020-10-03  8:55   ` Greg Kroah-Hartman
2020-10-06  1:05     ` Ricardo Neri
2020-10-03  8:49 ` [PATCH 0/4] drivers core: Introduce " Borislav Petkov
2020-10-06  0:27   ` Ricardo Neri
2020-10-06  8:51 ` Qais Yousef
2020-10-07  2:50   ` Ricardo Neri
2020-10-03  8:07 [PATCH 1/4] " kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.