From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A7FEC433DF for ; Thu, 9 Jul 2020 07:20:27 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E51D3206E2 for ; Thu, 9 Jul 2020 07:20:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E51D3206E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4B2SHr2dYlzDqyk for ; Thu, 9 Jul 2020 17:20:24 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=atrajeev@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4B2R9w6mw4zDqkP for ; Thu, 9 Jul 2020 16:30:12 +1000 (AEST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06960iDK123248; Thu, 9 Jul 2020 02:30:02 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 325ktsen5m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Jul 2020 02:30:02 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0696KjHV015415; Thu, 9 Jul 2020 06:29:57 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 325k1vggfs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Jul 2020 06:29:56 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0696TsQY61734946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 9 Jul 2020 06:29:54 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A290AAE05A; Thu, 9 Jul 2020 06:29:54 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A7C21AE045; Thu, 9 Jul 2020 06:29:52 +0000 (GMT) Received: from [9.85.87.102] (unknown [9.85.87.102]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 9 Jul 2020 06:29:52 +0000 (GMT) From: Athira Rajeev Message-Id: <3F67D5E9-D4AE-41B0-95AC-7231DC91A058@linux.vnet.ibm.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_E1CE319B-073D-42C4-ABFB-1FE9ADFF87D9" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2 10/10] powerpc/perf: Add extended regs support for power10 platform Date: Thu, 9 Jul 2020 11:59:49 +0530 In-Reply-To: <87r1tm2owu.fsf@mpe.ellerman.id.au> To: Michael Ellerman References: <1593595262-1433-1-git-send-email-atrajeev@linux.vnet.ibm.com> <1593595262-1433-11-git-send-email-atrajeev@linux.vnet.ibm.com> <87r1tm2owu.fsf@mpe.ellerman.id.au> X-Mailer: Apple Mail (2.3608.80.23.2.2) X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-09_01:2020-07-08, 2020-07-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007090043 X-Mailman-Approved-At: Thu, 09 Jul 2020 17:18:34 +1000 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Neuling , maddy@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" --Apple-Mail=_E1CE319B-073D-42C4-ABFB-1FE9ADFF87D9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 08-Jul-2020, at 5:34 PM, Michael Ellerman = wrote: >=20 > Athira Rajeev > writes: >> Include capability flag `PERF_PMU_CAP_EXTENDED_REGS` for power10 >> and expose MMCR3, SIER2, SIER3 registers as part of extended regs. >> Also introduce `PERF_REG_PMU_MASK_31` to define extended mask >> value at runtime for power10 >>=20 >> Signed-off-by: Athira Rajeev >> --- >> arch/powerpc/include/uapi/asm/perf_regs.h | 6 ++++++ >> arch/powerpc/perf/perf_regs.c | 10 +++++++++- >> arch/powerpc/perf/power10-pmu.c | 6 ++++++ >> tools/arch/powerpc/include/uapi/asm/perf_regs.h | 6 ++++++ >> tools/perf/arch/powerpc/include/perf_regs.h | 3 +++ >> tools/perf/arch/powerpc/util/perf_regs.c | 6 ++++++ >=20 > Please split into a kernel patch and a tools patch. And cc the tools = people. Ok sure >=20 >> 6 files changed, 36 insertions(+), 1 deletion(-) >>=20 >> diff --git a/arch/powerpc/include/uapi/asm/perf_regs.h = b/arch/powerpc/include/uapi/asm/perf_regs.h >> index 485b1d5..020b51c 100644 >> --- a/arch/powerpc/include/uapi/asm/perf_regs.h >> +++ b/arch/powerpc/include/uapi/asm/perf_regs.h >> @@ -52,6 +52,9 @@ enum perf_event_powerpc_regs { >> PERF_REG_POWERPC_MMCR0, >> PERF_REG_POWERPC_MMCR1, >> PERF_REG_POWERPC_MMCR2, >> + PERF_REG_POWERPC_MMCR3, >> + PERF_REG_POWERPC_SIER2, >> + PERF_REG_POWERPC_SIER3, >> /* Max regs without the extended regs */ >> PERF_REG_POWERPC_MAX =3D PERF_REG_POWERPC_MMCRA + 1, >> }; >> @@ -62,4 +65,7 @@ enum perf_event_powerpc_regs { >> #define PERF_REG_PMU_MASK_300 (((1ULL << (PERF_REG_POWERPC_MMCR2 + = 1)) - 1) \ >> - PERF_REG_PMU_MASK) >>=20 >> +/* PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_31 */ >> +#define PERF_REG_PMU_MASK_31 (((1ULL << = (PERF_REG_POWERPC_SIER3 + 1)) - 1) \ >> + - PERF_REG_PMU_MASK) >=20 > Wrapping that provides no benefit, just let it be long. >=20 Ok, >> #endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */ >> diff --git a/arch/powerpc/perf/perf_regs.c = b/arch/powerpc/perf/perf_regs.c >> index c8a7e8c..c969935 100644 >> --- a/arch/powerpc/perf/perf_regs.c >> +++ b/arch/powerpc/perf/perf_regs.c >> @@ -81,6 +81,12 @@ static u64 get_ext_regs_value(int idx) >> return mfspr(SPRN_MMCR1); >> case PERF_REG_POWERPC_MMCR2: >> return mfspr(SPRN_MMCR2); >> + case PERF_REG_POWERPC_MMCR3: >> + return mfspr(SPRN_MMCR3); >> + case PERF_REG_POWERPC_SIER2: >> + return mfspr(SPRN_SIER2); >> + case PERF_REG_POWERPC_SIER3: >> + return mfspr(SPRN_SIER3); >=20 > Indentation is wrong. >=20 >> default: return 0; >> } >> } >> @@ -89,7 +95,9 @@ u64 perf_reg_value(struct pt_regs *regs, int idx) >> { >> u64 PERF_REG_EXTENDED_MAX; >>=20 >> - if (cpu_has_feature(CPU_FTR_ARCH_300)) >> + if (cpu_has_feature(CPU_FTR_ARCH_31)) >> + PERF_REG_EXTENDED_MAX =3D PERF_REG_POWERPC_SIER3 + 1; >=20 > There's no way to know if that's correct other than going back to the > header to look at the list of values. >=20 > So instead you should define it in the header, next to the other = values, > with a meaningful name, like PERF_REG_MAX_ISA_31 or something. >=20 >> + else if (cpu_has_feature(CPU_FTR_ARCH_300)) >> PERF_REG_EXTENDED_MAX =3D PERF_REG_POWERPC_MMCR2 + 1; >=20 > Same. >=20 Ok, will make this change >> if (idx =3D=3D PERF_REG_POWERPC_SIER && >> diff --git a/arch/powerpc/perf/power10-pmu.c = b/arch/powerpc/perf/power10-pmu.c >> index 07fb919..51082d6 100644 >> --- a/arch/powerpc/perf/power10-pmu.c >> +++ b/arch/powerpc/perf/power10-pmu.c >> @@ -86,6 +86,8 @@ >> #define POWER10_MMCRA_IFM3 0x00000000C0000000UL >> #define POWER10_MMCRA_BHRB_MASK 0x00000000C0000000UL >>=20 >> +extern u64 mask_var; >=20 > Why is it extern? Also not a good name for a global. >=20 > Hang on, it's not even used? Is there some macro magic somewhere? This is defined in patch 8 "powerpc/perf: Add support for outputting = extended regs in perf intr_regs=E2=80=9D,=20 which adds the base support for extended regs in powerpc. Current patch = covers changes to support It for power10.=20 `mask_var` is used to define `PERF_REG_EXTENDED_MASK` at run time.=20 `PERF_REG_EXTENDED_MASK` basically contains mask value of supported = extended registers. And since supported registers may differ between processor versions, we = are defining this mask at runtime. The #define is done in arch/powerpc/include/asm/perf_event_server.h ( in = patch 8 ). In the PMU driver init, we will set the respective mask value ( in the = below code ). Hence it is extern Sorry for the confusion here.=20 Thanks Athira >=20 >> /* Table of alternatives, sorted by column 0 */ >> static const unsigned int power10_event_alternatives[][MAX_ALT] =3D { >> { PM_RUN_CYC_ALT, PM_RUN_CYC }, >> @@ -397,6 +399,7 @@ static void power10_config_bhrb(u64 = pmu_bhrb_filter) >> .cache_events =3D &power10_cache_events, >> .attr_groups =3D power10_pmu_attr_groups, >> .bhrb_nr =3D 32, >> + .capabilities =3D PERF_PMU_CAP_EXTENDED_REGS, >> }; >>=20 >> int init_power10_pmu(void) >> @@ -408,6 +411,9 @@ int init_power10_pmu(void) >> strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power10")) >> return -ENODEV; >>=20 >> + /* Set the PERF_REG_EXTENDED_MASK here */ >> + mask_var =3D PERF_REG_PMU_MASK_31; >> + >> rc =3D register_power_pmu(&power10_pmu); >> if (rc) >> return rc; >=20 >=20 > cheers --Apple-Mail=_E1CE319B-073D-42C4-ABFB-1FE9ADFF87D9 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On 08-Jul-2020, at 5:34 PM, Michael Ellerman <mpe@ellerman.id.au> = wrote:

Athira Rajeev <atrajeev@linux.vnet.ibm.com> writes:
Include capability flag = `PERF_PMU_CAP_EXTENDED_REGS` for power10
and expose MMCR3, = SIER2, SIER3 registers as part of extended regs.
Also = introduce `PERF_REG_PMU_MASK_31` to define extended mask
value at runtime for power10

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---
arch/powerpc/include/uapi/asm/perf_regs.h =       |  6 ++++++
arch/powerpc/perf/perf_regs.c =             &n= bsp;     | 10 +++++++++-
arch/powerpc/perf/power10-pmu.c =             &n= bsp;   |  6 ++++++
tools/arch/powerpc/include/uapi/asm/perf_regs.h |  6 = ++++++
tools/perf/arch/powerpc/include/perf_regs.h =     |  3 +++
tools/perf/arch/powerpc/util/perf_regs.c =        |  6 ++++++

Please split into a kernel patch and a tools patch. And cc = the tools people.

Ok sure

6 files changed, 36 insertions(+), 1 = deletion(-)

diff --git = a/arch/powerpc/include/uapi/asm/perf_regs.h = b/arch/powerpc/include/uapi/asm/perf_regs.h
index = 485b1d5..020b51c 100644
--- = a/arch/powerpc/include/uapi/asm/perf_regs.h
+++ = b/arch/powerpc/include/uapi/asm/perf_regs.h
@@ -52,6 +52,9 = @@ enum perf_event_powerpc_regs {
= PERF_REG_POWERPC_MMCR0,
= PERF_REG_POWERPC_MMCR1,
= PERF_REG_POWERPC_MMCR2,
+ = PERF_REG_POWERPC_MMCR3,
+ = PERF_REG_POWERPC_SIER2,
+ = PERF_REG_POWERPC_SIER3,
/* Max = regs without the extended regs */
= PERF_REG_POWERPC_MAX =3D PERF_REG_POWERPC_MMCRA + 1,
};
@@ -62,4 +65,7 @@ enum = perf_event_powerpc_regs {
#define PERF_REG_PMU_MASK_300 =   (((1ULL << (PERF_REG_POWERPC_MMCR2 + 1)) - 1) \
= = = = - PERF_REG_PMU_MASK)

+/* = PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_31 */
+#define= PERF_REG_PMU_MASK_31 (((1ULL << (PERF_REG_POWERPC_SIER3 + 1)) - 1) \
+ = = = = - PERF_REG_PMU_MASK)

Wrapping that provides no = benefit, just let it be long.


Ok,

#endif = /* _UAPI_ASM_POWERPC_PERF_REGS_H */
diff --git = a/arch/powerpc/perf/perf_regs.c b/arch/powerpc/perf/perf_regs.c
index c8a7e8c..c969935 100644
--- = a/arch/powerpc/perf/perf_regs.c
+++ = b/arch/powerpc/perf/perf_regs.c
@@ -81,6 +81,12 @@ static = u64 get_ext_regs_value(int idx)
return = mfspr(SPRN_MMCR1);
case PERF_REG_POWERPC_MMCR2:
= = return mfspr(SPRN_MMCR2);
+ case = PERF_REG_POWERPC_MMCR3:
+ return mfspr(SPRN_MMCR3);
+ = case PERF_REG_POWERPC_SIER2:
+ return = mfspr(SPRN_SIER2);
+ case PERF_REG_POWERPC_SIER3:
+ = = = return mfspr(SPRN_SIER3);

Indentation is wrong.

default: = return 0;
}
}
@@ = -89,7 +95,9 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)
{
u64 PERF_REG_EXTENDED_MAX;

- if = (cpu_has_feature(CPU_FTR_ARCH_300))
+ if = (cpu_has_feature(CPU_FTR_ARCH_31))
+ = PERF_REG_EXTENDED_MAX =3D PERF_REG_POWERPC_SIER3 + 1;

There's no way to know if that's correct other than going = back to the
header to = look at the list of values.

So instead you should define it in the header, next to the = other values,
with a = meaningful name, like PERF_REG_MAX_ISA_31 or something.

+ else if = (cpu_has_feature(CPU_FTR_ARCH_300))
= PERF_REG_EXTENDED_MAX =3D PERF_REG_POWERPC_MMCR2 + 1;

Same.


Ok, will make this change

if (idx = =3D=3D PERF_REG_POWERPC_SIER &&
diff --git = a/arch/powerpc/perf/power10-pmu.c b/arch/powerpc/perf/power10-pmu.c
index 07fb919..51082d6 100644
--- = a/arch/powerpc/perf/power10-pmu.c
+++ = b/arch/powerpc/perf/power10-pmu.c
@@ -86,6 +86,8 @@
#define POWER10_MMCRA_IFM3 0x00000000C0000000UL
#define POWER10_MMCRA_BHRB_MASK 0x00000000C0000000UL

+extern u64 mask_var;

Why is it extern? Also not a good name for a = global.

Hang on, it's = not even used? Is there some macro magic somewhere?

This is defined = in patch 8 "powerpc/perf: Add support for outputting extended regs in = perf intr_regs=E2=80=9D, 
which adds the base support for = extended regs in powerpc. Current patch covers changes to = support
It for power10. 

`mask_var` is used to define = `PERF_REG_EXTENDED_MASK` at run = time. 
`PERF_REG_EXTENDED_MASK` basically contains mask = value of supported extended registers.
And since supported = registers may differ between processor versions, we are defining this = mask at runtime.

The #define is done = in arch/powerpc/include/asm/perf_event_server.h ( in patch 8 = ).
In the PMU driver init, we will set the respective mask = value ( in the below code ). Hence it is extern

Sorry for the confusion here. 

Thanks
Athira


/* = Table of alternatives, sorted by column 0 */
static const = unsigned int power10_event_alternatives[][MAX_ALT] =3D {
= { PM_RUN_CYC_ALT, PM_RUN_CYC },
@@ = -397,6 +399,7 @@ static void power10_config_bhrb(u64 pmu_bhrb_filter)
= .cache_events =3D &power10_cache_events,
= .attr_groups =3D power10_pmu_attr_groups,
= .bhrb_nr =3D 32,
+ .capabilities =           =3D = PERF_PMU_CAP_EXTENDED_REGS,
};

int init_power10_pmu(void)
@@ -408,6 +411,9 @@ = int init_power10_pmu(void)
    strcmp(cur_= cpu_spec->oprofile_cpu_type, "ppc64/power10"))
return = -ENODEV;

+ /* Set the PERF_REG_EXTENDED_MASK = here */
+ mask_var =3D = PERF_REG_PMU_MASK_31;
+
rc =3D = register_power_pmu(&power10_pmu);
if = (rc)
return rc;


cheers

= --Apple-Mail=_E1CE319B-073D-42C4-ABFB-1FE9ADFF87D9--