Skip to content

Commit de7a9e9

Browse files
kjain101djbw
authored andcommitted
drivers/nvdimm: Fix build failure when CONFIG_PERF_EVENTS is not set
The following build failure occurs when CONFIG_PERF_EVENTS is not set as generic pmu functions are not visible in that scenario. |-- s390-randconfig-r044-20220313 | |-- nd_perf.c:(.text):undefined-reference-to-perf_pmu_migrate_context | |-- nd_perf.c:(.text):undefined-reference-to-perf_pmu_register | `-- nd_perf.c:(.text):undefined-reference-to-perf_pmu_unregister Similar build failure in nds32 architecture: nd_perf.c:(.text+0x21e): undefined reference to `perf_pmu_migrate_context' nd_perf.c:(.text+0x434): undefined reference to `perf_pmu_register' nd_perf.c:(.text+0x57c): undefined reference to `perf_pmu_unregister' Fix this issue by adding check for CONFIG_PERF_EVENTS config option and disabling the nvdimm perf interface incase this config is not set. Also remove function declaration of perf_pmu_migrate_context, perf_pmu_register, perf_pmu_unregister functions from nd.h as these are common pmu functions which are part of perf_event.h and since we are disabling nvdimm perf interface incase CONFIG_PERF_EVENTS option is not set, we not need to declare them in nd.h Also move the platform_device header file addition part from nd.h to nd_perf.c and add stub functions for register_nvdimm_pmu and unregister_nvdimm_pmu functions to handle CONFIG_PERF_EVENTS=n case. Fixes: 0fab1ba ("drivers/nvdimm: Add perf interface to expose nvdimm performance stats") (Commit id based on libnvdimm-for-next tree) Signed-off-by: Kajol Jain <kjain@linux.ibm.com> Link: https://lore.kernel.org/all/62317124.YBQFU33+s%2FwdvWGj%25lkp@intel.com/ Reported-by: kernel test robot <lkp@intel.com> Link: https://lore.kernel.org/r/20220323164550.109768-1-kjain@linux.ibm.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 3b6c6c0 commit de7a9e9

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

drivers/nvdimm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ nd_e820-y := e820.o
1515
libnvdimm-y := core.o
1616
libnvdimm-y += bus.o
1717
libnvdimm-y += dimm_devs.o
18-
libnvdimm-y += nd_perf.o
18+
libnvdimm-$(CONFIG_PERF_EVENTS) += nd_perf.o
1919
libnvdimm-y += dimm.o
2020
libnvdimm-y += region_devs.o
2121
libnvdimm-y += region.o

drivers/nvdimm/nd_perf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define pr_fmt(fmt) "nvdimm_pmu: " fmt
1111

1212
#include <linux/nd.h>
13+
#include <linux/platform_device.h>
1314

1415
#define EVENT(_name, _code) enum{_name = _code}
1516

include/linux/nd.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <linux/device.h>
1010
#include <linux/badblocks.h>
1111
#include <linux/perf_event.h>
12-
#include <linux/platform_device.h>
1312

1413
enum nvdimm_event {
1514
NVDIMM_REVALIDATE_POISON,
@@ -57,15 +56,24 @@ struct nvdimm_pmu {
5756
struct cpumask arch_cpumask;
5857
};
5958

59+
struct platform_device;
60+
61+
#ifdef CONFIG_PERF_EVENTS
6062
extern ssize_t nvdimm_events_sysfs_show(struct device *dev,
6163
struct device_attribute *attr,
6264
char *page);
6365

6466
int register_nvdimm_pmu(struct nvdimm_pmu *nvdimm, struct platform_device *pdev);
6567
void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu);
66-
void perf_pmu_migrate_context(struct pmu *pmu, int src_cpu, int dst_cpu);
67-
int perf_pmu_register(struct pmu *pmu, const char *name, int type);
68-
void perf_pmu_unregister(struct pmu *pmu);
68+
69+
#else
70+
static inline int register_nvdimm_pmu(struct nvdimm_pmu *nvdimm, struct platform_device *pdev)
71+
{
72+
return -ENXIO;
73+
}
74+
75+
static inline void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu) { }
76+
#endif
6977

7078
struct nd_device_driver {
7179
struct device_driver drv;

0 commit comments

Comments
 (0)