Skip to contentSkip to conversation

dmaengine: idxd: IDXD pmu support

PATCH Superseded Tom Zanussi 2 participants 8 messages Apr 3, 2021 – Apr 21, 2021

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover dmaengine: idxd: IDXD pmu support

From: Tom Zanussi <[email protected]>

Hi,

This is v2 of the IDXD pmu support patch, which is the same as v1 but removes a few assigned-but-unused variables reported by kernel test robot <[email protected]>.

Thanks,

Tom

-- original v1 text --

Hi,

This patchset implements initial pmu support for the Intel DSA (Data Streaming Accelerator [1]), which I'm hoping can go into 5.13.

I'm also hoping to supply a couple follow-on patches in the near future, but I'm not yet sure how much sense they make, so I thought I'd throw a couple ideas out there and maybe get some opinions before going forward with them:

- The perf userspace interface for this isn't exactly user-friedly, in that you currently need to specify numeric values for field values:

# perf stat -e dsa0/filter_wq=0x1,filter_tc=0x1,filter_sz=0x7,
filter_eng=0x1,event=0x8,event_category=0x3/

It would be nicer to be able to specify those values symbolically instead, and the way to do that seems to be via some JSON files in perf userspace.

- Some of the DSA pmu support is patterned after existing uncore code, and there seems to be at least some opportunity to consolidate some of the things they both do into common code, such as the cpumask device attributes and related cpu hotplug support. At this point I'm not sure how much sense it makes to put any effort into that, but would be willing to try if there would be some interest in it, especially considering there will probably be future pmu support added that could benefit from it.

Thanks,

Tom

Tom Zanussi (1):
dmaengine: idxd: Add IDXD performance monitor support

 drivers/dma/Kconfig          |  13 +
 drivers/dma/idxd/Makefile    |   2 +
 drivers/dma/idxd/idxd.h      |  45 +++
 drivers/dma/idxd/init.c      |   9 +
 drivers/dma/idxd/irq.c       |   5 +-
 drivers/dma/idxd/perfmon.c   | 653 +++++++++++++++++++++++++++++++++++
 drivers/dma/idxd/perfmon.h   | 119 +++++++
 drivers/dma/idxd/registers.h | 108 ++++++
 include/linux/cpuhotplug.h   |   1 +
 9 files changed, 951 insertions(+), 4 deletions(-)
 create mode 100644 drivers/dma/idxd/perfmon.c
 create mode 100644 drivers/dma/idxd/perfmon.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 dmaengine: idxd: Add IDXD performance monitor support

Enable the IDXD performance monitor capability (named 'perfmon' in the DSA (Data Streaming Accelerator) spec [1]), which supports the collection of information about key events occurring during DSA and IAX (Intel Analytics Accelerator) device execution, to assist in performance tuning and debugging.

The idxd perfmon support is implemented as part of the IDXD driver and interfaces with the Linux perf framework. It has several features in common with the existing uncore pmu support:

- it does not support sampling
- does not support per-thread counting

However it also has some unique features not present in the core and uncore support:

- all general-purpose counters are identical, thus no event constraints
- operation is always system-wide

While the core perf subsystem assumes that all counters are by default per-cpu, the uncore pmus are socket-scoped and use a cpu mask to restrict counting to one cpu from each socket. IDXD counters use a similar strategy but expand the scope even further; since IDXD counters are system-wide and can be read from any cpu, the IDXD perf driver picks a single cpu to do the work (with cpu hotplug notifiers to choose a different cpu if the chosen one is taken off-line).

More specifically, the perf userspace tool by default opens a counter for each cpu for an event. However, if it finds a cpumask file associated with the pmu under sysfs, as is the case with the uncore pmus, it will open counters only on the cpus specified by the cpumask. Since perfmon only needs to open a single counter per event for a given IDXD device, the perfmon driver will create a sysfs cpumask file for the device and insert the first cpu of the system into it. When a user uses perf to open an event, perf will open a single counter on the cpu specified by the cpu mask. This amounts to the default system-wide rather than per-cpu counting mentioned previously for perfmon pmu events. In order to keep the cpu mask up-to-date, the driver implements cpu hotplug support for multiple devices, as IDXD usually enumerates and registers more than one idxd device.

