mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-27 04:22:58 +00:00
drivers/nvdimm: Add perf interface to expose nvdimm performance stats
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. [Declare pmu functions in nd.h file to resolve implicit-function-declaration warning and make hotplug function static as reported by kernel test robot] Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Nageswara R Sastry <rnsastry@linux.ibm.com> Signed-off-by: Kajol Jain <kjain@linux.ibm.com> Link: https://lore.kernel.org/all/202202241242.zqzGkguy-lkp@intel.com/ Reported-by: kernel test robot <lkp@intel.com> Reviewed-by: Madhavan Srinivasan <maddy@in.ibm.com> Link: https://lore.kernel.org/r/20220225143024.47947-3-kjain@linux.ibm.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
@@ -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,16 @@ 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);
|
||||
void perf_pmu_migrate_context(struct pmu *pmu, int src_cpu, int dst_cpu);
|
||||
int perf_pmu_register(struct pmu *pmu, const char *name, int type);
|
||||
void perf_pmu_unregister(struct pmu *pmu);
|
||||
|
||||
struct nd_device_driver {
|
||||
struct device_driver drv;
|
||||
unsigned long type;
|
||||
|
||||
Reference in New Issue
Block a user