Skip to contentSkip to conversation

perf x86: Exposing IO stack to IO PMON mapping through sysfs

PATCH Superseded [email protected] 2 participants 8 messages Mar 20, 2020 – Mar 27, 2020

Subsystems (2)

v8 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v8 cover perf x86: Exposing IO stack to IO PMON mapping through sysfs

From: Roman Sudarikov <[email protected]>

The previous version can be found at:
v7: https://lkml.kernel.org/r/[email protected]/
Changes in this revision are:
v7 -> v8:
- Addressed comments from Kan Liang:
1. Fixed coding style issues (gotos in error path, comments style)

The previous version can be found at:
v6: https://lkml.kernel.org/r/[email protected]/

Changes in this revision are:
v6 -> v7:
- Addressed comments from Greg Kroah-Hartman:
1. Added proper handling of load/unload path
2. Simplified the mapping attribute show procedure by using the segment value of the first available root bus for all mapping attributes which is safe due to current implementation supports single segment configuration only
3. Fixed coding style issues (extra lines, gotos in error path, macros etc)

The previous version can be found at:
v5: https://lkml.kernel.org/r/[email protected]/

Changes in this revision are:
v5 -> v6:
1. Changed the mapping attribute name to "dieX"
2. Called sysfs_attr_init() prior to dynamically creating the mapping attrs
3. Removed redundant "empty" attribute
4. Got an agreement on the mapping attribute format

The previous version can be found at:
v4: https://lkml.kernel.org/r/[email protected]/

Changes in this revision are:
v4 -> v5:
- Addressed comments from Greg Kroah-Hartman:
1. Using the attr_update flow for newly introduced optional attributes
2. No subfolder, optional attributes are created the same level as 'cpumask'
3. No symlinks, optional attributes are created as files
4. Single file for each IIO PMON block to node mapping
5. Added Documentation/ABI/sysfs-devices-mapping

The previous version can be found at:
v3: https://lkml.kernel.org/r/[email protected]

Changes in this revision are:
v3 -> v4:
- Addressed comments from Greg Kroah-Hartman:
1. Reworked handling of newly introduced attribute.
2. Required Documentation update is expected in the follow up patchset

The previous version can be found at:
v2: https://lkml.kernel.org/r/[email protected]

Changes in this revision are:
v2 -> v3:
1. Addressed comments from Peter and Kan

The previous version can be found at:
v1: https://lkml.kernel.org/r/[email protected]

Changes in this revision are:
v1 -> v2:
1. Fixed process related issues;
2. This patch set includes kernel support for IIO stack to PMON mapping;
3. Stephane raised concerns regarding output format which may require
code changes in the user space part of the feature only. We will continue output format discussion in the context of user space update.

Intel® Xeon® Scalable processor family (code name Skylake-SP) makes significant changes in the integrated I/O (IIO) architecture. The new solution introduces IIO stacks which are responsible for managing traffic between the PCIe domain and the Mesh domain. Each IIO stack has its own PMON block and can handle either DMI port, x16 PCIe root port, MCP-Link or various built-in accelerators. IIO PMON blocks allow concurrent monitoring of I/O flows up to 4 x4 bifurcation within each IIO stack.

Software is supposed to program required perf counters within each IIO stack and gather performance data. The tricky thing here is that IIO PMON reports data per IIO stack but users have no idea what IIO stacks are - they only know devices which are connected to the platform.

Understanding IIO stack concept to find which IIO stack that particular IO device is connected to, or to identify an IIO PMON block to program for monitoring specific IIO stack assumes a lot of implicit knowledge about given Intel server platform architecture.

This patch set introduces:
1. An infrastructure for exposing an Uncore unit to Uncore PMON mapping through sysfs-backend;
2. A new --iiostat mode in perf stat to provide I/O performance metrics per I/O device.

Usage examples:

1. List all devices below IIO stacks
./perf stat --iiostat=show