The perfmon driver implements basic perfmon hardware capability discovery and configuration, and is initialized by the IDXD driver's probe function. During initialization, the driver retrieves the total number of supported performance counters, the pmu ID, and the device type from idxd device, and registers itself under the Linux perf framework.

The perf userspace tool can be used to monitor single or multiple events depending on the given configuration, as well as event groups, which are also supported by the perfmon driver. The user configures events using the perf tool command-line interface by specifying the event and corresponding event category, along with an optional set of filters that can be used to restrict counting to specific work queues, traffic classes, page and transfer sizes, and engines (See [1] for specifics).

With the configuration specified by the user, the perf tool issues a system call passing that information to the kernel, which uses it to initialize the specified event(s). The event(s) are opened and started, and following termination of the perf command, they're stopped. At that point, the perfmon driver will read the latest count for the event(s), calculate the difference between the latest counter values and previously tracked counter values, and display the final incremental count as the event count for the cycle. An overflow handler registered on the IDXD irq path is used to account for counter overflows, which are signaled by an overflow interrupt.

Below are a couple of examples of perf usage for monitoring DSA events.

The following monitors all events in the 'engine' category. Becuuse no filters are specified, this captures all engine events for the workload, which in this case is 19 iterations of the work generated by the kernel dmatest module.

Details describing the events can be found in Appendix D of [1], Performance Monitoring Events, but briefly they are:

  event 0x1:  total input data processed, in 32-byte units
  event 0x2:  total data written, in 32-byte units
  event 0x4:  number of work descriptors that read the source
  event 0x8:  number of work descriptors that write the destination

event 0x10: number of work descriptors dispatched from batch descriptors event 0x20: number of work descriptors dispatched from work queues

 # perf stat -e dsa0/event=0x1,event_category=0x1/,
                dsa0/event=0x2,event_category=0x1/,
		dsa0/event=0x4,event_category=0x1/,
		dsa0/event=0x8,event_category=0x1/,
		dsa0/event=0x10,event_category=0x1/,
		dsa0/event=0x20,event_category=0x1/
		  modprobe dmatest channel=dma0chan0 timeout=2000
		  iterations=19 run=1 wait=1
     Performance counter stats for 'system wide':

                 5,332      dsa0/event=0x1,event_category=0x1/
                 5,327      dsa0/event=0x2,event_category=0x1/
                    19      dsa0/event=0x4,event_category=0x1/
                    19      dsa0/event=0x8,event_category=0x1/
                     0      dsa0/event=0x10,event_category=0x1/
                    19      dsa0/event=0x20,event_category=0x1/

          21.977436186 seconds time elapsed

The command below illustrates filter usage with a simple example. It specifies that MEM_MOVE operations should be counted for the DSA device dsa0 (event 0x8 corresponds to the EV_MEM_MOVE event - Number of Memory Move Descriptors, which is part of event category 0x3 - Operations. The detailed category and event IDs are available in Appendix D, Performance Monitoring Events, of [1]). In addition to the event and event category, a number of filters are also specified (the detailed filter values are available in Chapter 6.4 (Filter Support) of [1]), which will restrict counting to only those events that meet all of the filter criteria. In this case, the filters specify that only MEM_MOVE operations that are serviced by work queue wq0 and specifically engine number engine0 and traffic class tc0 having sizes between 0 and 4k and page size of between 0 and 1G result in a counter hit; anything else will be filtered out and not appear in the final count. Note that filters are optional - any filter not specified is assumed to be all ones and will pass anything.

 # perf stat -e dsa0/filter_wq=0x1,filter_tc=0x1,filter_sz=0x7,
                filter_eng=0x1,event=0x8,event_category=0x3/
		  modprobe dmatest channel=dma0chan0 timeout=2000
		  iterations=19 run=1 wait=1
     Performance counter stats for 'system wide':

       19      dsa0/filter_wq=0x1,filter_tc=0x1,filter_sz=0x7,
               filter_eng=0x1,event=0x8,event_category=0x3/

          21.865914091 seconds time elapsed

