Skip to contentSkip to conversation

Add perf interface to expose nvdimm

PATCH Superseded Kajol Jain 4 participants 15 messages Feb 17, 2022 – Feb 25, 2022

Subsystems (2)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Kajol Jain

author
#0 lore raw

v6 cover Add perf interface to expose nvdimm

Patchset adds performance stats reporting support for nvdimm. Added interface includes support for pmu register/unregister functions. A structure is added called nvdimm_pmu to be used for adding arch/platform specific data such as cpumask, nvdimm device pointer and pmu event functions like event_init/add/read/del. User could use the standard perf tool to access perf events exposed via pmu.

Interface also defines supported event list, config fields for the event attributes and their corresponding bit values which are exported via sysfs. Patch 3 exposes IBM pseries platform nmem* device performance stats using this interface.

Result from power9 pseries lpar with 2 nvdimm device:

Ex: List all event by perf list

command:# perf list nmem

  nmem0/cache_rh_cnt/                                [Kernel PMU event]
  nmem0/cache_wh_cnt/                                [Kernel PMU event]
  nmem0/cri_res_util/                                [Kernel PMU event]
  nmem0/ctl_res_cnt/                                 [Kernel PMU event]
  nmem0/ctl_res_tm/                                  [Kernel PMU event]
  nmem0/fast_w_cnt/                                  [Kernel PMU event]
  nmem0/host_l_cnt/                                  [Kernel PMU event]
  nmem0/host_l_dur/                                  [Kernel PMU event]
  nmem0/host_s_cnt/                                  [Kernel PMU event]
  nmem0/host_s_dur/                                  [Kernel PMU event]
  nmem0/med_r_cnt/                                   [Kernel PMU event]
  nmem0/med_r_dur/                                   [Kernel PMU event]
  nmem0/med_w_cnt/                                   [Kernel PMU event]
  nmem0/med_w_dur/                                   [Kernel PMU event]
  nmem0/mem_life/                                    [Kernel PMU event]
  nmem0/poweron_secs/                                [Kernel PMU event]

...
nmem1/mem_life/ [Kernel PMU event]
nmem1/poweron_secs/ [Kernel PMU event]

Patch1:
Introduces the nvdimm_pmu structure
Patch2:
Adds common interface to add arch/platform specific data includes nvdimm device pointer, pmu data along with pmu event functions. It also defines supported event list and adds attribute groups for format, events and cpumask. It also adds code for cpu hotplug support.
Patch3:
Add code in arch/powerpc/platform/pseries/papr_scm.c to expose nmem* pmu. It fills in the nvdimm_pmu structure with pmu name, capabilities, cpumask and event functions and then registers the pmu by adding callbacks to register_nvdimm_pmu.
Patch4:
Sysfs documentation patch

Changelog
---
Resend v5 -> v6
- No logic change, just a rebase to latest upstream and tested the patchset.

- Link to the patchset Resend v5: https://lkml.org/lkml/2021/11/15/3979

v5 -> Resend v5
- Resend the patchset

- Link to the patchset v5: https://lkml.org/lkml/2021/9/28/643

v4 -> v5:
- Remove multiple variables defined in nvdimm_pmu structure include name and pmu functions(event_int/add/del/read) as they are just used to copy them again in pmu variable. Now we are directly doing this step in arch specific code as suggested by Dan Williams.

- Remove attribute group field from nvdimm pmu structure and defined these attribute groups in common interface which includes format, event list along with cpumask as suggested by Dan Williams.
Since we added static defination for attrbute groups needed in common interface, removes corresponding code from papr.

- Add nvdimm pmu event list with event codes in the common interface.

- Remove Acked-by/Reviewed-by/Tested-by tags as code is refactored to handle review comments from Dan.

- Make nvdimm_pmu_free_hotplug_memory function static as reported by kernel test robot, also add corresponding Reported-by tag.

- Link to the patchset v4: https://lkml.org/lkml/2021/9/3/45

v3 -> v4
- Rebase code on top of current papr_scm code without any logical changes.

- Added Acked-by tag from Peter Zijlstra and Reviewed by tag from Madhavan Srinivasan.

- Link to the patchset v3: https://lkml.org/lkml/2021/6/17/605

v2 -> v3
- Added Tested-by tag.

- Fix nvdimm mailing list in the ABI Documentation.

- Link to the patchset v2: https://lkml.org/lkml/2021/6/14/25

v1 -> v2
- Fix hotplug code by adding pmu migration call
incase current designated cpu got offline. As
pointed by Peter Zijlstra.

- Removed the retun -1 part from cpu hotplug offline function.

- Link to the patchset v1: https://lkml.org/lkml/2021/6/8/500

Kajol Jain (4):
drivers/nvdimm: Add nvdimm pmu structure
drivers/nvdimm: Add perf interface to expose nvdimm performance stats powerpc/papr_scm: Add perf interface support
docs: ABI: sysfs-bus-nvdimm: Document sysfs event format entries for
nvdimm pmu

 Documentation/ABI/testing/sysfs-bus-nvdimm |  35 +++
 arch/powerpc/include/asm/device.h          |   5 +
 arch/powerpc/platforms/pseries/papr_scm.c  | 225 ++++++++++++++
 drivers/nvdimm/Makefile                    |   1 +
 drivers/nvdimm/nd_perf.c                   | 328 +++++++++++++++++++++
 include/linux/nd.h                         |  41 +++
 6 files changed, 635 insertions(+)
 create mode 100644 drivers/nvdimm/nd_perf.c
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH v6 1/4 drivers/nvdimm: Add nvdimm pmu structure

A structure is added called nvdimm_pmu, for performance stats reporting support of nvdimm devices. It can be used to add device pmu data such as pmu data structure for performance stats, nvdimm device pointer along with cpumask attributes.

---
Changelog:
Resend v5 -> v6
- No logic change, just a rebase to latest upstream and tested the patch.

- Link to the patchset Resend v5: https://lkml.org/lkml/2021/11/15/3979

 include/linux/nd.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
include/linux/nd.h +20 -0
index 8a8c63edb1b2..ad186e828263 100644
@@ -8,6 +8,7 @@
 #include <linux/ndctl.h>
 #include <linux/device.h>
 #include <linux/badblocks.h>