Sample output w/o libpci:

    S0-RootPort0-uncore_iio_0<00:00.0>
    S1-RootPort0-uncore_iio_0<81:00.0>
    S0-RootPort1-uncore_iio_1<18:00.0>
    S1-RootPort1-uncore_iio_1<86:00.0>
    S1-RootPort1-uncore_iio_1<88:00.0>
    S0-RootPort2-uncore_iio_2<3d:00.0>
    S1-RootPort2-uncore_iio_2<af:00.0>
    S1-RootPort3-uncore_iio_3<da:00.0>

Sample output with libpci:

    S0-RootPort0-uncore_iio_0<00:00.0 Sky Lake-E DMI3 Registers>
    S1-RootPort0-uncore_iio_0<81:00.0 Ethernet Controller X710 for 10GbE SFP+>
    S0-RootPort1-uncore_iio_1<18:00.0 Omni-Path HFI Silicon 100 Series [discrete]>
    S1-RootPort1-uncore_iio_1<86:00.0 Ethernet Controller XL710 for 40GbE QSFP+>
    S1-RootPort1-uncore_iio_1<88:00.0 Ethernet Controller XL710 for 40GbE QSFP+>
    S0-RootPort2-uncore_iio_2<3d:00.0 Ethernet Connection X722 for 10GBASE-T>
    S1-RootPort2-uncore_iio_2<af:00.0 Omni-Path HFI Silicon 100 Series [discrete]>
    S1-RootPort3-uncore_iio_3<da:00.0 NVMe Datacenter SSD [Optane]>

2. Collect metrics for all I/O devices below IIO stack

  ./perf stat --iiostat -- dd if=/dev/zero of=/dev/nvme0n1 bs=1M oflag=direct
    357708+0 records in
    357707+0 records out
    375083606016 bytes (375 GB, 349 GiB) copied, 215.381 s, 1.7 GB/s

Performance counter stats for 'system wide':

device Inbound Read(MB) Inbound Write(MB) Outbound Read(MB) Outbound Write(MB)
00:00.0 0 0 0 0
81:00.0 0 0 0 0
18:00.0 0 0 0 0
86:00.0 0 0 0 0
88:00.0 0 0 0 0
3b:00.0 3 0 0 0
3c:03.0 3 0 0 0
3d:00.0 3 0 0 0
af:00.0 0 0 0 0
da:00.0 358559 44 0 22

215.383783574 seconds time elapsed

3. Collect metrics for comma separted list of I/O devices

  ./perf stat --iiostat=da:00.0 -- dd if=/dev/zero of=/dev/nvme0n1 bs=1M oflag=direct
    381555+0 records in
    381554+0 records out
    400088457216 bytes (400 GB, 373 GiB) copied, 374.044 s, 1.1 GB/s

Performance counter stats for 'system wide':

device Inbound Read(MB) Inbound Write(MB) Outbound Read(MB) Outbound Write(MB)
da:00.0 382462 47 0 23

374.045775505 seconds time elapsed

Roman Sudarikov (3):
perf x86: Infrastructure for exposing an Uncore unit to PMON mapping perf x86: Topology max dies for whole system
perf x86: Exposing an Uncore unit to PMON for Intel Xeon® server
platform

 .../ABI/testing/sysfs-devices-mapping         |  33 +++
 arch/x86/events/intel/uncore.c                |  21 +-
 arch/x86/events/intel/uncore.h                |  18 ++
 arch/x86/events/intel/uncore_snbep.c          | 191 ++++++++++++++++++
 4 files changed, 257 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-devices-mapping

base-commit: 6c90b86a745a446717fdf408c4a8a4631a5e8ee3

Signature · 1 line
2.19.1
#1 lore raw

PATCH v8 1/3 perf x86: Infrastructure for exposing an Uncore unit to PMON mapping

From: Roman Sudarikov <[email protected]>