The output above reflects that the unspecified workload resulted in the counting of 19 MEM_MOVE operation events that met the filter criteria.

[1]: https://software.intel.com/content/www/us/en/develop/download/intel-data-streaming-accelerator-preliminary-architecture-specification.html

[ Based on work originally by Jing Lin. ]

---
 drivers/dma/Kconfig          |  13 +
 drivers/dma/idxd/Makefile    |   2 +
 drivers/dma/idxd/idxd.h      |  45 +++
 drivers/dma/idxd/init.c      |   9 +
 drivers/dma/idxd/irq.c       |   5 +-
 drivers/dma/idxd/perfmon.c   | 653 +++++++++++++++++++++++++++++++++++
 drivers/dma/idxd/perfmon.h   | 119 +++++++
 drivers/dma/idxd/registers.h | 108 ++++++
 include/linux/cpuhotplug.h   |   1 +
 9 files changed, 951 insertions(+), 4 deletions(-)
 create mode 100644 drivers/dma/idxd/perfmon.c
 create mode 100644 drivers/dma/idxd/perfmon.h
drivers/dma/Kconfig +13 -0
index 0c2827fd8c19..fa945420e346 100644
@@ -300,6 +300,19 @@ config INTEL_IDXD_SVM
 	depends on PCI_PASID
 	depends on PCI_IOV
 
+config INTEL_IDXD_PERFMON
+	bool "Intel Data Accelerators performance monitor support"
+	depends on INTEL_IDXD
+	default y
+	help
+	  Enable performance monitor (pmu) support for the Intel(R)
+	  data accelerators present in Intel Xeon CPU.  With this
+	  enabled, perf can be used to monitor the DSA (Intel Data
+	  Streaming Accelerator) events described in the Intel DSA
+	  spec.
+
+	  If unsure, say N.
+
 config INTEL_IOATDMA
 	tristate "Intel I/OAT DMA support"
 	depends on PCI && X86_64
drivers/dma/idxd/Makefile +2 -0
index 8978b898d777..6d11558756f8 100644
@@ -1,2 +1,4 @@
 obj-$(CONFIG_INTEL_IDXD) += idxd.o
 idxd-y := init.o irq.o device.o sysfs.o submit.o dma.o cdev.o
+
+idxd-$(CONFIG_INTEL_IDXD_PERFMON) += perfmon.o
drivers/dma/idxd/idxd.h +45 -0

73 lines not on this page · raw message

drivers/dma/idxd/init.c +9 -0
index 085a0c3b62c6..e117d30c97ce 100644
@@ -21,6 +21,7 @@
 #include "../dmaengine.h"
 #include "registers.h"
 #include "idxd.h"
+#include "perfmon.h"
 
 MODULE_VERSION(IDXD_DRIVER_VERSION);
 MODULE_LICENSE("GPL v2");
@@ -378,6 +379,10 @@ static int idxd_probe(struct idxd_device *idxd)
 
 	idxd->major = idxd_cdev_get_major(idxd);
 
+	rc = perfmon_pmu_init(idxd);
+	if (rc < 0)
+		dev_warn(dev, "Failed to initialize perfmon. No PMU support: %d\n", rc);
+
 	dev_dbg(dev, "IDXD device %d probed successfully\n", idxd->id);
 	return 0;
 
@@ -522,6 +527,7 @@ static void idxd_remove(struct pci_dev *pdev)
 	idxd_shutdown(pdev);
 	if (device_pasid_enabled(idxd))
 		idxd_disable_system_pasid(idxd);
+	perfmon_pmu_remove(idxd);
 	mutex_lock(&idxd_idr_lock);
 	idr_remove(&idxd_idrs[idxd->type], idxd->id);
 	mutex_unlock(&idxd_idr_lock);
@@ -556,6 +562,8 @@ static int __init idxd_init_module(void)
 	for (i = 0; i < IDXD_TYPE_MAX; i++)
 		idr_init(&idxd_idrs[i]);
 
+	perfmon_init();
+
 	err = idxd_register_bus_type();
 	if (err < 0)
 		return err;