+#include <linux/perf_event.h>
 
 enum nvdimm_event {
 	NVDIMM_REVALIDATE_POISON,
@@ -23,6 +24,25 @@ enum nvdimm_claim_class {
 	NVDIMM_CCLASS_UNKNOWN,
 };
 
+/**
+ * struct nvdimm_pmu - data structure for nvdimm perf driver
+ * @pmu: pmu data structure for nvdimm performance stats.
+ * @dev: nvdimm device pointer.
+ * @cpu: designated cpu for counter access.
+ * @node: node for cpu hotplug notifier link.
+ * @cpuhp_state: state for cpu hotplug notification.
+ * @arch_cpumask: cpumask to get designated cpu for counter access.
+ */
+struct nvdimm_pmu {
+	struct pmu pmu;
+	struct device *dev;
+	int cpu;
+	struct hlist_node node;
+	enum cpuhp_state cpuhp_state;
+	/* cpumask provided by arch/platform specific code */
+	struct cpumask arch_cpumask;
+};
+
 struct nd_device_driver {
 	struct device_driver drv;
 	unsigned long type;
Signature · 1 line
2.31.1
author
#2 lore raw

PATCH v6 2/4 drivers/nvdimm: Add perf interface to expose nvdimm performance stats

In reply to Kajol Jain

A common interface is added to get performance stats reporting support for nvdimm devices. Added interface defines supported event list, config fields for the event attributes and their corresponding bit values which are exported via sysfs.

Interface also added support for pmu register/unregister functions, cpu hotplug feature along with macros for handling events addition via sysfs. It adds attribute groups for format, cpumask and events to the pmu structure.

User could use the standard perf tool to access perf events exposed via nvdimm pmu.

[Make hotplug function static as reported by kernel test rorbot]

---
Changelog:
Resend v5 -> v6
- No logic change, just a rebase to latest upstream and tested the patch.

- Link to the patchset Resend v5: https://lkml.org/lkml/2021/11/15/3979

 drivers/nvdimm/Makefile  |   1 +
 drivers/nvdimm/nd_perf.c | 328 +++++++++++++++++++++++++++++++++++++++
 include/linux/nd.h       |  21 +++
 3 files changed, 350 insertions(+)
 create mode 100644 drivers/nvdimm/nd_perf.c
drivers/nvdimm/Makefile +1 -0
index 29203f3d3069..25dba6095612 100644
@@ -18,6 +18,7 @@ nd_e820-y := e820.o
 libnvdimm-y := core.o
 libnvdimm-y += bus.o
 libnvdimm-y += dimm_devs.o
+libnvdimm-y += nd_perf.o
 libnvdimm-y += dimm.o
 libnvdimm-y += region_devs.o
 libnvdimm-y += region.o
drivers/nvdimm/nd_perf.c new file +328 -0

328 lines not on this page · raw message

include/linux/nd.h +21 -0
index ad186e828263..f28bda6c5512 100644
@@ -9,6 +9,7 @@
 #include <linux/device.h>
 #include <linux/badblocks.h>
 #include <linux/perf_event.h>
+#include <linux/platform_device.h>
 
 enum nvdimm_event {
 	NVDIMM_REVALIDATE_POISON,
@@ -24,6 +25,19 @@ enum nvdimm_claim_class {
 	NVDIMM_CCLASS_UNKNOWN,
 };
 
+#define NVDIMM_EVENT_VAR(_id)  event_attr_##_id
+#define NVDIMM_EVENT_PTR(_id)  (&event_attr_##_id.attr.attr)
+
+#define NVDIMM_EVENT_ATTR(_name, _id)				\
+	PMU_EVENT_ATTR(_name, NVDIMM_EVENT_VAR(_id), _id,	\
+			nvdimm_events_sysfs_show)
+
+/* Event attribute array index */
+#define NVDIMM_PMU_FORMAT_ATTR	0
+#define NVDIMM_PMU_EVENT_ATTR	1
+#define NVDIMM_PMU_CPUMASK_ATTR	2
+#define NVDIMM_PMU_NULL_ATTR	3
+
 /**
  * struct nvdimm_pmu - data structure for nvdimm perf driver
  * @pmu: pmu data structure for nvdimm performance stats.
@@ -43,6 +57,13 @@ struct nvdimm_pmu {
 	struct cpumask arch_cpumask;
 };
 
+extern ssize_t nvdimm_events_sysfs_show(struct device *dev,
+					struct device_attribute *attr,
+					char *page);
+
+int register_nvdimm_pmu(struct nvdimm_pmu *nvdimm, struct platform_device *pdev);
+void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu);
+
 struct nd_device_driver {
 	struct device_driver drv;
 	unsigned long type;
Signature · 1 line
2.31.1
author
#3 lore raw

PATCH v6 3/4 powerpc/papr_scm: Add perf interface support

In reply to Kajol Jain

Performance monitoring support for papr-scm nvdimm devices via perf interface is added which includes addition of pmu functions like add/del/read/event_init for nvdimm_pmu struture.

A new parameter 'priv' in added to the pdev_archdata structure to save nvdimm_pmu device pointer, to handle the unregistering of pmu device.

papr_scm_pmu_register function populates the nvdimm_pmu structure with name, capabilities, cpumask along with event handling functions. Finally the populated nvdimm_pmu structure is passed to register the pmu device. Event handling functions internally uses hcall to get events and counter data.

Result in power9 machine with 2 nvdimm device:

Ex: List all event by perf list

command:# perf list nmem

  nmem0/cache_rh_cnt/                                [Kernel PMU event]
  nmem0/cache_wh_cnt/                                [Kernel PMU event]
  nmem0/cri_res_util/                                [Kernel PMU event]
  nmem0/ctl_res_cnt/                                 [Kernel PMU event]
  nmem0/ctl_res_tm/                                  [Kernel PMU event]
  nmem0/fast_w_cnt/                                  [Kernel PMU event]
  nmem0/host_l_cnt/                                  [Kernel PMU event]
  nmem0/host_l_dur/                                  [Kernel PMU event]
  nmem0/host_s_cnt/                                  [Kernel PMU event]
  nmem0/host_s_dur/                                  [Kernel PMU event]
  nmem0/med_r_cnt/                                   [Kernel PMU event]
  nmem0/med_r_dur/                                   [Kernel PMU event]
  nmem0/med_w_cnt/                                   [Kernel PMU event]
  nmem0/med_w_dur/                                   [Kernel PMU event]
  nmem0/mem_life/                                    [Kernel PMU event]
  nmem0/poweron_secs/                                [Kernel PMU event]

...
nmem1/mem_life/ [Kernel PMU event]
nmem1/poweron_secs/ [Kernel PMU event]

---
Changelog:
Resend v5 -> v6
- No logic change, just a rebase to latest upstream and tested the patch.

- Link to the patchset Resend v5: https://lkml.org/lkml/2021/11/15/3979

 arch/powerpc/include/asm/device.h         |   5 +
 arch/powerpc/platforms/pseries/papr_scm.c | 225 ++++++++++++++++++++++
 2 files changed, 230 insertions(+)
arch/powerpc/include/asm/device.h +5 -0
index 219559d65864..47ed639f3b8f 100644
@@ -48,6 +48,11 @@ struct dev_archdata {
 
 struct pdev_archdata {
 	u64 dma_mask;
+	/*
+	 * Pointer to nvdimm_pmu structure, to handle the unregistering
+	 * of pmu device
+	 */
+	void *priv;
 };
 
 #endif /* _ASM_POWERPC_DEVICE_H */
arch/powerpc/platforms/pseries/papr_scm.c +225 -0

261 lines not on this page · raw message

Signature · 1 line
2.31.1
author
#4 lore raw

PATCH v6 4/4 docs: ABI: sysfs-bus-nvdimm: Document sysfs event format entries for nvdimm pmu

In reply to Kajol Jain

Details are added for the event, cpumask and format attributes in the ABI documentation.

---
Changelog:
Resend v5 -> v6
- No logic change, just a rebase to latest upstream.

- Link to the patchset Resend v5: https://lkml.org/lkml/2021/11/15/3979

 Documentation/ABI/testing/sysfs-bus-nvdimm | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
Documentation/ABI/testing/sysfs-bus-nvdimm +35 -0
index bff84a16812a..64004d5e4840 100644
@@ -6,3 +6,38 @@ Description:
 
 The libnvdimm sub-system implements a common sysfs interface for
 platform nvdimm resources. See Documentation/driver-api/nvdimm/.
+
+What:           /sys/bus/event_source/devices/nmemX/format
+Date:           February 2022
+KernelVersion:  5.18
+Contact:        Kajol Jain <[email protected]>
+Description:	(RO) Attribute group to describe the magic bits
+		that go into perf_event_attr.config for a particular pmu.
+		(See ABI/testing/sysfs-bus-event_source-devices-format).
+
+		Each attribute under this group defines a bit range of the
+		perf_event_attr.config. Supported attribute is listed
+		below::
+		  event  = "config:0-4"  - event ID
+
+		For example::
+			ctl_res_cnt = "event=0x1"
+
+What:           /sys/bus/event_source/devices/nmemX/events
+Date:           February 2022
+KernelVersion:  5.18
+Contact:        Kajol Jain <[email protected]>
+Description:	(RO) Attribute group to describe performance monitoring events
+                for the nvdimm memory device. Each attribute in this group
+                describes a single performance monitoring event supported by
+                this nvdimm pmu.  The name of the file is the name of the event.
+                (See ABI/testing/sysfs-bus-event_source-devices-events). A
+                listing of the events supported by a given nvdimm provider type
+                can be found in Documentation/driver-api/nvdimm/$provider.
+
+What:          /sys/bus/event_source/devices/nmemX/cpumask
+Date:          February 2022
+KernelVersion:  5.18
+Contact:        Kajol Jain <[email protected]>
+Description:	(RO) This sysfs file exposes the cpumask which is designated to
+		to retrieve nvdimm pmu event counter data.
Signature · 1 line
2.31.1
#5 lore raw
In reply to Kajol Jain
Quoted 82 lines · Kajol Jain

Patchset adds performance stats reporting support for nvdimm. Added interface includes support for pmu register/unregister functions. A structure is added called nvdimm_pmu to be used for adding arch/platform specific data such as cpumask, nvdimm device pointer and pmu event functions like event_init/add/read/del. User could use the standard perf tool to access perf events exposed via pmu.

Interface also defines supported event list, config fields for the event attributes and their corresponding bit values which are exported via sysfs. Patch 3 exposes IBM pseries platform nmem* device performance stats using this interface.

Result from power9 pseries lpar with 2 nvdimm device:

Ex: List all event by perf list

command:# perf list nmem

  nmem0/cache_rh_cnt/                                [Kernel PMU event]
  nmem0/cache_wh_cnt/                                [Kernel PMU event]
  nmem0/cri_res_util/                                [Kernel PMU event]
  nmem0/ctl_res_cnt/                                 [Kernel PMU event]
  nmem0/ctl_res_tm/                                  [Kernel PMU event]
  nmem0/fast_w_cnt/                                  [Kernel PMU event]
  nmem0/host_l_cnt/                                  [Kernel PMU event]
  nmem0/host_l_dur/                                  [Kernel PMU event]
  nmem0/host_s_cnt/                                  [Kernel PMU event]
  nmem0/host_s_dur/                                  [Kernel PMU event]
  nmem0/med_r_cnt/                                   [Kernel PMU event]
  nmem0/med_r_dur/                                   [Kernel PMU event]
  nmem0/med_w_cnt/                                   [Kernel PMU event]
  nmem0/med_w_dur/                                   [Kernel PMU event]
  nmem0/mem_life/                                    [Kernel PMU event]
  nmem0/poweron_secs/                                [Kernel PMU event]

...
nmem1/mem_life/ [Kernel PMU event]
nmem1/poweron_secs/ [Kernel PMU event]

Patch1:
Introduces the nvdimm_pmu structure
Patch2:
Adds common interface to add arch/platform specific data includes nvdimm device pointer, pmu data along with pmu event functions. It also defines supported event list and adds attribute groups for format, events and cpumask. It also adds code for cpu hotplug support.
Patch3:
Add code in arch/powerpc/platform/pseries/papr_scm.c to expose nmem* pmu. It fills in the nvdimm_pmu structure with pmu name, capabilities, cpumask and event functions and then registers the pmu by adding callbacks to register_nvdimm_pmu.
Patch4:
Sysfs documentation patch

Changelog
---
Resend v5 -> v6
- No logic change, just a rebase to latest upstream and tested the patchset.

- Link to the patchset Resend v5: https://lkml.org/lkml/2021/11/15/3979

v5 -> Resend v5
- Resend the patchset

- Link to the patchset v5: https://lkml.org/lkml/2021/9/28/643

v4 -> v5:
- Remove multiple variables defined in nvdimm_pmu structure include name and pmu functions(event_int/add/del/read) as they are just used to copy them again in pmu variable. Now we are directly doing this step in arch specific code as suggested by Dan Williams.

- Remove attribute group field from nvdimm pmu structure and defined these attribute groups in common interface which includes format, event list along with cpumask as suggested by Dan Williams.
Since we added static defination for attrbute groups needed in common interface, removes corresponding code from papr.

Quoted 4 lines

- Add nvdimm pmu event list with event codes in the common interface.

- Remove Acked-by/Reviewed-by/Tested-by tags as code is refactored to handle review comments from Dan.

I don't think review comments should invalidate the Acked-by tags in this case. Nothing fundamentally changed in the approach, and I would like to have the perf ack before taking this through the nvdimm tree.

Otherwise this looks good to me.

Peter, might you have a chance to re-Ack this series, or any concerns about me retrieving those Acks from the previous postings?

#6 lore raw
Quoted 89 lines · Dan Williams
Quoted 82 lines · Kajol Jain

Patchset adds performance stats reporting support for nvdimm. Added interface includes support for pmu register/unregister functions. A structure is added called nvdimm_pmu to be used for adding arch/platform specific data such as cpumask, nvdimm device pointer and pmu event functions like event_init/add/read/del. User could use the standard perf tool to access perf events exposed via pmu.

Interface also defines supported event list, config fields for the event attributes and their corresponding bit values which are exported via sysfs. Patch 3 exposes IBM pseries platform nmem* device performance stats using this interface.

Result from power9 pseries lpar with 2 nvdimm device:

Ex: List all event by perf list

command:# perf list nmem

  nmem0/cache_rh_cnt/                                [Kernel PMU event]
  nmem0/cache_wh_cnt/                                [Kernel PMU event]
  nmem0/cri_res_util/                                [Kernel PMU event]
  nmem0/ctl_res_cnt/                                 [Kernel PMU event]
  nmem0/ctl_res_tm/                                  [Kernel PMU event]
  nmem0/fast_w_cnt/                                  [Kernel PMU event]
  nmem0/host_l_cnt/                                  [Kernel PMU event]
  nmem0/host_l_dur/                                  [Kernel PMU event]
  nmem0/host_s_cnt/                                  [Kernel PMU event]
  nmem0/host_s_dur/                                  [Kernel PMU event]
  nmem0/med_r_cnt/                                   [Kernel PMU event]
  nmem0/med_r_dur/                                   [Kernel PMU event]
  nmem0/med_w_cnt/                                   [Kernel PMU event]
  nmem0/med_w_dur/                                   [Kernel PMU event]
  nmem0/mem_life/                                    [Kernel PMU event]
  nmem0/poweron_secs/                                [Kernel PMU event]

...
nmem1/mem_life/ [Kernel PMU event]
nmem1/poweron_secs/ [Kernel PMU event]

Patch1:
Introduces the nvdimm_pmu structure
Patch2:
Adds common interface to add arch/platform specific data includes nvdimm device pointer, pmu data along with pmu event functions. It also defines supported event list and adds attribute groups for format, events and cpumask. It also adds code for cpu hotplug support.
Patch3:
Add code in arch/powerpc/platform/pseries/papr_scm.c to expose nmem* pmu. It fills in the nvdimm_pmu structure with pmu name, capabilities, cpumask and event functions and then registers the pmu by adding callbacks to register_nvdimm_pmu.
Patch4:
Sysfs documentation patch

Changelog
---
Resend v5 -> v6
- No logic change, just a rebase to latest upstream and tested the patchset.

- Link to the patchset Resend v5: https://lkml.org/lkml/2021/11/15/3979

v5 -> Resend v5
- Resend the patchset

- Link to the patchset v5: https://lkml.org/lkml/2021/9/28/643

v4 -> v5:
- Remove multiple variables defined in nvdimm_pmu structure include name and pmu functions(event_int/add/del/read) as they are just used to copy them again in pmu variable. Now we are directly doing this step in arch specific code as suggested by Dan Williams.

- Remove attribute group field from nvdimm pmu structure and defined these attribute groups in common interface which includes format, event list along with cpumask as suggested by Dan Williams.
Since we added static defination for attrbute groups needed in common interface, removes corresponding code from papr.

Quoted 4 lines

- Add nvdimm pmu event list with event codes in the common interface.

- Remove Acked-by/Reviewed-by/Tested-by tags as code is refactored to handle review comments from Dan.

Quoted 8 lines

I don't think review comments should invalidate the Acked-by tags in this case. Nothing fundamentally changed in the approach, and I would like to have the perf ack before taking this through the nvdimm tree.

Otherwise this looks good to me.

Peter, might you have a chance to re-Ack this series, or any concerns about me retrieving those Acks from the previous postings?

Reached Peter offline and he refreshed his Acked-by.

#7 lore raw
Quoted 95 lines · Dan Williams
Quoted 93 lines · Dan Williams
Quoted 82 lines · Kajol Jain

Patchset adds performance stats reporting support for nvdimm. Added interface includes support for pmu register/unregister functions. A structure is added called nvdimm_pmu to be used for adding arch/platform specific data such as cpumask, nvdimm device pointer and pmu event functions like event_init/add/read/del. User could use the standard perf tool to access perf events exposed via pmu.

Interface also defines supported event list, config fields for the event attributes and their corresponding bit values which are exported via sysfs. Patch 3 exposes IBM pseries platform nmem* device performance stats using this interface.

Result from power9 pseries lpar with 2 nvdimm device:

Ex: List all event by perf list

command:# perf list nmem

  nmem0/cache_rh_cnt/                                [Kernel PMU event]
  nmem0/cache_wh_cnt/                                [Kernel PMU event]
  nmem0/cri_res_util/                                [Kernel PMU event]
  nmem0/ctl_res_cnt/                                 [Kernel PMU event]
  nmem0/ctl_res_tm/                                  [Kernel PMU event]
  nmem0/fast_w_cnt/                                  [Kernel PMU event]
  nmem0/host_l_cnt/                                  [Kernel PMU event]
  nmem0/host_l_dur/                                  [Kernel PMU event]
  nmem0/host_s_cnt/                                  [Kernel PMU event]
  nmem0/host_s_dur/                                  [Kernel PMU event]
  nmem0/med_r_cnt/                                   [Kernel PMU event]
  nmem0/med_r_dur/                                   [Kernel PMU event]
  nmem0/med_w_cnt/                                   [Kernel PMU event]
  nmem0/med_w_dur/                                   [Kernel PMU event]
  nmem0/mem_life/                                    [Kernel PMU event]
  nmem0/poweron_secs/                                [Kernel PMU event]

...
nmem1/mem_life/ [Kernel PMU event]
nmem1/poweron_secs/ [Kernel PMU event]

Patch1:
Introduces the nvdimm_pmu structure
Patch2:
Adds common interface to add arch/platform specific data includes nvdimm device pointer, pmu data along with pmu event functions. It also defines supported event list and adds attribute groups for format, events and cpumask. It also adds code for cpu hotplug support.
Patch3:
Add code in arch/powerpc/platform/pseries/papr_scm.c to expose nmem* pmu. It fills in the nvdimm_pmu structure with pmu name, capabilities, cpumask and event functions and then registers the pmu by adding callbacks to register_nvdimm_pmu.
Patch4:
Sysfs documentation patch

Changelog
---
Resend v5 -> v6
- No logic change, just a rebase to latest upstream and tested the patchset.

- Link to the patchset Resend v5: https://lkml.org/lkml/2021/11/15/3979

v5 -> Resend v5
- Resend the patchset

- Link to the patchset v5: https://lkml.org/lkml/2021/9/28/643

v4 -> v5:
- Remove multiple variables defined in nvdimm_pmu structure include name and pmu functions(event_int/add/del/read) as they are just used to copy them again in pmu variable. Now we are directly doing this step in arch specific code as suggested by Dan Williams.

- Remove attribute group field from nvdimm pmu structure and defined these attribute groups in common interface which includes format, event list along with cpumask as suggested by Dan Williams.
Since we added static defination for attrbute groups needed in common interface, removes corresponding code from papr.

Quoted 4 lines

- Add nvdimm pmu event list with event codes in the common interface.

- Remove Acked-by/Reviewed-by/Tested-by tags as code is refactored to handle review comments from Dan.

I don't think review comments should invalidate the Acked-by tags in this case. Nothing fundamentally changed in the approach, and I would like to have the perf ack before taking this through the nvdimm tree.

Quoted 6 lines
Quoted 4 lines

Otherwise this looks good to me.

Peter, might you have a chance to re-Ack this series, or any concerns about me retrieving those Acks from the previous postings?

Reached Peter offline and he refreshed his Acked-by.

There's still time for the tags from:

"Madhavan Srinivasan"
"Nageswara R Sastry"

...to be reapplied, but I'll go ahead with pushing this to Linux-next in the meantime.

author
#8 lore raw
Quoted 103 lines · Dan Williams
Quoted 95 lines · Dan Williams
Quoted 93 lines · Dan Williams
Quoted 82 lines · Kajol Jain

Patchset adds performance stats reporting support for nvdimm. Added interface includes support for pmu register/unregister functions. A structure is added called nvdimm_pmu to be used for adding arch/platform specific data such as cpumask, nvdimm device pointer and pmu event functions like event_init/add/read/del. User could use the standard perf tool to access perf events exposed via pmu.

Interface also defines supported event list, config fields for the event attributes and their corresponding bit values which are exported via sysfs. Patch 3 exposes IBM pseries platform nmem* device performance stats using this interface.

Result from power9 pseries lpar with 2 nvdimm device:

Ex: List all event by perf list

command:# perf list nmem

  nmem0/cache_rh_cnt/                                [Kernel PMU event]
  nmem0/cache_wh_cnt/                                [Kernel PMU event]
  nmem0/cri_res_util/                                [Kernel PMU event]
  nmem0/ctl_res_cnt/                                 [Kernel PMU event]
  nmem0/ctl_res_tm/                                  [Kernel PMU event]
  nmem0/fast_w_cnt/                                  [Kernel PMU event]
  nmem0/host_l_cnt/                                  [Kernel PMU event]
  nmem0/host_l_dur/                                  [Kernel PMU event]
  nmem0/host_s_cnt/                                  [Kernel PMU event]
  nmem0/host_s_dur/                                  [Kernel PMU event]
  nmem0/med_r_cnt/                                   [Kernel PMU event]
  nmem0/med_r_dur/                                   [Kernel PMU event]
  nmem0/med_w_cnt/                                   [Kernel PMU event]
  nmem0/med_w_dur/                                   [Kernel PMU event]
  nmem0/mem_life/                                    [Kernel PMU event]
  nmem0/poweron_secs/                                [Kernel PMU event]

...
nmem1/mem_life/ [Kernel PMU event]
nmem1/poweron_secs/ [Kernel PMU event]

Patch1:
Introduces the nvdimm_pmu structure
Patch2:
Adds common interface to add arch/platform specific data includes nvdimm device pointer, pmu data along with pmu event functions. It also defines supported event list and adds attribute groups for format, events and cpumask. It also adds code for cpu hotplug support.
Patch3:
Add code in arch/powerpc/platform/pseries/papr_scm.c to expose nmem* pmu. It fills in the nvdimm_pmu structure with pmu name, capabilities, cpumask and event functions and then registers the pmu by adding callbacks to register_nvdimm_pmu.
Patch4:
Sysfs documentation patch

Changelog
---
Resend v5 -> v6
- No logic change, just a rebase to latest upstream and tested the patchset.

- Link to the patchset Resend v5: https://lkml.org/lkml/2021/11/15/3979

v5 -> Resend v5
- Resend the patchset

- Link to the patchset v5: https://lkml.org/lkml/2021/9/28/643

v4 -> v5:
- Remove multiple variables defined in nvdimm_pmu structure include name and pmu functions(event_int/add/del/read) as they are just used to copy them again in pmu variable. Now we are directly doing this step in arch specific code as suggested by Dan Williams.

- Remove attribute group field from nvdimm pmu structure and defined these attribute groups in common interface which includes format, event list along with cpumask as suggested by Dan Williams.
Since we added static defination for attrbute groups needed in common interface, removes corresponding code from papr.

Quoted 4 lines

- Add nvdimm pmu event list with event codes in the common interface.

- Remove Acked-by/Reviewed-by/Tested-by tags as code is refactored to handle review comments from Dan.

I don't think review comments should invalidate the Acked-by tags in this case. Nothing fundamentally changed in the approach, and I would like to have the perf ack before taking this through the nvdimm tree.

Quoted 6 lines
Quoted 4 lines

Otherwise this looks good to me.

Peter, might you have a chance to re-Ack this series, or any concerns about me retrieving those Acks from the previous postings?

Reached Peter offline and he refreshed his Acked-by.

Quoted 7 lines

There's still time for the tags from:

"Madhavan Srinivasan"
"Nageswara R Sastry"

...to be reapplied, but I'll go ahead with pushing this to Linux-next in the meantime.

Hi Dan/Peter,
Thanks for reviewing and taking the patchset.

Thanks,
Kajol Jain

#9 lore raw
In reply to Kajol Jain
Quoted 55 lines · Kajol Jain

Patchset adds performance stats reporting support for nvdimm. Added interface includes support for pmu register/unregister functions. A structure is added called nvdimm_pmu to be used for adding arch/platform specific data such as cpumask, nvdimm device pointer and pmu event functions like event_init/add/read/del. User could use the standard perf tool to access perf events exposed via pmu.

Interface also defines supported event list, config fields for the event attributes and their corresponding bit values which are exported via sysfs. Patch 3 exposes IBM pseries platform nmem* device performance stats using this interface.

Result from power9 pseries lpar with 2 nvdimm device:

Ex: List all event by perf list

command:# perf list nmem

   nmem0/cache_rh_cnt/                                [Kernel PMU event]
   nmem0/cache_wh_cnt/                                [Kernel PMU event]
   nmem0/cri_res_util/                                [Kernel PMU event]
   nmem0/ctl_res_cnt/                                 [Kernel PMU event]
   nmem0/ctl_res_tm/                                  [Kernel PMU event]
   nmem0/fast_w_cnt/                                  [Kernel PMU event]
   nmem0/host_l_cnt/                                  [Kernel PMU event]
   nmem0/host_l_dur/                                  [Kernel PMU event]
   nmem0/host_s_cnt/                                  [Kernel PMU event]
   nmem0/host_s_dur/                                  [Kernel PMU event]
   nmem0/med_r_cnt/                                   [Kernel PMU event]
   nmem0/med_r_dur/                                   [Kernel PMU event]
   nmem0/med_w_cnt/                                   [Kernel PMU event]
   nmem0/med_w_dur/                                   [Kernel PMU event]
   nmem0/mem_life/                                    [Kernel PMU event]
   nmem0/poweron_secs/                                [Kernel PMU event]

...
nmem1/mem_life/ [Kernel PMU event]
nmem1/poweron_secs/ [Kernel PMU event]

Patch1:
Introduces the nvdimm_pmu structure
Patch2:
Adds common interface to add arch/platform specific data includes nvdimm device pointer, pmu data along with pmu event functions. It also defines supported event list and adds attribute groups for format, events and cpumask. It also adds code for cpu hotplug support.
Patch3:
Add code in arch/powerpc/platform/pseries/papr_scm.c to expose nmem* pmu. It fills in the nvdimm_pmu structure with pmu name, capabilities, cpumask and event functions and then registers the pmu by adding callbacks to register_nvdimm_pmu.
Patch4:
Sysfs documentation patch

Quoted 1 line

Changelog

Tested these patches with the automated tests at avocado-misc-tests/perf/perf_nmem.py URL:
https://github.com/avocado-framework-tests/avocado-misc-tests/blob/master/perf/perf_nmem.py

1. On the system where target id and online id were different then not seeing value in 'cpumask' and those tests failed.

Example:
Log from dmesg
...
papr_scm ibm,persistent-memory:ibm,pmemory@44100003: Region registered with target node 1 and online node 0
...

tests log:
(1/9) perf_nmem.py:perfNMEM.test_pmu_register_dmesg: PASS (1.13 s) (2/9) perf_nmem.py:perfNMEM.test_sysfs: PASS (1.10 s)
(3/9) perf_nmem.py:perfNMEM.test_pmu_count: PASS (1.07 s) (4/9) perf_nmem.py:perfNMEM.test_all_events: PASS (18.14 s) (5/9) perf_nmem.py:perfNMEM.test_all_group_events: PASS (2.18 s) (6/9) perf_nmem.py:perfNMEM.test_mixed_events: CANCEL: With single PMU
mixed events test is not possible. (1.10 s)
(7/9) perf_nmem.py:perfNMEM.test_pmu_cpumask: ERROR: invalid literal
for int() with base 10: '' (1.10 s)
(8/9) perf_nmem.py:perfNMEM.test_cpumask: ERROR: invalid literal for
int() with base 10: '' (1.10 s)
(9/9) perf_nmem.py:perfNMEM.test_cpumask_cpu_off: ERROR: invalid
literal for int() with base 10: '' (1.07 s)

2. On the system where target id and online id were same then seeing value in 'cpumask' and those tests pass.

tests log:
(1/9) perf_nmem.py:perfNMEM.test_pmu_register_dmesg: PASS (1.16 s) (2/9) perf_nmem.py:perfNMEM.test_sysfs: PASS (1.10 s)
(3/9) perf_nmem.py:perfNMEM.test_pmu_count: PASS (1.12 s) (4/9) perf_nmem.py:perfNMEM.test_all_events: PASS (18.10 s) (5/9) perf_nmem.py:perfNMEM.test_all_group_events: PASS (2.23 s) (6/9) perf_nmem.py:perfNMEM.test_mixed_events: CANCEL: With single PMU
mixed events test is not possible. (1.13 s)
(7/9) perf_nmem.py:perfNMEM.test_pmu_cpumask: PASS (1.08 s) (8/9) perf_nmem.py:perfNMEM.test_cpumask: PASS (1.09 s) (9/9) perf_nmem.py:perfNMEM.test_cpumask_cpu_off: PASS (1.62 s)

Quoted 77 lines

---
Resend v5 -> v6
- No logic change, just a rebase to latest upstream and tested the patchset.

- Link to the patchset Resend v5: https://lkml.org/lkml/2021/11/15/3979

v5 -> Resend v5
- Resend the patchset

- Link to the patchset v5: https://lkml.org/lkml/2021/9/28/643

v4 -> v5:
- Remove multiple variables defined in nvdimm_pmu structure include name and pmu functions(event_int/add/del/read) as they are just used to copy them again in pmu variable. Now we are directly doing this step in arch specific code as suggested by Dan Williams.

- Remove attribute group field from nvdimm pmu structure and defined these attribute groups in common interface which includes format, event list along with cpumask as suggested by Dan Williams.
Since we added static defination for attrbute groups needed in common interface, removes corresponding code from papr.

- Add nvdimm pmu event list with event codes in the common interface.

- Remove Acked-by/Reviewed-by/Tested-by tags as code is refactored to handle review comments from Dan.

- Make nvdimm_pmu_free_hotplug_memory function static as reported by kernel test robot, also add corresponding Reported-by tag.

- Link to the patchset v4: https://lkml.org/lkml/2021/9/3/45

v3 -> v4
- Rebase code on top of current papr_scm code without any logical changes.

- Added Acked-by tag from Peter Zijlstra and Reviewed by tag from Madhavan Srinivasan.

- Link to the patchset v3: https://lkml.org/lkml/2021/6/17/605

v2 -> v3
- Added Tested-by tag.

- Fix nvdimm mailing list in the ABI Documentation.

- Link to the patchset v2: https://lkml.org/lkml/2021/6/14/25

v1 -> v2
- Fix hotplug code by adding pmu migration call
incase current designated cpu got offline. As
pointed by Peter Zijlstra.

- Removed the retun -1 part from cpu hotplug offline function.

- Link to the patchset v1: https://lkml.org/lkml/2021/6/8/500

Kajol Jain (4):
drivers/nvdimm: Add nvdimm pmu structure
drivers/nvdimm: Add perf interface to expose nvdimm performance stats powerpc/papr_scm: Add perf interface support
docs: ABI: sysfs-bus-nvdimm: Document sysfs event format entries for
nvdimm pmu

  Documentation/ABI/testing/sysfs-bus-nvdimm |  35 +++
  arch/powerpc/include/asm/device.h          |   5 +
  arch/powerpc/platforms/pseries/papr_scm.c  | 225 ++++++++++++++
  drivers/nvdimm/Makefile                    |   1 +
  drivers/nvdimm/nd_perf.c                   | 328 +++++++++++++++++++++
  include/linux/nd.h                         |  41 +++
  6 files changed, 635 insertions(+)

create mode 100644 drivers/nvdimm/nd_perf.c

Signature · 2 lines
Thanks and Regards
R.Nageswara Sastry
author
#10 lore raw
Quoted 69 lines · Nageswara Sastry
Quoted 55 lines · Kajol Jain

Patchset adds performance stats reporting support for nvdimm. Added interface includes support for pmu register/unregister functions. A structure is added called nvdimm_pmu to be used for adding arch/platform specific data such as cpumask, nvdimm device pointer and pmu event functions like event_init/add/read/del. User could use the standard perf tool to access perf events exposed via pmu.

Interface also defines supported event list, config fields for the event attributes and their corresponding bit values which are exported via sysfs. Patch 3 exposes IBM pseries platform nmem* device performance stats using this interface.

Result from power9 pseries lpar with 2 nvdimm device:

Ex: List all event by perf list

command:# perf list nmem

   nmem0/cache_rh_cnt/                                [Kernel PMU event] nmem0/cache_wh_cnt/                                [Kernel PMU event] nmem0/cri_res_util/                                [Kernel PMU event] nmem0/ctl_res_cnt/                                 [Kernel PMU event] nmem0/ctl_res_tm/                                  [Kernel PMU event] nmem0/fast_w_cnt/                                  [Kernel PMU event] nmem0/host_l_cnt/                                  [Kernel PMU event] nmem0/host_l_dur/                                  [Kernel PMU event] nmem0/host_s_cnt/                                  [Kernel PMU event] nmem0/host_s_dur/                                  [Kernel PMU event] nmem0/med_r_cnt/                                   [Kernel PMU event] nmem0/med_r_dur/                                   [Kernel PMU event] nmem0/med_w_cnt/                                   [Kernel PMU event] nmem0/med_w_dur/                                   [Kernel PMU event] nmem0/mem_life/                                    [Kernel PMU event] nmem0/poweron_secs/                                [Kernel PMU event]
   ...
   nmem1/mem_life/                                    [Kernel PMU event] nmem1/poweron_secs/                                [Kernel PMU event]

Patch1:
         Introduces the nvdimm_pmu structure
Patch2:
         Adds common interface to add arch/platform specific data includes nvdimm device pointer, pmu data along with pmu event functions. It also defines supported event list and adds attribute groups for format, events and cpumask. It also adds code for cpu hotplug support.
Patch3:
         Add code in arch/powerpc/platform/pseries/papr_scm.c to expose nmem* pmu. It fills in the nvdimm_pmu structure with pmu name, capabilities, cpumask and event functions and then registers the pmu by adding callbacks to register_nvdimm_pmu. Patch4:
         Sysfs documentation patch

Quoted 1 line

Changelog

Tested these patches with the automated tests at
avocado-misc-tests/perf/perf_nmem.py
URL:
https://github.com/avocado-framework-tests/avocado-misc-tests/blob/master/perf/perf_nmem.py

1. On the system where target id and online id were different then not seeing value in 'cpumask' and those tests failed.

Quoted 6 lines

Example:
Log from dmesg
...
papr_scm ibm,persistent-memory:ibm,pmemory@44100003: Region registered with target node 1 and online node 0
...

Hi Nageswara Sastry,
Thanks for testing the patch set. Yes you right, incase target
node id and online node id is different, it can happen when target node is not online and hence can cause this issue, thanks for pointing it.

Function dev_to_node will return node id for a given nvdimm device which can be offline in some scenarios. We should use numa node id return by numa_map_to_online_node function in that scenario. This function incase given node is offline, it will lookup for next closest online node and return that nodeid.

Can you try with below change and see, if you are still getting this issue. Please let me know.

(quoted diff) +0 -0

b/arch/powerpc/platforms/pseries/papr_scm.c
index bdf2620db461..4dd513d7c029 100644

arch/powerpc/platforms/pseries/papr_scm.c +0 -0
@@ -536,7 +536,7 @@ static void papr_scm_pmu_register(struct

papr_scm_priv *p)

                                PERF_PMU_CAP_NO_EXCLUDE;

        /*updating the cpumask variable */
-       nodeid = dev_to_node(&p->pdev->dev);
+       nodeid = numa_map_to_online_node(dev_to_node(&p->pdev->dev));
        nd_pmu->arch_cpumask = *cpumask_of_node(nodeid);

Thanks,
Kajol Jain

Quoted 109 lines

tests log:
 (1/9) perf_nmem.py:perfNMEM.test_pmu_register_dmesg: PASS (1.13 s) (2/9) perf_nmem.py:perfNMEM.test_sysfs: PASS (1.10 s)
 (3/9) perf_nmem.py:perfNMEM.test_pmu_count: PASS (1.07 s) (4/9) perf_nmem.py:perfNMEM.test_all_events: PASS (18.14 s) (5/9) perf_nmem.py:perfNMEM.test_all_group_events: PASS (2.18 s) (6/9) perf_nmem.py:perfNMEM.test_mixed_events: CANCEL: With single PMU mixed events test is not possible. (1.10 s)
 (7/9) perf_nmem.py:perfNMEM.test_pmu_cpumask: ERROR: invalid literal for int() with base 10: '' (1.10 s)
 (8/9) perf_nmem.py:perfNMEM.test_cpumask: ERROR: invalid literal for int() with base 10: '' (1.10 s)
 (9/9) perf_nmem.py:perfNMEM.test_cpumask_cpu_off: ERROR: invalid literal for int() with base 10: '' (1.07 s)

2. On the system where target id and online id were same then seeing value in 'cpumask' and those tests pass.

tests log:
 (1/9) perf_nmem.py:perfNMEM.test_pmu_register_dmesg: PASS (1.16 s) (2/9) perf_nmem.py:perfNMEM.test_sysfs: PASS (1.10 s)
 (3/9) perf_nmem.py:perfNMEM.test_pmu_count: PASS (1.12 s) (4/9) perf_nmem.py:perfNMEM.test_all_events: PASS (18.10 s) (5/9) perf_nmem.py:perfNMEM.test_all_group_events: PASS (2.23 s) (6/9) perf_nmem.py:perfNMEM.test_mixed_events: CANCEL: With single PMU mixed events test is not possible. (1.13 s)
 (7/9) perf_nmem.py:perfNMEM.test_pmu_cpumask: PASS (1.08 s) (8/9) perf_nmem.py:perfNMEM.test_cpumask: PASS (1.09 s) (9/9) perf_nmem.py:perfNMEM.test_cpumask_cpu_off: PASS (1.62 s)

Quoted 77 lines

---
Resend v5 -> v6
- No logic change, just a rebase to latest upstream and tested the patchset.

- Link to the patchset Resend v5: https://lkml.org/lkml/2021/11/15/3979

v5 -> Resend v5
- Resend the patchset

- Link to the patchset v5: https://lkml.org/lkml/2021/9/28/643

v4 -> v5:
- Remove multiple variables defined in nvdimm_pmu structure include name and pmu functions(event_int/add/del/read) as they are just used to copy them again in pmu variable. Now we are directly doing this step in arch specific code as suggested by Dan Williams.

- Remove attribute group field from nvdimm pmu structure and defined these attribute groups in common interface which includes format, event list along with cpumask as suggested by Dan Williams.
   Since we added static defination for attrbute groups needed in common interface, removes corresponding code from papr.

- Add nvdimm pmu event list with event codes in the common interface.

- Remove Acked-by/Reviewed-by/Tested-by tags as code is refactored to handle review comments from Dan.

- Make nvdimm_pmu_free_hotplug_memory function static as reported by kernel test robot, also add corresponding Reported-by tag.

- Link to the patchset v4: https://lkml.org/lkml/2021/9/3/45

v3 -> v4
- Rebase code on top of current papr_scm code without any logical changes.

- Added Acked-by tag from Peter Zijlstra and Reviewed by tag from Madhavan Srinivasan.

- Link to the patchset v3: https://lkml.org/lkml/2021/6/17/605

v2 -> v3
- Added Tested-by tag.

- Fix nvdimm mailing list in the ABI Documentation.

- Link to the patchset v2: https://lkml.org/lkml/2021/6/14/25

v1 -> v2
- Fix hotplug code by adding pmu migration call
   incase current designated cpu got offline. As
   pointed by Peter Zijlstra.

- Removed the retun -1 part from cpu hotplug offline function.

- Link to the patchset v1: https://lkml.org/lkml/2021/6/8/500

Kajol Jain (4):
   drivers/nvdimm: Add nvdimm pmu structure
   drivers/nvdimm: Add perf interface to expose nvdimm performance stats powerpc/papr_scm: Add perf interface support
   docs: ABI: sysfs-bus-nvdimm: Document sysfs event format entries for nvdimm pmu

  Documentation/ABI/testing/sysfs-bus-nvdimm |  35 +++ arch/powerpc/include/asm/device.h          |   5 + arch/powerpc/platforms/pseries/papr_scm.c  | 225 ++++++++++++++ drivers/nvdimm/Makefile                    |   1 + drivers/nvdimm/nd_perf.c                   | 328 +++++++++++++++++++++ include/linux/nd.h                         |  41 +++

  6 files changed, 635 insertions(+)

  create mode 100644 drivers/nvdimm/nd_perf.c

#11 lore raw
Quoted 7 lines · kajoljain
Quoted 4 lines · Nageswara Sastry
Quoted 1 line · Kajol Jain

....

Quoted 55 lines
Quoted 13 lines
Quoted 2 lines

Changelog

Tested these patches with the automated tests at
avocado-misc-tests/perf/perf_nmem.py
URL:
https://github.com/avocado-framework-tests/avocado-misc-tests/blob/master/perf/perf_nmem.py

1. On the system where target id and online id were different then not
seeing value in 'cpumask' and those tests failed.

Quoted 7 lines

Example:
Log from dmesg
...
papr_scm ibm,persistent-memory:ibm,pmemory@44100003: Region registered
with target node 1 and online node 0
...

Hi Nageswara Sastry,
       Thanks for testing the patch set. Yes you right, incase target node id and online node id is different, it can happen when target node is not online and hence can cause this issue, thanks for pointing
it.

Function dev_to_node will return node id for a given nvdimm device which
can be offline in some scenarios. We should use numa node id return by
numa_map_to_online_node function in that scenario. This function incase
given node is offline, it will lookup for next closest online node and
return that nodeid.

Can you try with below change and see, if you are still getting this issue. Please let me know.

arch/powerpc/platforms/pseries/papr_scm.c +1 -1
index bdf2620db461..4dd513d7c029 100644
@@ -536,7 +536,7 @@ static void papr_scm_pmu_register(struct
 papr_scm_priv *p)
                                 PERF_PMU_CAP_NO_EXCLUDE;
 
         /*updating the cpumask variable */
-       nodeid = dev_to_node(&p->pdev->dev);
+       nodeid = numa_map_to_online_node(dev_to_node(&p->pdev->dev));
         nd_pmu->arch_cpumask = *cpumask_of_node(nodeid);
 
Quoted 1 line
Quoted 1 line

Can you use p->region->numa_node?

-aneesh

author
#12 lore raw
Quoted 59 lines · Aneesh Kumar K V
Quoted 7 lines · kajoljain
Quoted 4 lines · Nageswara Sastry
Quoted 1 line · Kajol Jain

....

Quoted 50 lines
Quoted 13 lines
Quoted 2 lines

Changelog

Tested these patches with the automated tests at
avocado-misc-tests/perf/perf_nmem.py
URL:
https://github.com/avocado-framework-tests/avocado-misc-tests/blob/master/perf/perf_nmem.py

1. On the system where target id and online id were different then not
seeing value in 'cpumask' and those tests failed.

Quoted 7 lines

Example:
Log from dmesg
...
papr_scm ibm,persistent-memory:ibm,pmemory@44100003: Region registered
with target node 1 and online node 0
...

Hi Nageswara Sastry,
       Thanks for testing the patch set. Yes you right, incase target node id and online node id is different, it can happen when target node is not online and hence can cause this issue, thanks for pointing
it.

Function dev_to_node will return node id for a given nvdimm device which
can be offline in some scenarios. We should use numa node id return by
numa_map_to_online_node function in that scenario. This function incase
given node is offline, it will lookup for next closest online node and
return that nodeid.

Can you try with below change and see, if you are still getting this issue. Please let me know.

arch/powerpc/platforms/pseries/papr_scm.c +0 -0
index bdf2620db461..4dd513d7c029 100644
@@ -536,7 +536,7 @@ static void papr_scm_pmu_register(struct
 papr_scm_priv *p)
                                 PERF_PMU_CAP_NO_EXCLUDE;
 
Quoted 8 lines
Quoted 6 lines
arch/powerpc/platforms/pseries/papr_scm.c +1 -1
         /*updating the cpumask variable */
-       nodeid = dev_to_node(&p->pdev->dev);
+       nodeid = numa_map_to_online_node(dev_to_node(&p->pdev->dev));
         nd_pmu->arch_cpumask = *cpumask_of_node(nodeid);
 
Quoted 1 line

Can you use p->region->numa_node?

Hi Aneesh,
Thanks for reviewing the changes. Actually we can't use numa_node
field of region structure directly inside papr_scm.c as we will get dereferencing issue

Result of build with this change:

arch/powerpc/platforms/pseries/papr_scm.c: In function 'papr_scm_pmu_register':
arch/powerpc/platforms/pseries/papr_scm.c:539:21: error: dereferencing pointer to incomplete type 'struct nd_region'

  nodeid = &p->region->numa_node;
                     ^~

make[3]: *** [scripts/Makefile.build:288:
arch/powerpc/platforms/pseries/papr_scm.o] Error 1 make[2]: *** [scripts/Makefile.build:550:
arch/powerpc/platforms/pseries] Erro

This is because, this structure is defined inside drivers/nvdimm/nd.h code which is not included in this file.

So, thats why I am using numa_map_to_online_node(dev_to_node(&p->pdev->dev)); directly.

Let me know if you are ok with initial change.

Thanks,
Kajol Jain

Quoted 4 lines

-aneesh

#13 lore raw
In reply to kajoljain
Quoted 108 lines · kajoljain
Quoted 69 lines · Nageswara Sastry
Quoted 55 lines · Kajol Jain

Patchset adds performance stats reporting support for nvdimm. Added interface includes support for pmu register/unregister functions. A structure is added called nvdimm_pmu to be used for adding arch/platform specific data such as cpumask, nvdimm device pointer and pmu event functions like event_init/add/read/del. User could use the standard perf tool to access perf events exposed via pmu.

Interface also defines supported event list, config fields for the event attributes and their corresponding bit values which are exported via sysfs. Patch 3 exposes IBM pseries platform nmem* device performance stats using this interface.

Result from power9 pseries lpar with 2 nvdimm device:

Ex: List all event by perf list

command:# perf list nmem

   nmem0/cache_rh_cnt/                                [Kernel PMU event] nmem0/cache_wh_cnt/                                [Kernel PMU event] nmem0/cri_res_util/                                [Kernel PMU event] nmem0/ctl_res_cnt/                                 [Kernel PMU event] nmem0/ctl_res_tm/                                  [Kernel PMU event] nmem0/fast_w_cnt/                                  [Kernel PMU event] nmem0/host_l_cnt/                                  [Kernel PMU event] nmem0/host_l_dur/                                  [Kernel PMU event] nmem0/host_s_cnt/                                  [Kernel PMU event] nmem0/host_s_dur/                                  [Kernel PMU event] nmem0/med_r_cnt/                                   [Kernel PMU event] nmem0/med_r_dur/                                   [Kernel PMU event] nmem0/med_w_cnt/                                   [Kernel PMU event] nmem0/med_w_dur/                                   [Kernel PMU event] nmem0/mem_life/                                    [Kernel PMU event] nmem0/poweron_secs/                                [Kernel PMU event]
   ...
   nmem1/mem_life/                                    [Kernel PMU event] nmem1/poweron_secs/                                [Kernel PMU event]

Patch1:
         Introduces the nvdimm_pmu structure
Patch2:
         Adds common interface to add arch/platform specific data includes nvdimm device pointer, pmu data along with pmu event functions. It also defines supported event list and adds attribute groups for format, events and cpumask. It also adds code for cpu hotplug support.
Patch3:
         Add code in arch/powerpc/platform/pseries/papr_scm.c to expose nmem* pmu. It fills in the nvdimm_pmu structure with pmu name, capabilities, cpumask and event functions and then registers the pmu by adding callbacks to register_nvdimm_pmu.
Patch4:
         Sysfs documentation patch

Quoted 1 line

Changelog

Tested these patches with the automated tests at
avocado-misc-tests/perf/perf_nmem.py
URL:
https://github.com/avocado-framework-tests/avocado-misc-tests/blob/master/perf/perf_nmem.py

1. On the system where target id and online id were different then not seeing value in 'cpumask' and those tests failed.

Quoted 6 lines

Example:
Log from dmesg
...
papr_scm ibm,persistent-memory:ibm,pmemory@44100003: Region registered with target node 1 and online node 0
...

Hi Nageswara Sastry,
Thanks for testing the patch set. Yes you right, incase target
node id and online node id is different, it can happen when target node is not online and hence can cause this issue, thanks for pointing it.

Function dev_to_node will return node id for a given nvdimm device which can be offline in some scenarios. We should use numa node id return by numa_map_to_online_node function in that scenario. This function incase given node is offline, it will lookup for next closest online node and return that nodeid.

Can you try with below change and see, if you are still getting this issue. Please let me know.

arch/powerpc/platforms/pseries/papr_scm.c +1 -1
index bdf2620db461..4dd513d7c029 100644
@@ -536,7 +536,7 @@ static void papr_scm_pmu_register(struct
 papr_scm_priv *p)
                                 PERF_PMU_CAP_NO_EXCLUDE;
 
         /*updating the cpumask variable */
-       nodeid = dev_to_node(&p->pdev->dev);
+       nodeid = numa_map_to_online_node(dev_to_node(&p->pdev->dev));
         nd_pmu->arch_cpumask = *cpumask_of_node(nodeid);
 
Quoted 3 lines

Thanks,
Kajol Jain

With the above patch all the tests are passing on the system where target id and online id were different. Here is the the result:

(1/9) perf_nmem.py:perfNMEM.test_pmu_register_dmesg: PASS (3.47 s)
(2/9) perf_nmem.py:perfNMEM.test_sysfs: PASS (1.15 s)
(3/9) perf_nmem.py:perfNMEM.test_pmu_count: PASS (1.08 s)
(4/9) perf_nmem.py:perfNMEM.test_all_events: PASS (18.15 s)
(5/9) perf_nmem.py:perfNMEM.test_all_group_events: PASS (2.22 s)
(6/9) perf_nmem.py:perfNMEM.test_mixed_events: CANCEL: With single PMU mixed events test is not possible. (1.18 s) (7/9) perf_nmem.py:perfNMEM.test_pmu_cpumask: PASS (1.12 s)
(8/9) perf_nmem.py:perfNMEM.test_cpumask: PASS (1.17 s)
(9/9) perf_nmem.py:perfNMEM.test_cpumask_cpu_off: PASS (1.81 s)

Signature · 2 lines
Thanks and Regards
R.Nageswara Sastry
author
#14 lore raw
Quoted 150 lines · Nageswara Sastry
Quoted 129 lines · kajoljain
Quoted 90 lines · Nageswara Sastry
Quoted 75 lines · Kajol Jain

Patchset adds performance stats reporting support for nvdimm. Added interface includes support for pmu register/unregister functions. A structure is added called nvdimm_pmu to be used for adding arch/platform specific data such as cpumask, nvdimm device pointer and pmu event functions like event_init/add/read/del. User could use the standard perf tool to access perf events exposed via pmu.

Interface also defines supported event list, config fields for the event attributes and their corresponding bit values which are exported via sysfs. Patch 3 exposes IBM pseries platform nmem* device performance stats using this interface.

Result from power9 pseries lpar with 2 nvdimm device:

Ex: List all event by perf list

command:# perf list nmem

    nmem0/cache_rh_cnt/                                [Kernel PMU event]
    nmem0/cache_wh_cnt/                                [Kernel PMU event]
    nmem0/cri_res_util/                                [Kernel PMU event]
    nmem0/ctl_res_cnt/                                 [Kernel PMU event]
    nmem0/ctl_res_tm/                                  [Kernel PMU event]
    nmem0/fast_w_cnt/                                  [Kernel PMU event]
    nmem0/host_l_cnt/                                  [Kernel PMU event]
    nmem0/host_l_dur/                                  [Kernel PMU event]
    nmem0/host_s_cnt/                                  [Kernel PMU event]
    nmem0/host_s_dur/                                  [Kernel PMU event]
    nmem0/med_r_cnt/                                   [Kernel PMU event]
    nmem0/med_r_dur/                                   [Kernel PMU event]
    nmem0/med_w_cnt/                                   [Kernel PMU event]
    nmem0/med_w_dur/                                   [Kernel PMU event]
    nmem0/mem_life/                                    [Kernel PMU event]
    nmem0/poweron_secs/                                [Kernel PMU event]
    ...
    nmem1/mem_life/                                    [Kernel PMU event]
    nmem1/poweron_secs/                                [Kernel PMU event]

Patch1:
          Introduces the nvdimm_pmu structure
Patch2:
          Adds common interface to add arch/platform specific data includes nvdimm device pointer, pmu data along with pmu event functions. It also defines supported event list and adds attribute groups for format, events and cpumask. It also adds code for cpu hotplug support. Patch3:
          Add code in arch/powerpc/platform/pseries/papr_scm.c to expose
          nmem* pmu. It fills in the nvdimm_pmu structure with pmu name,
          capabilities, cpumask and event functions and then registers the pmu by adding callbacks to register_nvdimm_pmu. Patch4:
          Sysfs documentation patch

Quoted 1 line

Changelog

Tested these patches with the automated tests at
avocado-misc-tests/perf/perf_nmem.py
URL:
https://github.com/avocado-framework-tests/avocado-misc-tests/blob/master/perf/perf_nmem.py

1. On the system where target id and online id were different then not seeing value in 'cpumask' and those tests failed.

Quoted 6 lines

Example:
Log from dmesg
...
papr_scm ibm,persistent-memory:ibm,pmemory@44100003: Region registered with target node 1 and online node 0
...

Hi Nageswara Sastry,
        Thanks for testing the patch set. Yes you right, incase target node id and online node id is different, it can happen when target node is not online and hence can cause this issue, thanks for pointing it.

Function dev_to_node will return node id for a given nvdimm device which can be offline in some scenarios. We should use numa node id return by numa_map_to_online_node function in that scenario. This function incase given node is offline, it will lookup for next closest online node and return that nodeid.

Can you try with below change and see, if you are still getting this issue. Please let me know.

arch/powerpc/platforms/pseries/papr_scm.c +1 -1
index bdf2620db461..4dd513d7c029 100644
@@ -536,7 +536,7 @@ static void papr_scm_pmu_register(struct
 papr_scm_priv *p)
                                  PERF_PMU_CAP_NO_EXCLUDE;
 
          /*updating the cpumask variable */
-       nodeid = dev_to_node(&p->pdev->dev);
+       nodeid = numa_map_to_online_node(dev_to_node(&p->pdev->dev));
          nd_pmu->arch_cpumask = *cpumask_of_node(nodeid);
 
Quoted 3 lines

Thanks,
Kajol Jain

With the above patch all the tests are passing on the system where target id and online id were different. Here is the the result:

(1/9) perf_nmem.py:perfNMEM.test_pmu_register_dmesg: PASS (3.47 s) (2/9) perf_nmem.py:perfNMEM.test_sysfs: PASS (1.15 s)
(3/9) perf_nmem.py:perfNMEM.test_pmu_count: PASS (1.08 s) (4/9) perf_nmem.py:perfNMEM.test_all_events: PASS (18.15 s) (5/9) perf_nmem.py:perfNMEM.test_all_group_events: PASS (2.22 s) (6/9) perf_nmem.py:perfNMEM.test_mixed_events: CANCEL: With single PMU mixed events test is not possible. (1.18 s)
(7/9) perf_nmem.py:perfNMEM.test_pmu_cpumask: PASS (1.12 s) (8/9) perf_nmem.py:perfNMEM.test_cpumask: PASS (1.17 s) (9/9) perf_nmem.py:perfNMEM.test_cpumask_cpu_off: PASS (1.81 s)

Quoted 1 line

Hi Nageswara,
Thanks for testing this change. I will send new patch series v7 with
this change and also include your Tested-by tag.

Thanks,
Kajol Jain

Quoted 1 line