Message ID | 20200214080606.26872-2-kjain@linux.ibm.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 22697da36d0cee57c2a5750ef7d84e4d88da17e7 |
Headers | show |
Series | [1/2] powerpc/kernel/sysfs: Refactor current sysfs.c | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | Successfully applied on branch powerpc/merge (a5bc6e124219546a81ce334dc9b16483d55e9abf) |
snowpatch_ozlabs/build-ppc64le | success | Build succeeded |
snowpatch_ozlabs/build-ppc64be | success | Build succeeded |
snowpatch_ozlabs/build-ppc64e | success | Build succeeded |
snowpatch_ozlabs/build-pmac32 | success | Build succeeded |
snowpatch_ozlabs/checkpatch | warning | total: 0 errors, 1 warnings, 0 checks, 46 lines checked |
snowpatch_ozlabs/needsstable | success | Patch has no Fixes tags |
"Kajol Jain" <kjain@linux.ibm.com> wrote on 14/02/2020 01:36:06 PM: > From: "Kajol Jain" <kjain@linux.ibm.com> > To: linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au > Cc: maddy@linux.vnet.ibm.com, anju@linux.vnet.ibm.com, Nageswara R > Sastry/India/IBM@IBMIN, kjain@linux.ibm.com > Date: 14/02/2020 01:36 PM > Subject: [PATCH 2/2] powerpc/kernel/sysfs: Add new config option > PMU_SYSFS to enable PMU SPRs sysfs file creation > > Many of the performance monitoring unit (PMU) SPRs are > exposed in the sysfs. This may not be a desirable since > "perf" API is the primary interface to program PMU and > collect counter data in the system. But that said, we > cant remove these sysfs files since we dont whether > anyone/anything is using them. > > So the patch adds a new CONFIG option 'CONFIG_PMU_SYSFS' > (user selectable) to be used in sysfs file creation for > PMU SPRs. New option by default is disabled, but can be > enabled if user needs it. > > Tested this patch behaviour in powernv and pseries machines. > Patch is also tested for pmac32_defconfig. > > Signed-off-by: Kajol Jain <kjain@linux.ibm.com> Tested-by: Nageswara R Sastry <nasastry@in.ibm.com> Tested on PowerVM, PowerNV machines with and with out CONFIG_PMU_SYSFS With CONFIG_PMU_SYSFS=y For online CPUs can see the SPR files namely mmcr*, pmc* With CONFIG_PMU_SYSFS=n Not seeing the SPR files > --- > arch/powerpc/kernel/sysfs.c | 6 ++++++ > arch/powerpc/platforms/Kconfig.cputype | 6 ++++++ > 2 files changed, 12 insertions(+) > > diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c > index 74da5eb..cd807e8 100644 > --- a/arch/powerpc/kernel/sysfs.c > +++ b/arch/powerpc/kernel/sysfs.c > @@ -562,6 +562,7 @@ void ppc_enable_pmcs(void) > * that are implemented on the current processor > */ > > +#ifdef CONFIG_PMU_SYSFS > #if defined(CONFIG_PPC64) || defined(CONFIG_PPC_BOOK3S_32) > #define HAS_PPC_PMC_CLASSIC 1 > #define HAS_PPC_PMC_IBM 1 > @@ -575,6 +576,7 @@ void ppc_enable_pmcs(void) > #ifdef CONFIG_PPC_BOOK3S_32 > #define HAS_PPC_PMC_G4 1 > #endif > +#endif /* CONFIG_PMU_SYSFS */ > > #if defined(CONFIG_PPC64) && defined(CONFIG_DEBUG_MISC) > #define HAS_PPC_PA6T > @@ -812,8 +814,10 @@ static int register_cpu_online(unsigned int cpu) > device_create_file(s, &pmc_attrs[i]); > > #ifdef CONFIG_PPC64 > +#ifdef CONFIG_PMU_SYSFS > if (cpu_has_feature(CPU_FTR_MMCRA)) > device_create_file(s, &dev_attr_mmcra); > +#endif /* CONFIG_PMU_SYSFS */ > > if (cpu_has_feature(CPU_FTR_PURR)) { > if (!firmware_has_feature(FW_FEATURE_LPAR)) > @@ -901,8 +905,10 @@ static int unregister_cpu_online(unsigned int cpu) > device_remove_file(s, &pmc_attrs[i]); > > #ifdef CONFIG_PPC64 > +#ifdef CONFIG_PMU_SYSFS > if (cpu_has_feature(CPU_FTR_MMCRA)) > device_remove_file(s, &dev_attr_mmcra); > +#endif /* CONFIG_PMU_SYSFS */ > > if (cpu_has_feature(CPU_FTR_PURR)) > device_remove_file(s, &dev_attr_purr); > diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/ > platforms/Kconfig.cputype > index 8d7f9c3..e58b48d 100644 > --- a/arch/powerpc/platforms/Kconfig.cputype > +++ b/arch/powerpc/platforms/Kconfig.cputype > @@ -417,6 +417,12 @@ config PPC_MM_SLICES > config PPC_HAVE_PMU_SUPPORT > bool > > +config PMU_SYSFS > + bool "Create PMU SPRs sysfs file" > + default n > + help > + This option enables sysfs file creation for PMU SPRs like > MMCR* and PMC*. > + > config PPC_PERF_CTRS > def_bool y > depends on PERF_EVENTS && PPC_HAVE_PMU_SUPPORT > -- > 1.8.3.1 >
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c index 74da5eb..cd807e8 100644 --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c @@ -562,6 +562,7 @@ void ppc_enable_pmcs(void) * that are implemented on the current processor */ +#ifdef CONFIG_PMU_SYSFS #if defined(CONFIG_PPC64) || defined(CONFIG_PPC_BOOK3S_32) #define HAS_PPC_PMC_CLASSIC 1 #define HAS_PPC_PMC_IBM 1 @@ -575,6 +576,7 @@ void ppc_enable_pmcs(void) #ifdef CONFIG_PPC_BOOK3S_32 #define HAS_PPC_PMC_G4 1 #endif +#endif /* CONFIG_PMU_SYSFS */ #if defined(CONFIG_PPC64) && defined(CONFIG_DEBUG_MISC) #define HAS_PPC_PA6T @@ -812,8 +814,10 @@ static int register_cpu_online(unsigned int cpu) device_create_file(s, &pmc_attrs[i]); #ifdef CONFIG_PPC64 +#ifdef CONFIG_PMU_SYSFS if (cpu_has_feature(CPU_FTR_MMCRA)) device_create_file(s, &dev_attr_mmcra); +#endif /* CONFIG_PMU_SYSFS */ if (cpu_has_feature(CPU_FTR_PURR)) { if (!firmware_has_feature(FW_FEATURE_LPAR)) @@ -901,8 +905,10 @@ static int unregister_cpu_online(unsigned int cpu) device_remove_file(s, &pmc_attrs[i]); #ifdef CONFIG_PPC64 +#ifdef CONFIG_PMU_SYSFS if (cpu_has_feature(CPU_FTR_MMCRA)) device_remove_file(s, &dev_attr_mmcra); +#endif /* CONFIG_PMU_SYSFS */ if (cpu_has_feature(CPU_FTR_PURR)) device_remove_file(s, &dev_attr_purr); diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index 8d7f9c3..e58b48d 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -417,6 +417,12 @@ config PPC_MM_SLICES config PPC_HAVE_PMU_SUPPORT bool +config PMU_SYSFS + bool "Create PMU SPRs sysfs file" + default n + help + This option enables sysfs file creation for PMU SPRs like MMCR* and PMC*. + config PPC_PERF_CTRS def_bool y depends on PERF_EVENTS && PPC_HAVE_PMU_SUPPORT
Many of the performance monitoring unit (PMU) SPRs are exposed in the sysfs. This may not be a desirable since "perf" API is the primary interface to program PMU and collect counter data in the system. But that said, we cant remove these sysfs files since we dont whether anyone/anything is using them. So the patch adds a new CONFIG option 'CONFIG_PMU_SYSFS' (user selectable) to be used in sysfs file creation for PMU SPRs. New option by default is disabled, but can be enabled if user needs it. Tested this patch behaviour in powernv and pseries machines. Patch is also tested for pmac32_defconfig. Signed-off-by: Kajol Jain <kjain@linux.ibm.com> --- arch/powerpc/kernel/sysfs.c | 6 ++++++ arch/powerpc/platforms/Kconfig.cputype | 6 ++++++ 2 files changed, 12 insertions(+)