@@ -589,5 +597,6 @@ static void __exit idxd_exit_module(void)
 	pci_unregister_driver(&idxd_pci_driver);
 	idxd_cdev_remove();
 	idxd_unregister_bus_type();
+	perfmon_exit();
 }
 module_exit(idxd_exit_module);
drivers/dma/idxd/irq.c +1 -4
index a60ca11a5784..bb2f4f5f66ec 100644
@@ -163,11 +163,8 @@ static int process_misc_interrupts(struct idxd_device *idxd, u32 cause)
 	}
 
 	if (cause & IDXD_INTC_PERFMON_OVFL) {
-		/*
-		 * Driver does not utilize perfmon counter overflow interrupt
-		 * yet.
-		 */
 		val |= IDXD_INTC_PERFMON_OVFL;
+		perfmon_counter_overflow(idxd);
 	}
 
 	val ^= cause;
drivers/dma/idxd/perfmon.c new file +653 -0

653 lines not on this page · raw message

drivers/dma/idxd/perfmon.h new file +119 -0

119 lines not on this page · raw message

drivers/dma/idxd/registers.h +108 -0

112 lines not on this page · raw message

include/linux/cpuhotplug.h +1 -0
index f14adb882338..264d911424c0 100644
@@ -167,6 +167,7 @@ enum cpuhp_state {
 	CPUHP_AP_PERF_X86_RAPL_ONLINE,
 	CPUHP_AP_PERF_X86_CQM_ONLINE,
 	CPUHP_AP_PERF_X86_CSTATE_ONLINE,
+	CPUHP_AP_PERF_X86_IDXD_ONLINE,
 	CPUHP_AP_PERF_S390_CF_ONLINE,
 	CPUHP_AP_PERF_S390_CFD_ONLINE,
 	CPUHP_AP_PERF_S390_SF_ONLINE,
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH v2 1/1] dmaengine: idxd: Add IDXD performance monitor support

drivers/dma/Kconfig config INTEL_IDXD_SVM · line 306

Quoted 4 lines · Tom Zanussi
drivers/dma/Kconfig +4 -0
+config INTEL_IDXD_PERFMON
+	bool "Intel Data Accelerators performance monitor support"
+	depends on INTEL_IDXD
+	default y

default y..?

drivers/dma/idxd/idxd.h int idxd_cdev_get_major(struct idxd_device *idxd); · line 403

Quoted 7 lines

/* IDXD software descriptor */

drivers/dma/idxd/idxd.h +2 -0
@@ -369,4 +399,19 @@ int idxd_cdev_get_major(struct idxd_device *idxd);
 int idxd_wq_add_cdev(struct idxd_wq *wq);
 void idxd_wq_del_cdev(struct idxd_wq *wq);
 
+/* perfmon */
+#ifdef CONFIG_INTEL_IDXD_PERFMON

maybe use IS_ENABLED()

Quoted 10 lines
drivers/dma/idxd/init.c +2 -0
@@ -556,6 +562,8 @@ static int __init idxd_init_module(void)
 	for (i = 0; i < IDXD_TYPE_MAX; i++)
 		idr_init(&idxd_idrs[i]);
 
+	perfmon_init();
+
 	err = idxd_register_bus_type();
 	if (err < 0)
 		return err;

drivers/dma/idxd/init.c static void __exit idxd_exit_module(void) · line 600

Quoted 4 lines
drivers/dma/idxd/init.c +1 -0
@@ -589,5 +597,6 @@ static void __exit idxd_exit_module(void)
 	pci_unregister_driver(&idxd_pci_driver);
 	idxd_cdev_remove();
 	idxd_unregister_bus_type();
+	perfmon_exit();

Ideally would make sense to add perfmon module first and then add use in idxd..

drivers/dma/idxd/perfmon.c line 16

Quoted 8 lines
drivers/dma/idxd/perfmon.c new file +8 -0
+static ssize_t cpumask_show(struct device *dev, struct device_attribute *attr,
+			    char *buf);
+
+static cpumask_t		perfmon_dsa_cpu_mask;
+static bool			cpuhp_set_up;
+static enum cpuhp_state		cpuhp_slot;
+
+static DEVICE_ATTR_RO(cpumask);

