Add perf interface to expose nvdimm
Subsystems (2)
PATCH RESEND v5 2/4 drivers/nvdimm: Add perf interface to expose nvdimm performance stats
In reply to Kajol JainA 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.
--- 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
@@ -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
@@ -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.26.2
PATCH RESEND v5 3/4 powerpc/papr_scm: Add perf interface support
In reply to Kajol JainPerformance 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]
--- 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
@@ -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.26.2
v5 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
---
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.26.2
PATCH RESEND v5 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.
--- include/linux/nd.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
include/linux/nd.h +20 -0
@@ -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.26.2
PATCH RESEND v5 4/4 docs: ABI: sysfs-bus-nvdimm: Document sysfs event format entries for nvdimm pmu
In reply to Kajol JainDetails are added for the event, cpumask and format attributes in the ABI documentation.
--- Documentation/ABI/testing/sysfs-bus-nvdimm | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+)
Documentation/ABI/testing/sysfs-bus-nvdimm +35 -0
@@ -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: September 2021 +KernelVersion: 5.16 +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: September 2021 +KernelVersion: 5.16 +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: September 2021 +KernelVersion: 5.16 +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.26.2
Hi
Le 16/11/2021 à 05:49, Kajol Jain a écrit :
Quoted 8 lines
Patchset adds performance stats reporting support for nvdimm. Added interface includes support for pmu register/unregister functions. A structure is added called
nvdimm_pmuto be used for addingarch/platformspecific 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.
Quoted 4 lines
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.
You resending your v5 series ? Is there any news since your submittion last month that's awaiting in patchwork here at
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=264422 ?
Christophe
Quoted 110 lines
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 thenvdimm_pmustructure
Patch2:
Adds common interface to addarch/platformspecific 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 inarch/powerpc/platform/pseries/papr_scm.cto expose nmem* pmu. It fills in thenvdimm_pmustructure with pmu name, capabilities, cpumask and event functions and then registers the pmu by adding callbacks toregister_nvdimm_pmu.
Patch4:
Sysfs documentation patchChangelog
---
v4 -> v5:
- Remove multiple variables defined innvdimm_pmustructure include name and pmufunctions(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_memoryfunction 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 currentpapr_scmcode 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 pmuDocumentation/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
Quoted 11 lines · LEROY Christophe
Hi
Le 16/11/2021 à 05:49, Kajol Jain a écrit :
Quoted 8 lines
Patchset adds performance stats reporting support for nvdimm. Added interface includes support for pmu register/unregister functions. A structure is added called
nvdimm_pmuto be used for addingarch/platformspecific 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.
Quoted 8 lines
Quoted 4 lines
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.
You resending your v5 series ? Is there any news since your submittion last month that's awaiting in patchwork here at
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=264422 ?
Hi Christophe,
There is no code side changes from the last v5 version. Since, I
am looking for reviews, again posted this patchset with RESEND tag.
Thanks,
Kajol Jain
Quoted 113 lines
Christophe
Quoted 109 lines
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 thenvdimm_pmustructure
Patch2:
Adds common interface to addarch/platformspecific 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 inarch/powerpc/platform/pseries/papr_scm.cto expose nmem* pmu. It fills in thenvdimm_pmustructure with pmu name, capabilities, cpumask and event functions and then registers the pmu by adding callbacks toregister_nvdimm_pmu.
Patch4:
Sysfs documentation patchChangelog
---
v4 -> v5:
- Remove multiple variables defined innvdimm_pmustructure include name and pmufunctions(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_memoryfunction 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 currentpapr_scmcode 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 pmuDocumentation/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