From: maddy <maddy@linux.vnet.ibm.com>
To: Kajol Jain <kjain@linux.ibm.com>,
linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au
Cc: anju@linux.vnet.ibm.com
Subject: Re: [PATCH] powerpc/perf: Add functionality to check PERF_EVENTS config option
Date: Thu, 3 Oct 2019 13:34:12 +0530 [thread overview]
Message-ID: <a83a7daa-779b-037c-c5ab-3901fe3f9802@linux.vnet.ibm.com> (raw)
In-Reply-To: <20191001092113.17826-1-kjain@linux.ibm.com>
On 10/1/19 2:51 PM, Kajol Jain wrote:
> Perf is the primary interface to program performance monitoring
> unit (pmu) and collect counter data in system.
> But currently pmu register files are created in the
> /sys/devices/system/cpu/cpu* without checking CONFIG_PERF_EVENTS
> option. These includes PMC* and MMCR* sprs.
> Patch ties sysfs pmu spr file creation with CONFIG_PERF_EVENTS options.
>
> Tested this patch with enable/disable CONFIG_PERF_EVENTS option
> in powernv and pseries machines.
> Also did compilation testing with book3s_32.config.
Title of the patch should be
powerpc/kernel/sysfs: Add PERF_EVENT config option check to PMU SPRs
Rest looks fine.
Reviewed-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
> Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
> ---
> arch/powerpc/kernel/sysfs.c | 21 ++++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
> index e2147d7c9e72..263023cc6308 100644
> --- a/arch/powerpc/kernel/sysfs.c
> +++ b/arch/powerpc/kernel/sysfs.c
> @@ -456,16 +456,21 @@ static ssize_t __used \
>
> #if defined(CONFIG_PPC64)
> #define HAS_PPC_PMC_CLASSIC 1
> +#if defined(CONFIG_PERF_EVENTS)
> #define HAS_PPC_PMC_IBM 1
> +#endif
> #define HAS_PPC_PMC_PA6T 1
> #elif defined(CONFIG_PPC_BOOK3S_32)
> #define HAS_PPC_PMC_CLASSIC 1
> +#if defined(CONFIG_PERF_EVENTS)
> #define HAS_PPC_PMC_IBM 1
> #define HAS_PPC_PMC_G4 1
> #endif
> +#endif
>
>
> #ifdef HAS_PPC_PMC_CLASSIC
> +#ifdef HAS_PPC_PMC_IBM
> SYSFS_PMCSETUP(mmcr0, SPRN_MMCR0);
> SYSFS_PMCSETUP(mmcr1, SPRN_MMCR1);
> SYSFS_PMCSETUP(pmc1, SPRN_PMC1);
> @@ -484,6 +489,10 @@ SYSFS_PMCSETUP(pmc7, SPRN_PMC7);
> SYSFS_PMCSETUP(pmc8, SPRN_PMC8);
>
> SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
> +#endif /* CONFIG_PPC64 */
> +#endif /* HAS_PPC_PMC_IBM */
> +
> +#ifdef CONFIG_PPC64
> SYSFS_SPRSETUP(purr, SPRN_PURR);
> SYSFS_SPRSETUP(spurr, SPRN_SPURR);
> SYSFS_SPRSETUP(pir, SPRN_PIR);
> @@ -494,7 +503,9 @@ SYSFS_SPRSETUP(tscr, SPRN_TSCR);
> enable write when needed with a separate function.
> Lets be conservative and default to pseries.
> */
> +#ifdef HAS_PPC_PMC_IBM
> static DEVICE_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
> +#endif /* HAS_PPC_PMC_IBM */
> static DEVICE_ATTR(spurr, 0400, show_spurr, NULL);
> static DEVICE_ATTR(purr, 0400, show_purr, store_purr);
> static DEVICE_ATTR(pir, 0400, show_pir, NULL);
> @@ -605,12 +616,14 @@ static void sysfs_create_dscr_default(void)
> #endif /* CONFIG_PPC64 */
>
> #ifdef HAS_PPC_PMC_PA6T
> +#ifdef HAS_PPC_PMC_IBM
> SYSFS_PMCSETUP(pa6t_pmc0, SPRN_PA6T_PMC0);
> SYSFS_PMCSETUP(pa6t_pmc1, SPRN_PA6T_PMC1);
> SYSFS_PMCSETUP(pa6t_pmc2, SPRN_PA6T_PMC2);
> SYSFS_PMCSETUP(pa6t_pmc3, SPRN_PA6T_PMC3);
> SYSFS_PMCSETUP(pa6t_pmc4, SPRN_PA6T_PMC4);
> SYSFS_PMCSETUP(pa6t_pmc5, SPRN_PA6T_PMC5);
> +#endif /* HAS_PPC_PMC_IBM */
> #ifdef CONFIG_DEBUG_MISC
> SYSFS_SPRSETUP(hid0, SPRN_HID0);
> SYSFS_SPRSETUP(hid1, SPRN_HID1);
> @@ -648,7 +661,6 @@ static struct device_attribute ibm_common_attrs[] = {
> __ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
> __ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
> };
> -#endif /* HAS_PPC_PMC_G4 */
>
> #ifdef HAS_PPC_PMC_G4
> static struct device_attribute g4_common_attrs[] = {
> @@ -670,9 +682,11 @@ static struct device_attribute classic_pmc_attrs[] = {
> __ATTR(pmc8, 0600, show_pmc8, store_pmc8),
> #endif
> };
> +#endif /* HAS_PPC_PMC_IBM */
>
> #ifdef HAS_PPC_PMC_PA6T
> static struct device_attribute pa6t_attrs[] = {
> +#ifdef HAS_PPC_PMC_IBM
> __ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
> __ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
> __ATTR(pmc0, 0600, show_pa6t_pmc0, store_pa6t_pmc0),
> @@ -681,6 +695,7 @@ static struct device_attribute pa6t_attrs[] = {
> __ATTR(pmc3, 0600, show_pa6t_pmc3, store_pa6t_pmc3),
> __ATTR(pmc4, 0600, show_pa6t_pmc4, store_pa6t_pmc4),
> __ATTR(pmc5, 0600, show_pa6t_pmc5, store_pa6t_pmc5),
> +#endif /* HAS_PPC_PMC_IBM */
> #ifdef CONFIG_DEBUG_MISC
> __ATTR(hid0, 0600, show_hid0, store_hid0),
> __ATTR(hid1, 0600, show_hid1, store_hid1),
> @@ -769,8 +784,10 @@ static int register_cpu_online(unsigned int cpu)
> device_create_file(s, &pmc_attrs[i]);
>
> #ifdef CONFIG_PPC64
> +#ifdef HAS_PPC_PMC_IBM
> if (cpu_has_feature(CPU_FTR_MMCRA))
> device_create_file(s, &dev_attr_mmcra);
> +#endif
>
> if (cpu_has_feature(CPU_FTR_PURR)) {
> if (!firmware_has_feature(FW_FEATURE_LPAR))
> @@ -858,8 +875,10 @@ static int unregister_cpu_online(unsigned int cpu)
> device_remove_file(s, &pmc_attrs[i]);
>
> #ifdef CONFIG_PPC64
> +#ifdef HAS_PPC_PMC_IBM
> if (cpu_has_feature(CPU_FTR_MMCRA))
> device_remove_file(s, &dev_attr_mmcra);
> +#endif
>
> if (cpu_has_feature(CPU_FTR_PURR))
> device_remove_file(s, &dev_attr_purr);
prev parent reply other threads:[~2019-10-03 8:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-01 9:21 [PATCH] powerpc/perf: Add functionality to check PERF_EVENTS config option Kajol Jain
2019-10-03 8:04 ` maddy [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a83a7daa-779b-037c-c5ab-3901fe3f9802@linux.vnet.ibm.com \
--to=maddy@linux.vnet.ibm.com \
--cc=anju@linux.vnet.ibm.com \
--cc=kjain@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).