Pls document these new attributes added

drivers/dma/idxd/perfmon.c line 76

Quoted 3 lines
drivers/dma/idxd/perfmon.c new file +3 -0
+static int perfmon_collect_events(struct idxd_pmu *idxd_pmu,
+				  struct perf_event *leader,
+				  bool dogrp)

dogrp..?

Quoted 21 lines
drivers/dma/idxd/perfmon.c new file +21 -0
+static int perfmon_validate_group(struct idxd_pmu *pmu,
+				  struct perf_event *event)
+{
+	struct perf_event *leader = event->group_leader;
+	struct idxd_pmu *fake_pmu;
+	int i, ret = 0, n;
+
+	fake_pmu = kzalloc(sizeof(*fake_pmu), GFP_KERNEL);
+	if (!fake_pmu)
+		return -ENOMEM;
+
+	fake_pmu->pmu.name = pmu->pmu.name;
+	fake_pmu->n_counters = pmu->n_counters;
+
+	n = perfmon_collect_events(fake_pmu, leader, true);
+	if (n < 0) {
+		ret = n;
+		goto out;
+	}
+
+	fake_pmu->n_events = n;

drivers/dma/idxd/perfmon.c line 173

Quoted 10 lines
drivers/dma/idxd/perfmon.c new file +10 -0
+	n = perfmon_collect_events(fake_pmu, event, false);
+	if (n < 0) {
+		ret = n;
+		goto out;
+	}
+
+	fake_pmu->n_events = n;
+
+	for (i = 0; i < n; i++) {
+		int idx;

lets move it to top of the function please

drivers/dma/idxd/perfmon.c line 232

Quoted 12 lines
drivers/dma/idxd/perfmon.c new file +12 -0
+static inline u64 perfmon_pmu_read_counter(struct perf_event *event)
+{
+	struct hw_perf_event *hwc = &event->hw;
+	struct idxd_device *idxd;
+	int cntr = hwc->idx;
+	u64 cntrdata;
+
+	idxd = event_to_idxd(event);
+
+	cntrdata = ioread64(CNTRDATA_REG(idxd, cntr));
+
+	return cntrdata;

return ioread64() ?

Signature · 1 line
~Vinod
#3 lore raw

Re: [PATCH v2 1/1] dmaengine: idxd: Add IDXD performance monitor support

Hi Vinod,

Quoted 8 lines · Vinod Koul

drivers/dma/Kconfig config INTEL_IDXD_SVM · line 306

Quoted 4 lines · Tom Zanussi
drivers/dma/Kconfig +4 -0
+config INTEL_IDXD_PERFMON
+	bool "Intel Data Accelerators performance monitor support"
+	depends on INTEL_IDXD
+	default y

default y..?

Will change to n.

Quoted 15 lines

drivers/dma/idxd/idxd.h int idxd_cdev_get_major(struct idxd_device *idxd); · line 403

Quoted 8 lines

/* IDXD software descriptor */

drivers/dma/idxd/idxd.h +2 -0
@@ -369,4 +399,19 @@ int idxd_cdev_get_major(struct idxd_device *idxd);
  int idxd_wq_add_cdev(struct idxd_wq *wq);
  void idxd_wq_del_cdev(struct idxd_wq *wq);
 
+/* perfmon */
+#ifdef CONFIG_INTEL_IDXD_PERFMON

maybe use IS_ENABLED()

Quoted 4 lines
drivers/dma/idxd/init.c +0 -0
@@ -556,6 +562,8 @@ static int __init idxd_init_module(void)
  	for (i = 0; i < IDXD_TYPE_MAX; i++)
  		idr_init(&idxd_idrs[i]);
 
Quoted 14 lines

drivers/dma/idxd/init.c static void __exit idxd_exit_module(void) · line 600

Quoted 10 lines
drivers/dma/idxd/init.c +3 -0
+	perfmon_init();
+
  	err = idxd_register_bus_type();
  	if (err < 0)
  		return err;
@@ -589,5 +597,6 @@ static void __exit idxd_exit_module(void)
  	pci_unregister_driver(&idxd_pci_driver);
  	idxd_cdev_remove();
  	idxd_unregister_bus_type();
+	perfmon_exit();

Ideally would make sense to add perfmon module first and then add use in idxd..

OK, I'll separate this out into a separate patch.

Quoted 11 lines

drivers/dma/idxd/perfmon.c line 16

Quoted 8 lines
drivers/dma/idxd/perfmon.c new file +8 -0
+static ssize_t cpumask_show(struct device *dev, struct device_attribute *attr,
+			    char *buf);
+
+static cpumask_t		perfmon_dsa_cpu_mask;
+static bool			cpuhp_set_up;
+static enum cpuhp_state		cpuhp_slot;
+
+static DEVICE_ATTR_RO(cpumask);

Pls document these new attributes added

Quoted 6 lines

drivers/dma/idxd/perfmon.c line 76

Quoted 3 lines
drivers/dma/idxd/perfmon.c new file +3 -0
+static int perfmon_collect_events(struct idxd_pmu *idxd_pmu,
+				  struct perf_event *leader,
+				  bool dogrp)

dogrp..?

Yeah, bad name, first thought on seeing it is always 'dog'. ;-)

Quoted 34 lines
Quoted 21 lines
drivers/dma/idxd/perfmon.c new file +21 -0
+static int perfmon_validate_group(struct idxd_pmu *pmu,
+				  struct perf_event *event)
+{
+	struct perf_event *leader = event->group_leader;
+	struct idxd_pmu *fake_pmu;
+	int i, ret = 0, n;
+
+	fake_pmu = kzalloc(sizeof(*fake_pmu), GFP_KERNEL);
+	if (!fake_pmu)
+		return -ENOMEM;
+
+	fake_pmu->pmu.name = pmu->pmu.name;
+	fake_pmu->n_counters = pmu->n_counters;
+
+	n = perfmon_collect_events(fake_pmu, leader, true);
+	if (n < 0) {
+		ret = n;
+		goto out;
+	}
+
+	fake_pmu->n_events = n;

drivers/dma/idxd/perfmon.c line 173

Quoted 10 lines
drivers/dma/idxd/perfmon.c new file +10 -0
+	n = perfmon_collect_events(fake_pmu, event, false);
+	if (n < 0) {
+		ret = n;
+		goto out;
+	}
+
+	fake_pmu->n_events = n;
+
+	for (i = 0; i < n; i++) {
+		int idx;

lets move it to top of the function please

Quoted 15 lines

drivers/dma/idxd/perfmon.c line 232

Quoted 12 lines
drivers/dma/idxd/perfmon.c new file +12 -0
+static inline u64 perfmon_pmu_read_counter(struct perf_event *event)
+{
+	struct hw_perf_event *hwc = &event->hw;
+	struct idxd_device *idxd;
+	int cntr = hwc->idx;
+	u64 cntrdata;
+
+	idxd = event_to_idxd(event);
+
+	cntrdata = ioread64(CNTRDATA_REG(idxd, cntr));
+
+	return cntrdata;

return ioread64() ?

Yeah, I removed some intervening code and didn't change this, will do.

Thanks for reviewing this,

Tom

maintainer
#4 lore raw

Re: [PATCH v2 1/1] dmaengine: idxd: Add IDXD performance monitor support

Quoted 5 lines · Tom

Hi Vinod,

Quoted 2 lines · Vinod Koul

On 03-04-21, 11:45, Tom Zanussi wrote:

Quoted 8 lines
Quoted 6 lines

drivers/dma/Kconfig config INTEL_IDXD_SVM · line 306

Quoted 4 lines
drivers/dma/Kconfig +4 -0
+config INTEL_IDXD_PERFMON
+	bool "Intel Data Accelerators performance monitor support"
+	depends on INTEL_IDXD
+	default y

default y..?

Will change to n.

That is the default, you may drop this line

Quoted 10 lines
Quoted 10 lines

drivers/dma/idxd/idxd.h int idxd_cdev_get_major(struct idxd_device *idxd); · line 402

Quoted 8 lines

/* IDXD software descriptor */

drivers/dma/idxd/idxd.h +2 -0
@@ -369,4 +399,19 @@ int idxd_cdev_get_major(struct idxd_device *idxd);
  int idxd_wq_add_cdev(struct idxd_wq *wq);
  void idxd_wq_del_cdev(struct idxd_wq *wq);
+/* perfmon */
+#ifdef CONFIG_INTEL_IDXD_PERFMON

maybe use IS_ENABLED()

?

Quoted 19 lines
Quoted 18 lines
Quoted 10 lines
drivers/dma/idxd/init.c +2 -0
@@ -556,6 +562,8 @@ static int __init idxd_init_module(void)
  	for (i = 0; i < IDXD_TYPE_MAX; i++)
  		idr_init(&idxd_idrs[i]);
+	perfmon_init();
+
  	err = idxd_register_bus_type();
  	if (err < 0)
  		return err;

drivers/dma/idxd/init.c static void __exit idxd_exit_module(void) · line 600

Quoted 4 lines
drivers/dma/idxd/init.c +1 -0
@@ -589,5 +597,6 @@ static void __exit idxd_exit_module(void)
  	pci_unregister_driver(&idxd_pci_driver);
  	idxd_cdev_remove();
  	idxd_unregister_bus_type();
+	perfmon_exit();

Ideally would make sense to add perfmon module first and then add use in idxd..

Quoted 12 lines

OK, I'll separate this out into a separate patch.

Quoted 10 lines

drivers/dma/idxd/perfmon.c line 16

Quoted 8 lines
drivers/dma/idxd/perfmon.c new file +8 -0
+static ssize_t cpumask_show(struct device *dev, struct device_attribute *attr,
+			    char *buf);
+
+static cpumask_t		perfmon_dsa_cpu_mask;
+static bool			cpuhp_set_up;
+static enum cpuhp_state		cpuhp_slot;
+
+static DEVICE_ATTR_RO(cpumask);

Pls document these new attributes added

?

Quoted 9 lines
Quoted 7 lines

drivers/dma/idxd/perfmon.c line 76

Quoted 4 lines
drivers/dma/idxd/perfmon.c new file +3 -0
+static int perfmon_collect_events(struct idxd_pmu *idxd_pmu,
+				  struct perf_event *leader,
+				  bool dogrp)

dogrp..?

Yeah, bad name, first thought on seeing it is always 'dog'. ;-)

Yep, that was my first read as well... i guess it would be better as do_grp

Signature · 1 line
~Vinod
#5 lore raw

Re: [PATCH v2 1/1] dmaengine: idxd: Add IDXD performance monitor support

Hi Vinod,

Quoted 13 lines · Vinod Koul
Quoted 12 lines · Tom

Hi Vinod,

Quoted 8 lines · Vinod Koul

drivers/dma/Kconfig config INTEL_IDXD_SVM · line 306

Quoted 4 lines · Tom Zanussi
drivers/dma/Kconfig +4 -0
+config INTEL_IDXD_PERFMON
+	bool "Intel Data Accelerators performance monitor support"
+	depends on INTEL_IDXD
+	default y

default y..?

Quoted 4 lines
Quoted 1 line

Will change to n.

That is the default, you may drop this line

OK, will do.

Quoted 11 lines
Quoted 10 lines
Quoted 10 lines

drivers/dma/idxd/idxd.h int idxd_cdev_get_major(struct idxd_device *idxd); · line 402

Quoted 8 lines

   /* IDXD software descriptor */
drivers/dma/idxd/idxd.h +2 -0
@@ -369,4 +399,19 @@ int idxd_cdev_get_major(struct idxd_device *idxd);
   int idxd_wq_add_cdev(struct idxd_wq *wq);
   void idxd_wq_del_cdev(struct idxd_wq *wq);
+/* perfmon */
+#ifdef CONFIG_INTEL_IDXD_PERFMON

maybe use IS_ENABLED()

Quoted 2 lines

?

Yes, I'll change to this.

Quoted 32 lines
Quoted 19 lines
Quoted 18 lines
Quoted 10 lines
drivers/dma/idxd/init.c +2 -0
@@ -556,6 +562,8 @@ static int __init idxd_init_module(void)
   	for (i = 0; i < IDXD_TYPE_MAX; i++)
   		idr_init(&idxd_idrs[i]);
+	perfmon_init();
+
   	err = idxd_register_bus_type();
   	if (err < 0)
   		return err;

drivers/dma/idxd/init.c static void __exit idxd_exit_module(void) · line 600

Quoted 4 lines
drivers/dma/idxd/init.c +1 -0
@@ -589,5 +597,6 @@ static void __exit idxd_exit_module(void)
   	pci_unregister_driver(&idxd_pci_driver);
   	idxd_cdev_remove();
   	idxd_unregister_bus_type();
+	perfmon_exit();

Ideally would make sense to add perfmon module first and then add use in idxd..

Quoted 12 lines

OK, I'll separate this out into a separate patch.

Quoted 10 lines

drivers/dma/idxd/perfmon.c line 16

Quoted 8 lines
drivers/dma/idxd/perfmon.c new file +8 -0
+static ssize_t cpumask_show(struct device *dev, struct device_attribute *attr,
+			    char *buf);
+
+static cpumask_t		perfmon_dsa_cpu_mask;
+static bool			cpuhp_set_up;
+static enum cpuhp_state		cpuhp_slot;
+
+static DEVICE_ATTR_RO(cpumask);

Pls document these new attributes added

Quoted 2 lines

?

Yes, I'll add comments to all the attributes (also I'm assuming they don't need to be documented elsewhere).

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

drivers/dma/idxd/perfmon.c line 76

Quoted 4 lines
drivers/dma/idxd/perfmon.c new file +3 -0
+static int perfmon_collect_events(struct idxd_pmu *idxd_pmu,
+				  struct perf_event *leader,
+				  bool dogrp)

dogrp..?

Quoted 5 lines
Quoted 1 line

Yeah, bad name, first thought on seeing it is always 'dog'. ;-)

Yep, that was my first read as well... i guess it would be better as do_grp

Yep, will make change it to that.

Thanks,

Tom

maintainer
#6 lore raw

Re: [PATCH v2 1/1] dmaengine: idxd: Add IDXD performance monitor support

Quoted 11 lines · Tom
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines

drivers/dma/idxd/perfmon.c line 16

Quoted 8 lines
drivers/dma/idxd/perfmon.c new file +8 -0
+static ssize_t cpumask_show(struct device *dev, struct device_attribute *attr,
+			    char *buf);
+
+static cpumask_t		perfmon_dsa_cpu_mask;
+static bool			cpuhp_set_up;
+static enum cpuhp_state		cpuhp_slot;
+
+static DEVICE_ATTR_RO(cpumask);

Pls document these new attributes added

Quoted 4 lines
Quoted 2 lines

?

Yes, I'll add comments to all the attributes (also I'm assuming they don't need to be documented elsewhere).

They need to be, all new sysfs attributes are ABI and need to be documented in Documentation/ABI/

Thanks

Signature · 1 line
~Vinod
#7 lore raw

Re: [PATCH v2 1/1] dmaengine: idxd: Add IDXD performance monitor support

Quoted 13 lines · Vinod Koul
Quoted 11 lines · Tom
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines

drivers/dma/idxd/perfmon.c line 16

Quoted 8 lines
drivers/dma/idxd/perfmon.c new file +8 -0
+static ssize_t cpumask_show(struct device *dev, struct device_attribute *attr,
+			    char *buf);
+
+static cpumask_t		perfmon_dsa_cpu_mask;
+static bool			cpuhp_set_up;
+static enum cpuhp_state		cpuhp_slot;
+
+static DEVICE_ATTR_RO(cpumask);

Pls document these new attributes added

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

?

Yes, I'll add comments to all the attributes (also I'm assuming they don't need to be documented elsewhere).

They need to be, all new sysfs attributes are ABI and need to be documented in Documentation/ABI/

OK, will do that as well, thanks for letting me know.

Tom

Quoted 2 lines

Thanks