[v2 PATCH 1/2] 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: 0fab1ba6ad6b ("drivers/nvdimm: Add perf interface to expose nvdimm performance stats") (Commit id based on libnvdimm-for-next tree) Signed-off-by: Kajol Jain Link: https://lore.kernel.org/all/62317124.ybqfu33+s%2fwdvwgj%25...@intel.com/ Reported-by: kernel test robot --- drivers/nvdimm/Makefile | 2 +- drivers/nvdimm/nd_perf.c | 1 + include/linux/nd.h | 16 3 files changed, 14 insertions(+), 5 deletions(-) --- Changelog: v1 -> v2 - Rebase and tested the fix patch changes on top of libnvdimm-for-next branch - Add stub functions for register_nvdimm_pmu and unregister_nvdimm_pmu functions to handle CONFIG_PERF_EVENTS=n case as suggested by Dan Williams - Move the platform_device header file addition part from nd.h to nd_perf.c and just forward declare struct platform_device in nd.h --- diff --git a/drivers/nvdimm/Makefile b/drivers/nvdimm/Makefile index 3fb806748716..ba0296dca9db 100644 --- a/drivers/nvdimm/Makefile +++ b/drivers/nvdimm/Makefile @@ -15,7 +15,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-$(CONFIG_PERF_EVENTS) += nd_perf.o libnvdimm-y += dimm.o libnvdimm-y += region_devs.o libnvdimm-y += region.o diff --git a/drivers/nvdimm/nd_perf.c b/drivers/nvdimm/nd_perf.c index 314415894acf..433bbb68ae64 100644 --- a/drivers/nvdimm/nd_perf.c +++ b/drivers/nvdimm/nd_perf.c @@ -10,6 +10,7 @@ #define pr_fmt(fmt) "nvdimm_pmu: " fmt #include +#include #define EVENT(_name, _code) enum{_name = _code} diff --git a/include/linux/nd.h b/include/linux/nd.h index 7b2ccbdc1cbc..f3e91c891cbc 100644 --- a/include/linux/nd.h +++ b/include/linux/nd.h @@ -9,7 +9,6 @@ #include #include #include -#include enum nvdimm_event { NVDIMM_REVALIDATE_POISON, @@ -57,15 +56,24 @@ struct nvdimm_pmu { struct cpumask arch_cpumask; }; +struct platform_device; + +#ifdef CONFIG_PERF_EVENTS 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); + +#else +static inline int register_nvdimm_pmu(struct nvdimm_pmu *nvdimm, struct platform_device *pdev) +{ + return -ENXIO; +} + +static inline void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu) { } +#endif struct nd_device_driver { struct device_driver drv; -- 2.31.1
Re: [PATCH 1/2] drivers/nvdimm: Fix build failure when CONFIG_PERF_EVENTS is not set
On 3/22/22 07:40, Dan Williams wrote: > On Fri, Mar 18, 2022 at 4:42 AM Kajol Jain wrote: >> >> The following build failure occures 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 removed 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 >> >> Fixes: 0fab1ba6ad6b ("drivers/nvdimm: Add perf interface to expose >> nvdimm performance stats") (Commit id based on linux-next tree) >> Signed-off-by: Kajol Jain >> Link: >> https://lore.kernel.org/all/62317124.ybqfu33+s%2fwdvwgj%25...@intel.com/ >> Reported-by: kernel test robot >> --- >> drivers/nvdimm/Makefile | 2 +- >> include/linux/nd.h | 7 --- >> 2 files changed, 5 insertions(+), 4 deletions(-) >> >> --- >> - This fix patch changes are added and tested on top of linux-next tree >> on the 'next-20220315' branch. >> --- >> diff --git a/drivers/nvdimm/Makefile b/drivers/nvdimm/Makefile >> index 3fb806748716..ba0296dca9db 100644 >> --- a/drivers/nvdimm/Makefile >> +++ b/drivers/nvdimm/Makefile >> @@ -15,7 +15,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-$(CONFIG_PERF_EVENTS) += nd_perf.o >> libnvdimm-y += dimm.o >> libnvdimm-y += region_devs.o >> libnvdimm-y += region.o >> diff --git a/include/linux/nd.h b/include/linux/nd.h >> index 7b2ccbdc1cbc..a4265eaf5ae8 100644 >> --- a/include/linux/nd.h >> +++ b/include/linux/nd.h >> @@ -8,8 +8,10 @@ >> #include >> #include >> #include >> +#ifdef CONFIG_PERF_EVENTS >> #include > > Why must this not be included? Doesn't it already handle the > CONFIG_PERF_EVENTS=n case internally? > >> #include > > I notice now that this platform-device header should have never been > added in the first place, just forward declare: > > struct platform_device; Hi Dan, Sure I will do the required changes. Thanks, Kajol Jain > >> +#endif >> >> enum nvdimm_event { >> NVDIMM_REVALIDATE_POISON, >> @@ -25,6 +27,7 @@ enum nvdimm_claim_class { >> NVDIMM_CCLASS_UNKNOWN, >> }; >> >> +#ifdef CONFIG_PERF_EVENTS >> #define NVDIMM_EVENT_VAR(_id) event_attr_##_id >> #define NVDIMM_EVENT_PTR(_id) (_attr_##_id.attr.attr) > > Why must these be inside the ifdef guard? > >> >> @@ -63,9 +66,7 @@ extern ssize_t nvdimm_events_sysfs_show(struct device *dev, >> >> int register_nvdimm_pmu(struct nvdimm_pmu *nvdimm, struct platform_device >> *pdev); >> void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu); > > Shouldn't there also be stub functions in the CONFIG_PERF_EVENTS=n case? > > static inline int register_nvdimm_pmu(struct nvdimm_pmu *nvdimm, > struct platform_device *pdev) > { > return -ENXIO; > } > > static inline 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); > > Yeah, I should have caught these earlier. > >> +#endif >> >> struct nd_device_driver { >> struct device_driver drv; >> -- >> 2.31.1 >>
Re: [PATCH 1/2] drivers/nvdimm: Fix build failure when CONFIG_PERF_EVENTS is not set
On Fri, Mar 18, 2022 at 4:42 AM Kajol Jain wrote: > > The following build failure occures 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 removed 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 > > Fixes: 0fab1ba6ad6b ("drivers/nvdimm: Add perf interface to expose > nvdimm performance stats") (Commit id based on linux-next tree) > Signed-off-by: Kajol Jain > Link: https://lore.kernel.org/all/62317124.ybqfu33+s%2fwdvwgj%25...@intel.com/ > Reported-by: kernel test robot > --- > drivers/nvdimm/Makefile | 2 +- > include/linux/nd.h | 7 --- > 2 files changed, 5 insertions(+), 4 deletions(-) > > --- > - This fix patch changes are added and tested on top of linux-next tree > on the 'next-20220315' branch. > --- > diff --git a/drivers/nvdimm/Makefile b/drivers/nvdimm/Makefile > index 3fb806748716..ba0296dca9db 100644 > --- a/drivers/nvdimm/Makefile > +++ b/drivers/nvdimm/Makefile > @@ -15,7 +15,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-$(CONFIG_PERF_EVENTS) += nd_perf.o > libnvdimm-y += dimm.o > libnvdimm-y += region_devs.o > libnvdimm-y += region.o > diff --git a/include/linux/nd.h b/include/linux/nd.h > index 7b2ccbdc1cbc..a4265eaf5ae8 100644 > --- a/include/linux/nd.h > +++ b/include/linux/nd.h > @@ -8,8 +8,10 @@ > #include > #include > #include > +#ifdef CONFIG_PERF_EVENTS > #include Why must this not be included? Doesn't it already handle the CONFIG_PERF_EVENTS=n case internally? > #include I notice now that this platform-device header should have never been added in the first place, just forward declare: struct platform_device; > +#endif > > enum nvdimm_event { > NVDIMM_REVALIDATE_POISON, > @@ -25,6 +27,7 @@ enum nvdimm_claim_class { > NVDIMM_CCLASS_UNKNOWN, > }; > > +#ifdef CONFIG_PERF_EVENTS > #define NVDIMM_EVENT_VAR(_id) event_attr_##_id > #define NVDIMM_EVENT_PTR(_id) (_attr_##_id.attr.attr) Why must these be inside the ifdef guard? > > @@ -63,9 +66,7 @@ extern ssize_t nvdimm_events_sysfs_show(struct device *dev, > > int register_nvdimm_pmu(struct nvdimm_pmu *nvdimm, struct platform_device > *pdev); > void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu); Shouldn't there also be stub functions in the CONFIG_PERF_EVENTS=n case? static inline int register_nvdimm_pmu(struct nvdimm_pmu *nvdimm, struct platform_device *pdev) { return -ENXIO; } static inline 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); Yeah, I should have caught these earlier. > +#endif > > struct nd_device_driver { > struct device_driver drv; > -- > 2.31.1 >
[PATCH 1/2] drivers/nvdimm: Fix build failure when CONFIG_PERF_EVENTS is not set
The following build failure occures 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 removed 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 Fixes: 0fab1ba6ad6b ("drivers/nvdimm: Add perf interface to expose nvdimm performance stats") (Commit id based on linux-next tree) Signed-off-by: Kajol Jain Link: https://lore.kernel.org/all/62317124.ybqfu33+s%2fwdvwgj%25...@intel.com/ Reported-by: kernel test robot --- drivers/nvdimm/Makefile | 2 +- include/linux/nd.h | 7 --- 2 files changed, 5 insertions(+), 4 deletions(-) --- - This fix patch changes are added and tested on top of linux-next tree on the 'next-20220315' branch. --- diff --git a/drivers/nvdimm/Makefile b/drivers/nvdimm/Makefile index 3fb806748716..ba0296dca9db 100644 --- a/drivers/nvdimm/Makefile +++ b/drivers/nvdimm/Makefile @@ -15,7 +15,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-$(CONFIG_PERF_EVENTS) += nd_perf.o libnvdimm-y += dimm.o libnvdimm-y += region_devs.o libnvdimm-y += region.o diff --git a/include/linux/nd.h b/include/linux/nd.h index 7b2ccbdc1cbc..a4265eaf5ae8 100644 --- a/include/linux/nd.h +++ b/include/linux/nd.h @@ -8,8 +8,10 @@ #include #include #include +#ifdef CONFIG_PERF_EVENTS #include #include +#endif enum nvdimm_event { NVDIMM_REVALIDATE_POISON, @@ -25,6 +27,7 @@ enum nvdimm_claim_class { NVDIMM_CCLASS_UNKNOWN, }; +#ifdef CONFIG_PERF_EVENTS #define NVDIMM_EVENT_VAR(_id) event_attr_##_id #define NVDIMM_EVENT_PTR(_id) (_attr_##_id.attr.attr) @@ -63,9 +66,7 @@ extern ssize_t nvdimm_events_sysfs_show(struct device *dev, 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); +#endif struct nd_device_driver { struct device_driver drv; -- 2.31.1