Add perf interface to expose nvdimm
Subsystems (2)
v4 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 supported events, cpumask pmu event functions like event_init/add/read/del.
User could use the standard perf tool to access perf events exposed via pmu.
Added implementation to expose IBM pseries platform nmem* device performance stats using this interface.
Result from power9 pseries lpar with 2 nvdimm device:
command:# perf list nmem
nmem0/cchrhcnt/ [Kernel PMU event] nmem0/cchwhcnt/ [Kernel PMU event] nmem0/critrscu/ [Kernel PMU event] nmem0/ctlresct/ [Kernel PMU event] nmem0/ctlrestm/ [Kernel PMU event] nmem0/fastwcnt/ [Kernel PMU event] nmem0/hostlcnt/ [Kernel PMU event] nmem0/hostldur/ [Kernel PMU event] nmem0/hostscnt/ [Kernel PMU event] nmem0/hostsdur/ [Kernel PMU event] nmem0/medrcnt/ [Kernel PMU event] nmem0/medrdur/ [Kernel PMU event] nmem0/medwcnt/ [Kernel PMU event] nmem0/medwdur/ [Kernel PMU event] nmem0/memlife/ [Kernel PMU event] nmem0/noopstat/ [Kernel PMU event] nmem0/ponsecs/ [Kernel PMU event] nmem1/cchrhcnt/ [Kernel PMU event] nmem1/cchwhcnt/ [Kernel PMU event] nmem1/critrscu/ [Kernel PMU event]
...
nmem1/noopstat/ [Kernel PMU event]
nmem1/ponsecs/ [Kernel PMU event]
Patch1:
Introduces the nvdimm_pmu structure
Patch2:
Adds common interface to add arch/platform specific data includes supported events, pmu event functions. 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 event attrs cpumask andevent functions and then registers the pmu by adding callbacks to register_nvdimm_pmu.
Patch4:
Sysfs documentation patch
Changelog
---
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 powerpc/papr_scm: Document papr_scm sysfs event format entries
Documentation/ABI/testing/sysfs-bus-papr-pmem | 31 ++ arch/powerpc/include/asm/device.h | 5 + arch/powerpc/platforms/pseries/papr_scm.c | 365 ++++++++++++++++++ drivers/nvdimm/Makefile | 1 + drivers/nvdimm/nd_perf.c | 230 +++++++++++ include/linux/nd.h | 46 +++ 6 files changed, 678 insertions(+) create mode 100644 drivers/nvdimm/nd_perf.c
Signature · 1 line
2.26.2
PATCH RESEND v4 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 nvdimm pmu data such as supported events and pmu event functions like event_init/add/read/del with cpu hotplug support.
--- include/linux/nd.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
include/linux/nd.h +43 -0
@@ -8,6 +8,8 @@#include <linux/ndctl.h> #include <linux/device.h> #include <linux/badblocks.h> +#include <linux/platform_device.h> +#include <linux/perf_event.h> enum nvdimm_event {NVDIMM_REVALIDATE_POISON ,
@@ -23,6 +25,47 @@ enum nvdimm_claim_class { NVDIMM_CCLASS_UNKNOWN, }; +/* 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 +* +* @name: name of the nvdimm pmu device. +* @pmu: pmu data structure for nvdimm performance stats. +* @dev: nvdimm device pointer. +* @functions(event_init/add/del/read): platform specific pmu functions. +* @attr_groups: data structure for events, formats and cpumask +* @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 { +const char *name; +struct pmu pmu; +struct device *dev; +int (*event_init)(struct perf_event *event); +int (*add)(struct perf_event *event,int flags); +void (*del)(struct perf_event *event,int flags); +void (*read)(struct perf_event *event); +/* +* Attribute groups for the nvdimm pmu. Index 0 used for +* format attribute, index 1 used for event attribute, +* index 2 used for cpusmask attribute and index 3 kept as NULL. +*/ +const struct attribute_group *attr_groups[4 ]; +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
Re: [RESEND PATCH v4 1/4] drivers/nvdimm: Add nvdimm pmu structure
Hi Kajol,
Apologies for the delay in responding to this series, some comments below:
Quoted 34 lines · Kajol Jain
A structure is added, called
nvdimm_pmu, for performance stats reporting support of nvdimm devices. It can be used to add nvdimm pmu data such as supported events and pmu event functions like event_init/add/read/del with cpu hotplug support.Reviewed-by Madhavan Srinivasan <[email protected]>Tested-by Nageswara R Sastry <[email protected]>Signed-off-by Kajol Jain <[email protected]>--- include/linux/nd.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)include/linux/nd.h +5
-0@@ -8,6 +8,8 @@#include <linux/ndctl.h> #include <linux/device.h> #include <linux/badblocks.h> +#include <linux/platform_device.h> +#include <linux/perf_event.h> enum nvdimm_event {NVDIMM_REVALIDATE_POISON ,@@ -23,6 +25,47 @@ enum nvdimm_claim_class { NVDIMM_CCLASS_UNKNOWN, }; +/* Event attribute array index */ +#define NVDIMM_PMU_FORMAT_ATTR 0 +#define NVDIMM_PMU_EVENT_ATTR 1
include/linux/nd.h enum nvdimm_claim_class { · line 40
Quoted 10 lines
include/linux/nd.h +10
-0+#define NVDIMM_PMU_CPUMASK_ATTR 2 +#define NVDIMM_PMU_NULL_ATTR 3 + +/** +* struct nvdimm_pmu - data structure for nvdimm perf driver +* +* @name: name of the nvdimm pmu device. +* @pmu: pmu data structure for nvdimm performance stats. +* @dev: nvdimm device pointer. +* @functions(event_init/add/del/read): platform specific pmu functions.
This is not valid kernel-doc:
include/linux/nd.h:67: warning: Function parameter or member 'event_init' not described in 'nvdimm_pmu' include/linux/nd.h:67: warning: Function parameter or member 'add' not described in 'nvdimm_pmu'include/linux/nd.h:67: warning: Function parameter or member 'del' not described in 'nvdimm_pmu'include/linux/nd.h:67: warning: Function parameter or member 'read' not described in 'nvdimm_pmu'
...but I think rather than fixing those up 'struct nvdimm_pmu' should be pruned.
It's not clear to me that it is worth the effort to describe these details to the nvdimm core which is just going to turn around and call the pmu core. I'd just as soon have the driver call the pmu core directly, optionally passing in attributes and callbacks that come from the nvdimm core and/or the nvdimm provider.
Otherwise it's also not clear which of these structure members are used at runtime vs purely used as temporary storage to pass parameters to the pmu core.
Quoted 10 lines
include/linux/nd.h +10
-0+* @attr_groups: data structure for events, formats and cpumask +* @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 { +const char *name; +struct pmu pmu; +struct device *dev;
include/linux/nd.h enum nvdimm_claim_class { · line 60
Quoted 10 lines
include/linux/nd.h +10
-0+int (*event_init)(struct perf_event *event); +int (*add)(struct perf_event *event,int flags); +void (*del)(struct perf_event *event,int flags); +void (*read)(struct perf_event *event); +/* +* Attribute groups for the nvdimm pmu. Index 0 used for +* format attribute, index 1 used for event attribute, +* index 2 used for cpusmask attribute and index 3 kept as NULL. +*/ +const struct attribute_group *attr_groups[4 ];
Following from above, I'd rather this was organized as static attributes with an is_visible() helper for the groups for any dynamic aspects. That mirrors the behavior of nvdimm_create() and allows for device drivers to compose the attribute groups from a core set and / or a provider specific set.
Quoted 14 lines
include/linux/nd.h +8
-1+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; --2.26.2
Re: [RESEND PATCH v4 1/4] drivers/nvdimm: Add nvdimm pmu structure
Quoted 3 lines · Dan Williams
Hi Kajol,
Apologies for the delay in responding to this series, some comments below:
Hi Dan,
No issues, thanks for reviewing the patches.
Quoted 58 lines · Kajol Jain
Quoted 34 lines
A structure is added, called
nvdimm_pmu, for performance stats reporting support of nvdimm devices. It can be used to add nvdimm pmu data such as supported events and pmu event functions like event_init/add/read/del with cpu hotplug support.Reviewed-by Madhavan Srinivasan <[email protected]>Tested-by Nageswara R Sastry <[email protected]>Signed-off-by Kajol Jain <[email protected]>--- include/linux/nd.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)include/linux/nd.h +5
-0@@ -8,6 +8,8 @@#include <linux/ndctl.h> #include <linux/device.h> #include <linux/badblocks.h> +#include <linux/platform_device.h> +#include <linux/perf_event.h> enum nvdimm_event {NVDIMM_REVALIDATE_POISON ,@@ -23,6 +25,47 @@ enum nvdimm_claim_class { NVDIMM_CCLASS_UNKNOWN, }; +/* Event attribute array index */ +#define NVDIMM_PMU_FORMAT_ATTR 0 +#define NVDIMM_PMU_EVENT_ATTR 1include/linux/nd.h enum nvdimm_claim_class { · line 40
Quoted 10 lines
include/linux/nd.h +10
-0+#define NVDIMM_PMU_CPUMASK_ATTR 2 +#define NVDIMM_PMU_NULL_ATTR 3 + +/** +* struct nvdimm_pmu - data structure for nvdimm perf driver +* +* @name: name of the nvdimm pmu device. +* @pmu: pmu data structure for nvdimm performance stats. +* @dev: nvdimm device pointer. +* @functions(event_init/add/del/read): platform specific pmu functions. This is not valid kernel-doc:
include/linux/nd.h:67: warning: Function parameter or member 'event_init' not described in 'nvdimm_pmu'include/linux/nd.h:67: warning: Function parameter or member 'add' not described in 'nvdimm_pmu'include/linux/nd.h:67: warning: Function parameter or member 'del' not described in 'nvdimm_pmu'include/linux/nd.h:67: warning: Function parameter or member 'read' not described in 'nvdimm_pmu'
Quoted 7 lines
...but I think rather than fixing those up 'struct
nvdimm_pmu' should be pruned.It's not clear to me that it is worth the effort to describe these details to the nvdimm core which is just going to turn around and call the pmu core. I'd just as soon have the driver call the pmu core directly, optionally passing in attributes and callbacks that come from the nvdimm core and/or the nvdimm provider.
The intend for adding these callbacks(event_init/add/del/read) is to give flexibility to the nvdimm core to add some common checks/routines if required in the future. Those checks can be common for all architecture with still having the ability to call arch/platform specific driver code to use its own routines.
But as you said, currently we don't have any common checks and it directly calling platform specific code, so we can get rid of it. Should we remove this part for now?
Quoted 26 lines
Otherwise it's also not clear which of these structure members are used at runtime vs purely used as temporary storage to pass parameters to the pmu core.
Quoted 10 lines
include/linux/nd.h +10
-0+* @attr_groups: data structure for events, formats and cpumask +* @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 { +const char *name; +struct pmu pmu; +struct device *dev;include/linux/nd.h enum nvdimm_claim_class { · line 60
Quoted 10 lines
include/linux/nd.h +10
-0+int (*event_init)(struct perf_event *event); +int (*add)(struct perf_event *event,int flags); +void (*del)(struct perf_event *event,int flags); +void (*read)(struct perf_event *event); +/* +* Attribute groups for the nvdimm pmu. Index 0 used for +* format attribute, index 1 used for event attribute, +* index 2 used for cpusmask attribute and index 3 kept as NULL. +*/ +const struct attribute_group *attr_groups[4 ];
Quoted 5 lines
Following from above, I'd rather this was organized as static attributes with an
is_visible()helper for the groups for any dynamic aspects. That mirrors the behavior ofnvdimm_create()and allows for device drivers to compose the attribute groups from a core set and / or a provider specific set.
Since we don't have any common events right now, Can I use papr attributes directly or should we create dummy events for common thing and then merged it with papr event list.
Thanks,
Kajol Jain
Quoted 15 lines
Quoted 15 lines
include/linux/nd.h +8
-1+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; --2.26.2
Re: [RESEND PATCH v4 1/4] drivers/nvdimm: Add nvdimm pmu structure
Quoted 77 lines · kajoljain
Quoted 3 lines · Dan Williams
Hi Kajol,
Apologies for the delay in responding to this series, some comments below:
Hi Dan,
No issues, thanks for reviewing the patches.Quoted 58 lines · Kajol Jain
Quoted 34 lines
A structure is added, called
nvdimm_pmu, for performance stats reporting support of nvdimm devices. It can be used to add nvdimm pmu data such as supported events and pmu event functions like event_init/add/read/del with cpu hotplug support.Reviewed-by Madhavan Srinivasan <[email protected]>Tested-by Nageswara R Sastry <[email protected]>Signed-off-by Kajol Jain <[email protected]>--- include/linux/nd.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)include/linux/nd.h +5
-0@@ -8,6 +8,8 @@#include <linux/ndctl.h> #include <linux/device.h> #include <linux/badblocks.h> +#include <linux/platform_device.h> +#include <linux/perf_event.h> enum nvdimm_event {NVDIMM_REVALIDATE_POISON ,@@ -23,6 +25,47 @@ enum nvdimm_claim_class { NVDIMM_CCLASS_UNKNOWN, }; +/* Event attribute array index */ +#define NVDIMM_PMU_FORMAT_ATTR 0 +#define NVDIMM_PMU_EVENT_ATTR 1include/linux/nd.h enum nvdimm_claim_class { · line 40
Quoted 10 lines
include/linux/nd.h +10
-0+#define NVDIMM_PMU_CPUMASK_ATTR 2 +#define NVDIMM_PMU_NULL_ATTR 3 + +/** +* struct nvdimm_pmu - data structure for nvdimm perf driver +* +* @name: name of the nvdimm pmu device. +* @pmu: pmu data structure for nvdimm performance stats. +* @dev: nvdimm device pointer. +* @functions(event_init/add/del/read): platform specific pmu functions. This is not valid kernel-doc:
include/linux/nd.h:67: warning: Function parameter or member 'event_init' not described in 'nvdimm_pmu'include/linux/nd.h:67: warning: Function parameter or member 'add' not described in 'nvdimm_pmu'include/linux/nd.h:67: warning: Function parameter or member 'del' not described in 'nvdimm_pmu'include/linux/nd.h:67: warning: Function parameter or member 'read' not described in 'nvdimm_pmu'Quoted 7 lines
...but I think rather than fixing those up 'struct
nvdimm_pmu' should be pruned.It's not clear to me that it is worth the effort to describe these details to the nvdimm core which is just going to turn around and call the pmu core. I'd just as soon have the driver call the pmu core directly, optionally passing in attributes and callbacks that come from the nvdimm core and/or the nvdimm provider.
Quoted 8 lines
The intend for adding these
callbacks(event_init/add/del/read)is to give flexibility to the nvdimm core to add some common checks/routines if required in the future. Those checks can be common for all architecture with still having the ability to callarch/platformspecific driver code to use its own routines.But as you said, currently we don't have any common checks and it directly calling platform specific code, so we can get rid of it. Should we remove this part for now?
Yes, lets go direct to the perf api for now and await the need for a common core wrapper to present itself.
Quoted 34 lines
Quoted 28 lines
Otherwise it's also not clear which of these structure members are used at runtime vs purely used as temporary storage to pass parameters to the pmu core.
Quoted 10 lines
include/linux/nd.h +10
-0+* @attr_groups: data structure for events, formats and cpumask +* @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 { +const char *name; +struct pmu pmu; +struct device *dev;include/linux/nd.h enum nvdimm_claim_class { · line 60
Quoted 10 lines
include/linux/nd.h +10
-0+int (*event_init)(struct perf_event *event); +int (*add)(struct perf_event *event,int flags); +void (*del)(struct perf_event *event,int flags); +void (*read)(struct perf_event *event); +/* +* Attribute groups for the nvdimm pmu. Index 0 used for +* format attribute, index 1 used for event attribute, +* index 2 used for cpusmask attribute and index 3 kept as NULL. +*/ +const struct attribute_group *attr_groups[4 ];Quoted 5 lines
Following from above, I'd rather this was organized as static attributes with an
is_visible()helper for the groups for any dynamic aspects. That mirrors the behavior ofnvdimm_create()and allows for device drivers to compose the attribute groups from a core set and / or a provider specific set.
Quoted 3 lines
Since we don't have any common events right now, Can I use papr attributes directly or should we create dummy events for common thing and then merged it with papr event list.
Just use papr events directly.
Re: [RESEND PATCH v4 1/4] drivers/nvdimm: Add nvdimm pmu structure
Quoted 125 lines · Dan Williams
Quoted 77 lines · kajoljain
Quoted 3 lines · Dan Williams
Hi Kajol,
Apologies for the delay in responding to this series, some comments below:
Hi Dan,
No issues, thanks for reviewing the patches.Quoted 58 lines · Kajol Jain
Quoted 34 lines
A structure is added, called
nvdimm_pmu, for performance stats reporting support of nvdimm devices. It can be used to add nvdimm pmu data such as supported events and pmu event functions like event_init/add/read/del with cpu hotplug support.Reviewed-by Madhavan Srinivasan <[email protected]>Tested-by Nageswara R Sastry <[email protected]>Signed-off-by Kajol Jain <[email protected]>--- include/linux/nd.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)include/linux/nd.h +5
-0@@ -8,6 +8,8 @@#include <linux/ndctl.h> #include <linux/device.h> #include <linux/badblocks.h> +#include <linux/platform_device.h> +#include <linux/perf_event.h> enum nvdimm_event {NVDIMM_REVALIDATE_POISON ,@@ -23,6 +25,47 @@ enum nvdimm_claim_class { NVDIMM_CCLASS_UNKNOWN, }; +/* Event attribute array index */ +#define NVDIMM_PMU_FORMAT_ATTR 0 +#define NVDIMM_PMU_EVENT_ATTR 1include/linux/nd.h enum nvdimm_claim_class { · line 40
Quoted 10 lines
include/linux/nd.h +10
-0+#define NVDIMM_PMU_CPUMASK_ATTR 2 +#define NVDIMM_PMU_NULL_ATTR 3 + +/** +* struct nvdimm_pmu - data structure for nvdimm perf driver +* +* @name: name of the nvdimm pmu device. +* @pmu: pmu data structure for nvdimm performance stats. +* @dev: nvdimm device pointer. +* @functions(event_init/add/del/read): platform specific pmu functions. This is not valid kernel-doc:
include/linux/nd.h:67: warning: Function parameter or member 'event_init' not described in 'nvdimm_pmu'include/linux/nd.h:67: warning: Function parameter or member 'add' not described in 'nvdimm_pmu'include/linux/nd.h:67: warning: Function parameter or member 'del' not described in 'nvdimm_pmu'include/linux/nd.h:67: warning: Function parameter or member 'read' not described in 'nvdimm_pmu'Quoted 7 lines
...but I think rather than fixing those up 'struct
nvdimm_pmu' should be pruned.It's not clear to me that it is worth the effort to describe these details to the nvdimm core which is just going to turn around and call the pmu core. I'd just as soon have the driver call the pmu core directly, optionally passing in attributes and callbacks that come from the nvdimm core and/or the nvdimm provider.
Quoted 8 lines
The intend for adding these
callbacks(event_init/add/del/read)is to give flexibility to the nvdimm core to add some common checks/routines if required in the future. Those checks can be common for all architecture with still having the ability to callarch/platformspecific driver code to use its own routines.But as you said, currently we don't have any common checks and it directly calling platform specific code, so we can get rid of it. Should we remove this part for now?
Yes, lets go direct to the perf api for now and await the need for a common core wrapper to present itself.
Quoted 34 lines
Quoted 33 lines
Otherwise it's also not clear which of these structure members are used at runtime vs purely used as temporary storage to pass parameters to the pmu core.
Quoted 10 lines
include/linux/nd.h +10
-0+* @attr_groups: data structure for events, formats and cpumask +* @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 { +const char *name; +struct pmu pmu; +struct device *dev;include/linux/nd.h enum nvdimm_claim_class { · line 60
Quoted 10 lines
include/linux/nd.h +10
-0+int (*event_init)(struct perf_event *event); +int (*add)(struct perf_event *event,int flags); +void (*del)(struct perf_event *event,int flags); +void (*read)(struct perf_event *event); +/* +* Attribute groups for the nvdimm pmu. Index 0 used for +* format attribute, index 1 used for event attribute, +* index 2 used for cpusmask attribute and index 3 kept as NULL. +*/ +const struct attribute_group *attr_groups[4 ];Following from above, I'd rather this was organized as static attributes with an
is_visible()helper for the groups for any dynamic aspects. That mirrors the behavior ofnvdimm_create()and allows for device drivers to compose the attribute groups from a core set and / or a provider specific set.
Quoted 5 lines
Quoted 3 lines
Since we don't have any common events right now, Can I use papr attributes directly or should we create dummy events for common thing and then merged it with papr event list.
Just use papr events directly.
That is to say...I think if another implementation followed it should try to match as many common event names as papr_scm picked, and possibly extend with its own rather than start with a papr_scm specific namespace for everything.
PATCH RESEND v4 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 includes support for pmu register/unregister functions, cpu hotplug and pmu event functions like event_init/add/read/del.
User could use the standard perf tool to access perf events exposed via pmu.
--- drivers/nvdimm/Makefile | 1 + drivers/nvdimm/nd_perf.c | 230 +++++++++++++++++++++++++++++++++++++++ include/linux/nd.h | 3 + 3 files changed, 234 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 +230 -0
230 lines not on this page · raw message
include/linux/nd.h +3 -0
@@ -66,6 +66,9 @@ struct nvdimm_pmu {struct cpumask arch_cpumask; }; +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
kernel test robot
build botRe: [RESEND PATCH v4 2/4] drivers/nvdimm: Add perf interface to expose nvdimm performance stats
Thank you for the patch! Perhaps something to improve:
Hi Kajol,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linux-nvdimm/libnvdimm-for-next] [also build test WARNING on powerpc/next linus/master v5.14 next-20210903] [cannot apply to mpe/next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Kajol-Jain/Add-perf-interface-to-expose-nvdimm/20210903-131212 base: https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git libnvdimm-for-next config: x86_64-randconfig-a005-20210903 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 1104e3258b5064e7110cc297e2cec60ac9acfc0a)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/f841601cc058e6033761bd2157b886a30190fc3a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Kajol-Jain/Add-perf-interface-to-expose-nvdimm/20210903-131212 git checkout f841601cc058e6033761bd2157b886a30190fc3a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/nvdimm/nd_perf.c:159:6: warning: no previous prototype for function 'nvdimm_pmu_free_hotplug_memory' [-Wmissing-prototypes]
void nvdimm_pmu_free_hotplug_memory(struct nvdimm_pmu *nd_pmu)
^ drivers/nvdimm/nd_perf.c:159:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void nvdimm_pmu_free_hotplug_memory(struct nvdimm_pmu *nd_pmu)
^
static
1 warning generated.
vim +/nvdimm_pmu_free_hotplug_memory +159 drivers/nvdimm/nd_perf.c
158
> 159 void nvdimm_pmu_free_hotplug_memory(struct nvdimm_pmu *nd_pmu)
160 {
161 cpuhp_state_remove_instance_nocalls(nd_pmu->cpuhp_state, &nd_pmu->node);
162 cpuhp_remove_multi_state(nd_pmu->cpuhp_state);
163
164 if (nd_pmu->attr_groups[NVDIMM_PMU_CPUMASK_ATTR])
165 kfree(nd_pmu->attr_groups[NVDIMM_PMU_CPUMASK_ATTR]->attrs);
166 kfree(nd_pmu->attr_groups[NVDIMM_PMU_CPUMASK_ATTR]);
167 }
168
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [RESEND PATCH v4 2/4] drivers/nvdimm: Add perf interface to expose nvdimm performance stats
In reply to Kajol JainThank you for the patch! Perhaps something to improve:
Hi Kajol,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linux-nvdimm/libnvdimm-for-next] [also build test WARNING on powerpc/next linus/master v5.14 next-20210903] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Kajol-Jain/Add-perf-interface-to-expose-nvdimm/20210903-131212 base: https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git libnvdimm-for-next config: x86_64-randconfig-s021-20210903 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.4-rc1-dirty # https://github.com/0day-ci/linux/commit/f841601cc058e6033761bd2157b886a30190fc3a git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Kajol-Jain/Add-perf-interface-to-expose-nvdimm/20210903-131212 git checkout f841601cc058e6033761bd2157b886a30190fc3a # save the attached .config to linux build tree make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/nvdimm/
If you fix the issue, kindly add following tag as appropriate
sparse warnings: (new ones prefixed by >>)
>> drivers/nvdimm/nd_perf.c:159:6: sparse: sparse: symbol 'nvdimm_pmu_free_hotplug_memory' was not declared. Should it be static?
Please review and possibly fold the followup patch.
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [RESEND PATCH v4 2/4] drivers/nvdimm: Add perf interface to expose nvdimm performance stats
Quoted 24 lines · kernel test robot
Hi Kajol,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linux-nvdimm/libnvdimm-for-next] [also build test WARNING on powerpc/next linus/master v5.14 next-20210903] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]url: https://github.com/0day-ci/linux/commits/Kajol-Jain/Add-perf-interface-to-expose-nvdimm/20210903-131212 base: https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git libnvdimm-for-next config: x86_64-randconfig-s021-20210903 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.4-rc1-dirty # https://github.com/0day-ci/linux/commit/f841601cc058e6033761bd2157b886a30190fc3a git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Kajol-Jain/Add-perf-interface-to-expose-nvdimm/20210903-131212 git checkout f841601cc058e6033761bd2157b886a30190fc3a # save the attached .config to linux build tree make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/nvdimm/
Quoted 8 lines
If you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>sparse warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
drivers/nvdimm/nd_perf.c:159:6: sparse: sparse: symbol 'nvdimm_pmu_free_hotplug_memory' was not declared. Should it be static?Please review and possibly fold the followup patch.
Hi,
Sure I will correct it and send follow-up patchset.
Thanks,
Kajol Jain
Quoted 5 lines
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build bot[RFC PATCH] drivers/nvdimm: nvdimm_pmu_free_hotplug_memory() can be static
In reply to Kajol Jaindrivers/nvdimm/nd_perf.c:159:6: warning: symbol 'nvdimm_pmu_free_hotplug_memory' was not declared. Should it be static?
drivers/nvdimm/nd_perf.c:159:6: warning: symbol 'nvdimm_pmu_free_hotplug_memory' was not declared. Should it be static?
--- nd_perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvdimm/nd_perf.c +1 -1
@@ -156,7 +156,7 @@ static int nvdimm_pmu_cpu_hotplug_init(struct nvdimm_pmu *nd_pmu)return 0 ; } -void nvdimm_pmu_free_hotplug_memory (struct nvdimm_pmu *nd_pmu) +static void nvdimm_pmu_free_hotplug_memory (struct nvdimm_pmu *nd_pmu) {cpuhp_state_remove_instance_nocalls (nd_pmu->cpuhp_state, &nd_pmu->node);cpuhp_remove_multi_state (nd_pmu->cpuhp_state);
Re: [RFC PATCH] drivers/nvdimm: nvdimm_pmu_free_hotplug_memory() can be static
Quoted 14 lines · kernel test robot
drivers/nvdimm/nd_perf.c:159:6: warning: symbol 'nvdimm_pmu_free_hotplug_memory' was not declared. Should it be static?Reported-by kernel test robot <[email protected]>Signed-off-by kernel test robot <[email protected]>--- nd_perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvdimm/nd_perf.c +0
-0
drivers/nvdimm/nd_perf.c static int nvdimm_pmu_cpu_hotplug_init(struct nvdimm_pmu *nd_pmu) · line 162
Quoted 8 lines
drivers/nvdimm/nd_perf.c +1
-1@@ -156,7 +156,7 @@ static int nvdimm_pmu_cpu_hotplug_init(struct nvdimm_pmu *nd_pmu)return 0 ; } -void nvdimm_pmu_free_hotplug_memory (struct nvdimm_pmu *nd_pmu) +static void nvdimm_pmu_free_hotplug_memory (struct nvdimm_pmu *nd_pmu) {cpuhp_state_remove_instance_nocalls (nd_pmu->cpuhp_state, &nd_pmu->node);cpuhp_remove_multi_state (nd_pmu->cpuhp_state);
Hi,
Thanks for reporting this issue, I will merge it in my followup patchset.
Thanks,
Kajol Jain
PATCH RESEND v4 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 events, cpumask, attribute groups 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/cchrhcnt/ [Kernel PMU event] nmem0/cchwhcnt/ [Kernel PMU event] nmem0/critrscu/ [Kernel PMU event] nmem0/ctlresct/ [Kernel PMU event] nmem0/ctlrestm/ [Kernel PMU event] nmem0/fastwcnt/ [Kernel PMU event] nmem0/hostlcnt/ [Kernel PMU event] nmem0/hostldur/ [Kernel PMU event] nmem0/hostscnt/ [Kernel PMU event] nmem0/hostsdur/ [Kernel PMU event] nmem0/medrcnt/ [Kernel PMU event] nmem0/medrdur/ [Kernel PMU event] nmem0/medwcnt/ [Kernel PMU event] nmem0/medwdur/ [Kernel PMU event] nmem0/memlife/ [Kernel PMU event] nmem0/noopstat/ [Kernel PMU event] nmem0/ponsecs/ [Kernel PMU event] nmem1/cchrhcnt/ [Kernel PMU event] nmem1/cchwhcnt/ [Kernel PMU event] nmem1/critrscu/ [Kernel PMU event]
...
nmem1/noopstat/ [Kernel PMU event]
nmem1/ponsecs/ [Kernel PMU event]
--- arch/powerpc/include/asm/device.h | 5 + arch/powerpc/platforms/pseries/papr_scm.c | 365 ++++++++++++++++++++++ 2 files changed, 370 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 +365 -0
401 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH RESEND v4 4/4 powerpc/papr_scm: Document papr_scm sysfs event format entries
In reply to Kajol JainDetails is added for the event, cpumask and format attributes in the ABI documentation.
--- Documentation/ABI/testing/sysfs-bus-papr-pmem | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+)
Documentation/ABI/testing/sysfs-bus-papr-pmem +31 -0
@@ -61,3 +61,34 @@ Description: * "CchRHCnt" : Cache Read Hit Count * "CchWHCnt" : Cache Write Hit Count * "FastWCnt" : Fast Write Count + +What: /sys/devices/nmemX/format +Date: June 2021 +Contact: linuxppc-dev <[email protected]>, [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:: + noopstat = "event=0x1" + +What: /sys/devices/nmemX/events +Date: June 2021 +Contact: linuxppc-dev <[email protected]>, [email protected], +Description: (RO) Attribute group to describe performance monitoring + events specific to papr-scm. 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). + +What: /sys/devices/nmemX/cpumask +Date: June 2021 +Contact: linuxppc-dev <[email protected]>, [email protected], +Description: (RO) This sysfs file exposes the cpumask which is designated to make + HCALLs to retrieve nvdimm pmu event counter data.
Signature · 1 line
2.26.2
Re: [RESEND PATCH v4 4/4] powerpc/papr_scm: Document papr_scm sysfs event format entries
Quoted 28 lines · Kajol Jain
Details is added for the event, cpumask and format attributes in the ABI documentation.
Reviewed-by Madhavan Srinivasan <[email protected]>Tested-by Nageswara R Sastry <[email protected]>Signed-off-by Kajol Jain <[email protected]>--- Documentation/ABI/testing/sysfs-bus-papr-pmem | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+)Documentation/ABI/testing/sysfs-bus-papr-pmem +8
-0@@ -61,3 +61,34 @@ Description: * "CchRHCnt" : Cache Read Hit Count * "CchWHCnt" : Cache Write Hit Count * "FastWCnt" : Fast Write Count + +What: /sys/devices/nmemX/format +Date: June 2021 +Contact: linuxppc-dev <[email protected]>, [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). +
Documentation/ABI/testing/sysfs-bus-papr-pmem Description: · line 81
Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-papr-pmem +10
-0+ 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:: + noopstat = "event=0x1" + +What: /sys/devices/nmemX/events
That's not a valid sysfs path. Did you mean /sys/bus/nd/devices/nmemX?
Documentation/ABI/testing/sysfs-bus-papr-pmem Description: · line 88
Quoted 7 lines
Documentation/ABI/testing/sysfs-bus-papr-pmem +7
-0+Date: June 2021 +Contact: linuxppc-dev <[email protected]>, [email protected], +Description: (RO) Attribute group to describe performance monitoring + events specific to papr-scm. 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).
Given these events are in the generic namespace the ABI documentation should be generic as well. So I think move these entries to Documentation/ABI/testing/sysfs-bus-nvdimm directly.
You can still mention papr-scm, but I would expect something like:
What: /sys/bus/nd/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, for
example: Documentation/driver-api/nvdimm/papr-scm.
Documentation/ABI/testing/sysfs-bus-papr-pmem Description: · line 94
Quoted 6 lines
Documentation/ABI/testing/sysfs-bus-papr-pmem +6
-0+ +What: /sys/devices/nmemX/cpumask +Date: June 2021 +Contact: linuxppc-dev <[email protected]>, [email protected], +Description: (RO) This sysfs file exposes the cpumask which is designated to make + HCALLs to retrieve nvdimm pmu event counter data.
Seems this one would be provider generic, so no need to refer to PPC specific concepts like HCALLs.
Re: [RESEND PATCH v4 4/4] powerpc/papr_scm: Document papr_scm sysfs event format entries
Quoted 33 lines · Dan Williams
Quoted 32 lines · Kajol Jain
Details is added for the event, cpumask and format attributes in the ABI documentation.
Reviewed-by Madhavan Srinivasan <[email protected]>Tested-by Nageswara R Sastry <[email protected]>Signed-off-by Kajol Jain <[email protected]>--- Documentation/ABI/testing/sysfs-bus-papr-pmem | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+)Documentation/ABI/testing/sysfs-bus-papr-pmem +12
-0@@ -61,3 +61,34 @@ Description: * "CchRHCnt" : Cache Read Hit Count * "CchWHCnt" : Cache Write Hit Count * "FastWCnt" : Fast Write Count + +What: /sys/devices/nmemX/format +Date: June 2021 +Contact: linuxppc-dev <[email protected]>, [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:: +
Quoted 8 lines
Documentation/ABI/testing/sysfs-bus-papr-pmem Description: · line 81
Quoted 6 lines
Documentation/ABI/testing/sysfs-bus-papr-pmem +6
-0+ event = "config:0-4" - event ID + + For example:: + noopstat = "event=0x1" + +What: /sys/devices/nmemX/eventsThat's not a valid sysfs path. Did you mean
/sys/bus/nd/devices/nmemX?
Hi Dan,
Thanks, I will correct it and update it to /sys/bus/event_source/devices/
where perf creates sysfs files for given pmu.
Quoted 19 lines
Documentation/ABI/testing/sysfs-bus-papr-pmem Description: · line 88
Quoted 8 lines
Documentation/ABI/testing/sysfs-bus-papr-pmem +7
-0+Date: June 2021 +Contact: linuxppc-dev <[email protected]>, [email protected], +Description: (RO) Attribute group to describe performance monitoring + events specific to papr-scm. 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).Given these events are in the generic namespace the ABI documentation should be generic as well. So I think move these entries to
Documentation/ABI/testing/sysfs-bus-nvdimmdirectly.You can still mention papr-scm, but I would expect something like:
What: /sys/bus/nd/devices/nmemX/events Date: September 2021 KernelVersion: 5.16 Contact: Kajol Jain <[email protected]>
Quoted 11 lines
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 inDocumentation/driver-api/nvdimm/$provider, for
example:Documentation/driver-api/nvdimm/papr-scm.
I will update it accordingly.
Quoted 11 lines
Documentation/ABI/testing/sysfs-bus-papr-pmem Description: · line 94
Quoted 7 lines
Documentation/ABI/testing/sysfs-bus-papr-pmem +6
-0+ +What: /sys/devices/nmemX/cpumask +Date: June 2021 +Contact: linuxppc-dev <[email protected]>, [email protected], +Description: (RO) This sysfs file exposes the cpumask which is designated to make + HCALLs to retrieve nvdimm pmu event counter data.Seems this one would be provider generic, so no need to refer to PPC specific concepts like HCALLs.
Sure will update it.
Thanks,
Kajol Jain