Intel® Xeon® Scalable processor family (code name Skylake-SP) makes significant changes in the integrated I/O (IIO) architecture. The new solution introduces IIO stacks which are responsible for managing traffic between the PCIe domain and the Mesh domain. Each IIO stack has its own PMON block and can handle either DMI port, x16 PCIe root port, MCP-Link or various built-in accelerators. IIO PMON blocks allow concurrent monitoring of I/O flows up to 4 x4 bifurcation within each IIO stack.

Software is supposed to program required perf counters within each IIO stack and gather performance data. The tricky thing here is that IIO PMON reports data per IIO stack but users have no idea what IIO stacks are - they only know devices which are connected to the platform.

Understanding IIO stack concept to find which IIO stack that particular IO device is connected to, or to identify an IIO PMON block to program for monitoring specific IIO stack assumes a lot of implicit knowledge about given Intel server platform architecture.

Usage example:

    ls /sys/devices/uncore_<type>_<pmu_idx>/die*

Each Uncore unit type, by its nature, can be mapped to its own context, for example:
1. CHA - each uncore_cha_<pmu_idx> is assigned to manage a distinct slice of LLC capacity;
2. UPI - each uncore_upi_<pmu_idx> is assigned to manage one link of Intel UPI Subsystem;
3. IIO - each uncore_iio_<pmu_idx> is assigned to manage one stack of the IIO module;
4. IMC - each uncore_imc_<pmu_idx> is assigned to manage one channel of Memory Controller.

Implementation details:
Optional callbacks added to struct intel_uncore_type to discover and map Uncore units to PMONs:
int (*set_mapping)(struct intel_uncore_type *type)
void (*cleanup_mapping)(struct intel_uncore_type *type)

Details of IIO Uncore unit mapping to IIO PMON:
Each IIO stack is either DMI port, x16 PCIe root port, MCP-Link or various built-in accelerators. For Uncore IIO Unit type, the mapping file holds bus numbers of devices, which can be monitored by that IIO PMON block on each die.

---
 arch/x86/events/intel/uncore.c | 8 ++++++++
 arch/x86/events/intel/uncore.h | 6 ++++++
 2 files changed, 14 insertions(+)
arch/x86/events/intel/uncore.c +8 -0
index 86467f85c383..fb693608c223 100644
@@ -843,10 +843,12 @@ static int uncore_pmu_register(struct intel_uncore_pmu *pmu)
 			.read		= uncore_pmu_event_read,
 			.module		= THIS_MODULE,
 			.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
+			.attr_update	= pmu->type->attr_update,
 		};
 	} else {
 		pmu->pmu = *pmu->type->pmu;
 		pmu->pmu.attr_groups = pmu->type->attr_groups;
+		pmu->pmu.attr_update = pmu->type->attr_update;
 	}
 
 	if (pmu->type->num_boxes == 1) {
@@ -887,6 +889,9 @@ static void uncore_type_exit(struct intel_uncore_type *type)
 	struct intel_uncore_pmu *pmu = type->pmus;
 	int i;
 
+	if (type->cleanup_mapping)
+		type->cleanup_mapping(type);
+
 	if (pmu) {
 		for (i = 0; i < type->num_boxes; i++, pmu++) {
 			uncore_pmu_unregister(pmu);
@@ -954,6 +959,9 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
 
 	type->pmu_group = &uncore_pmu_attr_group;
 
+	if (type->set_mapping)
+		type->set_mapping(type);
+
 	return 0;
 
 err:
arch/x86/events/intel/uncore.h +6 -0
index bbfdaa720b45..d41f8874adc5 100644
@@ -72,7 +72,13 @@ struct intel_uncore_type {
 	struct uncore_event_desc *event_descs;
 	struct freerunning_counters *freerunning;
 	const struct attribute_group *attr_groups[4];
+	const struct attribute_group **attr_update;
 	struct pmu *pmu; /* for custom pmu ops */
+	/* PMON's topologies */
+	u64 *topology;
+	/* mapping Uncore units to PMON ranges */
+	int (*set_mapping)(struct intel_uncore_type *type);
+	void (*cleanup_mapping)(struct intel_uncore_type *type);
 };
 
 #define pmu_group attr_groups[0]
Signature · 1 line
2.19.1
#2 lore raw

Re: [PATCH v8 1/3] perf x86: Infrastructure for exposing an Uncore unit to PMON mapping

Quoted 100 lines · On 20.03.2020 10:31, [email protected] wrote:

From: Roman Sudarikov <[email protected]>

Intel® Xeon® Scalable processor family (code name Skylake-SP) makes significant changes in the integrated I/O (IIO) architecture. The new solution introduces IIO stacks which are responsible for managing traffic between the PCIe domain and the Mesh domain. Each IIO stack has its own PMON block and can handle either DMI port, x16 PCIe root port, MCP-Link or various built-in accelerators. IIO PMON blocks allow concurrent monitoring of I/O flows up to 4 x4 bifurcation within each IIO stack.

Software is supposed to program required perf counters within each IIO stack and gather performance data. The tricky thing here is that IIO PMON reports data per IIO stack but users have no idea what IIO stacks are - they only know devices which are connected to the platform.

Understanding IIO stack concept to find which IIO stack that particular IO device is connected to, or to identify an IIO PMON block to program for monitoring specific IIO stack assumes a lot of implicit knowledge about given Intel server platform architecture.

Usage example:

     ls /sys/devices/uncore_<type>_<pmu_idx>/die*

Each Uncore unit type, by its nature, can be mapped to its own context, for example:
1. CHA - each uncore_cha_<pmu_idx> is assigned to manage a distinct slice

    of LLC capacity;
2. UPI - each uncore_upi_<pmu_idx> is assigned to manage one link of Intel
    UPI Subsystem;
3. IIO - each uncore_iio_<pmu_idx> is assigned to manage one stack of the
    IIO module;

4. IMC - each uncore_imc_<pmu_idx> is assigned to manage one channel of Memory Controller.

Implementation details:
Optional callbacks added to struct intel_uncore_type to discover and map Uncore units to PMONs:
int (*set_mapping)(struct intel_uncore_type *type)
void (*cleanup_mapping)(struct intel_uncore_type *type)

Details of IIO Uncore unit mapping to IIO PMON:
Each IIO stack is either DMI port, x16 PCIe root port, MCP-Link or various built-in accelerators. For Uncore IIO Unit type, the mapping file holds bus numbers of devices, which can be monitored by that IIO PMON block on each die.

---
  arch/x86/events/intel/uncore.c | 8 ++++++++
  arch/x86/events/intel/uncore.h | 6 ++++++
  2 files changed, 14 insertions(+)
arch/x86/events/intel/uncore.c +8 -0
index 86467f85c383..fb693608c223 100644
@@ -843,10 +843,12 @@ static int uncore_pmu_register(struct intel_uncore_pmu *pmu)
  			.read		= uncore_pmu_event_read,
  			.module		= THIS_MODULE,
  			.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
+			.attr_update	= pmu->type->attr_update,
  		};
  	} else {
  		pmu->pmu = *pmu->type->pmu;
  		pmu->pmu.attr_groups = pmu->type->attr_groups;
+		pmu->pmu.attr_update = pmu->type->attr_update;
  	}
 
  	if (pmu->type->num_boxes == 1) {
@@ -887,6 +889,9 @@ static void uncore_type_exit(struct intel_uncore_type *type)
  	struct intel_uncore_pmu *pmu = type->pmus;
  	int i;
 
+	if (type->cleanup_mapping)
+		type->cleanup_mapping(type);
+
  	if (pmu) {
  		for (i = 0; i < type->num_boxes; i++, pmu++) {
  			uncore_pmu_unregister(pmu);
@@ -954,6 +959,9 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
 
  	type->pmu_group = &uncore_pmu_attr_group;
 
+	if (type->set_mapping)
+		type->set_mapping(type);
+
  	return 0;
 
  err:
arch/x86/events/intel/uncore.h +0 -0
index bbfdaa720b45..d41f8874adc5 100644
@@ -72,7 +72,13 @@ struct intel_uncore_type {
  	struct uncore_event_desc *event_descs;
  	struct freerunning_counters *freerunning;
  	const struct attribute_group *attr_groups[4];

arch/x86/events/intel/uncore.h struct intel_uncore_type { · line 84

Quoted 10 lines
arch/x86/events/intel/uncore.h +6 -0
+	const struct attribute_group **attr_update;
  	struct pmu *pmu; /* for custom pmu ops */
+	/* PMON's topologies */
+	u64 *topology;
+	/* mapping Uncore units to PMON ranges */
+	int (*set_mapping)(struct intel_uncore_type *type);
+	void (*cleanup_mapping)(struct intel_uncore_type *type);
  };
 
  #define pmu_group attr_groups[0]

Hello Peter,
are you waiting for some further review/ack on this, or is it just in your pending review queue?

Sorry for bothering you several times, but the feature will add value to users.

Thanks,
Roman

#3 lore raw

Re: [PATCH v8 1/3] perf x86: Infrastructure for exposing an Uncore unit to PMON mapping

In reply to [email protected]
Quoted 1 line · [email protected] writes:

From: Roman Sudarikov <[email protected]>

My comments for 2/3 also apply here. Also, check out the Documentation/process/submitting-patches.rst.

Quoted 21 lines

Intel® Xeon® Scalable processor family (code name Skylake-SP) makes significant changes in the integrated I/O (IIO) architecture. The new solution introduces IIO stacks which are responsible for managing traffic between the PCIe domain and the Mesh domain. Each IIO stack has its own PMON block and can handle either DMI port, x16 PCIe root port, MCP-Link or various built-in accelerators. IIO PMON blocks allow concurrent monitoring of I/O flows up to 4 x4 bifurcation within each IIO stack.

Software is supposed to program required perf counters within each IIO stack and gather performance data. The tricky thing here is that IIO PMON reports data per IIO stack but users have no idea what IIO stacks are - they only know devices which are connected to the platform.

Understanding IIO stack concept to find which IIO stack that particular IO device is connected to, or to identify an IIO PMON block to program for monitoring specific IIO stack assumes a lot of implicit knowledge about given Intel server platform architecture.

Usage example:

    ls /sys/devices/uncore_<type>_<pmu_idx>/die*
Quoted 10 lines

Each Uncore unit type, by its nature, can be mapped to its own context, for example:
1. CHA - each uncore_cha_<pmu_idx> is assigned to manage a distinct slice of LLC capacity;
2. UPI - each uncore_upi_<pmu_idx> is assigned to manage one link of Intel UPI Subsystem;
3. IIO - each uncore_iio_<pmu_idx> is assigned to manage one stack of the IIO module;
4. IMC - each uncore_imc_<pmu_idx> is assigned to manage one channel of Memory Controller.

This is indeed very informative. I'd say it belongs more in a Documentation/ than commit message. In a nutshell, we have uncore PMUs that monitor integrated IO and the first task is to map those to the actual devices in the system, right? A lot of the time commit messages are way too short and missing important details, this one is tending towards the other end of the spectrum.

At the same time, you don't seem to mention the one thing that this patch does do: extend the uncore PMU to support integrated IO monitoning, if my understanding is correct.

Also, the acronyms are unexplained. I'm not sure if they even need to be here.

Quoted 5 lines

Implementation details:
Optional callbacks added to struct intel_uncore_type to discover and map Uncore units to PMONs:
int (*set_mapping)(struct intel_uncore_type *type)
void (*cleanup_mapping)(struct intel_uncore_type *type)

Most of the time, you don't need to verbalize the code in the commit message, you can do it in the comments or Documentation. Here, we can just scroll down for the implementation details. If you want to explain the new callbacks, add comments to the structure definition.

Quoted 5 lines
arch/x86/events/intel/uncore.c +0 -0
index 86467f85c383..fb693608c223 100644

arch/x86/events/intel/uncore.c static int uncore_pmu_register(struct intel_uncore_pmu *pmu) · line 851

Quoted 9 lines
arch/x86/events/intel/uncore.c +2 -0
@@ -843,10 +843,12 @@ static int uncore_pmu_register(struct intel_uncore_pmu *pmu)
 			.read		= uncore_pmu_event_read,
 			.module		= THIS_MODULE,
 			.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
+			.attr_update	= pmu->type->attr_update,
 		};
 	} else {
 		pmu->pmu = *pmu->type->pmu;
 		pmu->pmu.attr_groups = pmu->type->attr_groups;
+		pmu->pmu.attr_update = pmu->type->attr_update;

So you need the attr_update to create the mapping attributes on the fly, right? May be worth mentioning.

arch/x86/events/intel/uncore.h struct intel_uncore_type { · line 79

Quoted 13 lines
arch/x86/events/intel/uncore.h +4 -0
index bbfdaa720b45..d41f8874adc5 100644
@@ -72,7 +72,13 @@ struct intel_uncore_type {
 	struct uncore_event_desc *event_descs;
 	struct freerunning_counters *freerunning;
 	const struct attribute_group *attr_groups[4];
+	const struct attribute_group **attr_update;
 	struct pmu *pmu; /* for custom pmu ops */
+	/* PMON's topologies */
+	u64 *topology;
+	/* mapping Uncore units to PMON ranges */

This can be more elaborate, like the "implementation details" paragraph from the commit message.

Quoted 7 lines
arch/x86/events/intel/uncore.h +2 -0
+	int (*set_mapping)(struct intel_uncore_type *type);
+	void (*cleanup_mapping)(struct intel_uncore_type *type);
 };
 
 #define pmu_group attr_groups[0]
Signature · 1 line
2.19.1
#4 lore raw

PATCH v8 2/3 perf x86: Topology max dies for whole system

In reply to [email protected]

From: Roman Sudarikov <[email protected]>

Helper function to return number of dies on the platform.

---
 arch/x86/events/intel/uncore.c | 13 +++++++------
 arch/x86/events/intel/uncore.h |  3 +++
 2 files changed, 10 insertions(+), 6 deletions(-)
arch/x86/events/intel/uncore.c +7 -6
index fb693608c223..aee64c96785d 100644
@@ -16,7 +16,7 @@ struct pci_driver *uncore_pci_driver;
 DEFINE_RAW_SPINLOCK(pci2phy_map_lock);
 struct list_head pci2phy_map_head = LIST_HEAD_INIT(pci2phy_map_head);
 struct pci_extra_dev *uncore_extra_pci_dev;
-static int max_dies;
+int __uncore_max_dies;
 
 /* mask of cpus that collect uncore events */
 static cpumask_t uncore_cpu_mask;
@@ -108,7 +108,7 @@ struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu
 	 * The unsigned check also catches the '-1' return value for non
 	 * existent mappings in the topology map.
 	 */
-	return dieid < max_dies ? pmu->boxes[dieid] : NULL;
+	return dieid < uncore_max_dies() ? pmu->boxes[dieid] : NULL;
 }
 
 u64 uncore_msr_read_counter(struct intel_uncore_box *box, struct perf_event *event)
@@ -879,7 +879,7 @@ static void uncore_free_boxes(struct intel_uncore_pmu *pmu)
 {
 	int die;
 
-	for (die = 0; die < max_dies; die++)
+	for (die = 0; die < uncore_max_dies(); die++)
 		kfree(pmu->boxes[die]);
 	kfree(pmu->boxes);
 }
@@ -920,7 +920,7 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
 	if (!pmus)
 		return -ENOMEM;
 
-	size = max_dies * sizeof(struct intel_uncore_box *);
+	size = uncore_max_dies() * sizeof(struct intel_uncore_box *);
 
 	for (i = 0; i < type->num_boxes; i++) {
 		pmus[i].func_id	= setid ? i : -1;
@@ -1120,7 +1120,7 @@ static int __init uncore_pci_init(void)
 	size_t size;
 	int ret;
 
-	size = max_dies * sizeof(struct pci_extra_dev);
+	size = uncore_max_dies() * sizeof(struct pci_extra_dev);
 	uncore_extra_pci_dev = kzalloc(size, GFP_KERNEL);
 	if (!uncore_extra_pci_dev) {
 		ret = -ENOMEM;
@@ -1532,7 +1532,8 @@ static int __init intel_uncore_init(void)
 	if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return -ENODEV;
 
-	max_dies = topology_max_packages() * topology_max_die_per_package();
+	__uncore_max_dies =
+		topology_max_packages() * topology_max_die_per_package();
 
 	uncore_init = (struct intel_uncore_init_fun *)id->driver_data;
 	if (uncore_init->pci_init) {
arch/x86/events/intel/uncore.h +3 -0
index d41f8874adc5..c1da2b8218cd 100644
@@ -174,6 +174,9 @@ int uncore_pcibus_to_physid(struct pci_bus *bus);
 ssize_t uncore_event_show(struct kobject *kobj,
 			  struct kobj_attribute *attr, char *buf);
 
+extern int __uncore_max_dies;
+#define uncore_max_dies()	(__uncore_max_dies)
+
 #define INTEL_UNCORE_EVENT_DESC(_name, _config)			\
 {								\
 	.attr	= __ATTR(_name, 0444, uncore_event_show, NULL),	\
Signature · 1 line
2.19.1
#5 lore raw

Re: [PATCH v8 2/3] perf x86: Topology max dies for whole system

Quoted 3 lines · [email protected] writes:

From: Roman Sudarikov <[email protected]>

Helper function to return number of dies on the platform.

It's not a function though, it's a macro. And maybe more of an "accessor" than a "helper".

It's also good to mention in the commit message, why this change is needed and sometimes (though maybe not here) why this way is better than the alternatives.

Another thing about the subject line is that it has to describe the action that the patch is taking, in imperative mood. In this case it could be "Turn the max die calculation into a function".

The prefix of the subject line should be: perf/x86/intel/uncore. Check out git log arch/x86/events/intel/uncore.c for examples.

I also think that it won't be unreasonable to fold this patch into the next one. That's up to you, of course.

Regards,
--
Alex

#6 lore raw

PATCH v8 3/3 perf x86: Exposing an Uncore unit to PMON for Intel Xeon® server platform

In reply to [email protected]

From: Roman Sudarikov <[email protected]>

Current version supports a server line starting Intel® Xeon® Processor Scalable Family and introduces mapping for IIO Uncore units only. Other units can be added on demand.

IIO stack to PMON mapping is exposed through:
/sys/devices/uncore_iio_<pmu_idx>/dieX
where dieX is file which holds "Segment:Root Bus" for PCIe root port, which can be monitored by that IIO PMON block.

Details are explained in Documentation/ABI/testing/sysfs-devices-mapping

---
 .../ABI/testing/sysfs-devices-mapping         |  33 +++
 arch/x86/events/intel/uncore.h                |   9 +
 arch/x86/events/intel/uncore_snbep.c          | 191 ++++++++++++++++++
 3 files changed, 233 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-devices-mapping
Documentation/ABI/testing/sysfs-devices-mapping new file +33 -0
new file mode 100644
index 000000000000..16f4e900be7b
@@ -0,0 +1,33 @@
+What:           /sys/devices/uncore_iio_x/dieX
+Date:           February 2020
+Contact:        Roman Sudarikov <[email protected]>
+Description:
+                Each IIO stack (PCIe root port) has its own IIO PMON block, so
+                each dieX file (where X is die number) holds "Segment:Root Bus"
+                for PCIe root port, which can be monitored by that IIO PMON
+                block.
+                For example, on 4-die Xeon platform with up to 6 IIO stacks per
+                die and, therefore, 6 IIO PMON blocks per die, the mapping of
+                IIO PMON block 0 exposes as the following:
+
+                $ ls /sys/devices/uncore_iio_0/die*
+                -r--r--r-- /sys/devices/uncore_iio_0/die0
+                -r--r--r-- /sys/devices/uncore_iio_0/die1
+                -r--r--r-- /sys/devices/uncore_iio_0/die2
+                -r--r--r-- /sys/devices/uncore_iio_0/die3
+
+                $ tail /sys/devices/uncore_iio_0/die*
+                ==> /sys/devices/uncore_iio_0/die0 <==
+                0000:00
+                ==> /sys/devices/uncore_iio_0/die1 <==
+                0000:40
+                ==> /sys/devices/uncore_iio_0/die2 <==
+                0000:80
+                ==> /sys/devices/uncore_iio_0/die3 <==
+                0000:c0
+
+                Which means:
+                IIO PMU 0 on die 0 belongs to PCI RP on bus 0x00, domain 0x0000
+                IIO PMU 0 on die 1 belongs to PCI RP on bus 0x40, domain 0x0000
+                IIO PMU 0 on die 2 belongs to PCI RP on bus 0x80, domain 0x0000
+                IIO PMU 0 on die 3 belongs to PCI RP on bus 0xc0, domain 0x0000
\ No newline at end of file
arch/x86/events/intel/uncore.h +9 -0
index c1da2b8218cd..eb93b8676f34 100644
@@ -174,6 +174,15 @@ int uncore_pcibus_to_physid(struct pci_bus *bus);
 ssize_t uncore_event_show(struct kobject *kobj,
 			  struct kobj_attribute *attr, char *buf);
 
+static inline struct intel_uncore_pmu *dev_to_uncore_pmu(struct device *dev)
+{
+	return container_of(dev_get_drvdata(dev), struct intel_uncore_pmu, pmu);
+}
+
+#define to_device_attribute(n)	container_of(n, struct device_attribute, attr)
+#define to_dev_ext_attribute(n)	container_of(n, struct dev_ext_attribute, attr)
+#define attr_to_ext_attr(n)	to_dev_ext_attribute(to_device_attribute(n))
+
 extern int __uncore_max_dies;
 #define uncore_max_dies()	(__uncore_max_dies)
 
arch/x86/events/intel/uncore_snbep.c +191 -0

209 lines not on this page · raw message

Signature · 1 line
2.19.1
reviewer Reviewed-by on v8 3/3
#7 lore raw

Re: [PATCH v8 3/3] perf x86: Exposing an Uncore unit to PMON for Intel Xeon® server platform

Documentation/ABI/testing/sysfs-devices-mapping

Quoted 12 lines · [email protected] writes:
---
 .../ABI/testing/sysfs-devices-mapping         |  33 +++
 arch/x86/events/intel/uncore.h                |   9 +
 arch/x86/events/intel/uncore_snbep.c          | 191 ++++++++++++++++++
 3 files changed, 233 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-devices-mapping
Documentation/ABI/testing/sysfs-devices-mapping new file +0 -0
new file mode 100644
index 000000000000..16f4e900be7b

Is this a good place for something that's perf/x86/intel/uncore specific?

Documentation/ABI/testing/sysfs-devices-mapping line 33

Quoted 6 lines
Documentation/ABI/testing/sysfs-devices-mapping new file +5 -0
+                Which means:
+                IIO PMU 0 on die 0 belongs to PCI RP on bus 0x00, domain 0x0000
+                IIO PMU 0 on die 1 belongs to PCI RP on bus 0x40, domain 0x0000
+                IIO PMU 0 on die 2 belongs to PCI RP on bus 0x80, domain 0x0000
+                IIO PMU 0 on die 3 belongs to PCI RP on bus 0xc0, domain 0x0000
\ No newline at end of file

Git is trying to tell you something.

Documentation/ABI/testing/sysfs-devices-mapping

Quoted 1 line
Documentation/ABI/testing/sysfs-devices-mapping new file +1 -0
+		eas[die].attr.attr.mode = 0444;

I believe this one is also known as S_IRUGO.

Other than that, this patch is

Regards,
--
Alex