Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1692989ybs; Tue, 26 May 2020 01:00:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFetMlsLR3wU+n35Sb6skxWy4La0CL3PeWJ3JkXzw/4totxRsB4OHRoZ7VPDFTDHlg6tGC X-Received: by 2002:a17:906:57d6:: with SMTP id u22mr56791ejr.49.1590480022970; Tue, 26 May 2020 01:00:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590480022; cv=none; d=google.com; s=arc-20160816; b=xruW8RKWe1cdckWy4WuNStfK33pTog7I2oemwoq8Jq0U/gowPDlKbS0X+tOu3063/u X0aUJ9Tium7i2Cm2OH9ZZRvE/+tIswS0+qA+eRHk8y+6YnYdmoRt2jJ4xQWYpvgWP+PW UZsACjfdyrjSniiApoLKo6mm93s4qmmHG13ct+ohcpxuJNK+xOrDA8iAsLxt757fh4ct qaW9HcQlRPK00VE5Wz7mknFCv7vU5b6HiEKnT7gYdLnvc4wslJCMd6noiFEPcPxK11Ud gdFHqKvIInR0uFtFNRTs87cCc67eC17/fNZkSkg8R8lqwjShxUGKdzdqnP2spSUvEeKT XUtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ihKBm4c7gP29IClNfH7KHTWnUHd3Qq4IWiaKliPJLaY=; b=QgxgD7t6IuETCgZ8F5099b16TTxasH5ITSD/JUol5LDAkgnMkdYIXI45fKY0ZiTsYN OVQfTbcs4v5mC0UlVwCEr7WNaJhctLEt+lOTa2/RIvSgKyFSTgog6FckDbr58lWP2NsP GaqpoPudY79WhI2mc9s3fiGIWhNhKYDhM6kqj5rX0UKwEwaXFG4sH0hreofaSPohiTVV 7ol972mO+AS40RyiypuqddEyyfs5SUScP8VGIzG0e8iZJGSPvvawBdrd/KfEoXD5rPnG FF0/tkwDoBrjbJmcnrddv9u1lwWNpig9i9qN6OhH2EaWNlKg4YBwZPgIZFhci28KRANN yaxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s4si423685edy.21.2020.05.26.01.00.00; Tue, 26 May 2020 01:00:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731600AbgEZH3j (ORCPT + 99 others); Tue, 26 May 2020 03:29:39 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:16854 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726756AbgEZH3i (ORCPT ); Tue, 26 May 2020 03:29:38 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04Q72X2g170670; Tue, 26 May 2020 03:29:32 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 316yqhu574-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 May 2020 03:29:32 -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 04Q7PARH020020; Tue, 26 May 2020 07:29:30 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 316uf85dha-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 May 2020 07:29:30 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04Q7TS8q8651082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 May 2020 07:29:28 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6B242A405C; Tue, 26 May 2020 07:29:28 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 98F99A405B; Tue, 26 May 2020 07:29:26 +0000 (GMT) Received: from localhost.localdomain (unknown [9.199.55.182]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 May 2020 07:29:26 +0000 (GMT) Subject: Re: [PATCH V3 2/2] tools/perf: Add perf tools support for extended register capability in powerpc To: Athira Rajeev , linuxppc-dev@lists.ozlabs.org Cc: ravi.bangoria@linux.ibm.com, maddy@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, acme@kernel.org, anju@linux.vnet.ibm.com, jolsa@kernel.org References: <1589967933-1503-1-git-send-email-atrajeev@linux.vnet.ibm.com> <1589967933-1503-3-git-send-email-atrajeev@linux.vnet.ibm.com> From: Madhavan Srinivasan Message-ID: <142c15f3-d70a-32f9-49a0-2f250fbf0e7d@linux.ibm.com> Date: Tue, 26 May 2020 12:59:25 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <1589967933-1503-3-git-send-email-atrajeev@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-05-25_12:2020-05-25,2020-05-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 suspectscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 adultscore=0 mlxscore=0 spamscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005260049 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/20/20 3:15 PM, Athira Rajeev wrote: > From: Anju T Sudhakar > > Add extended regs to sample_reg_mask in the tool side to use > with `-I?` option. Perf tools side uses extended mask to display > the platform supported register names (with -I? option) to the user > and also send this mask to the kernel to capture the extended registers > in each sample. Hence decide the mask value based on the processor > version. > > Signed-off-by: Anju T Sudhakar > [Decide extended mask at run time based on platform] > Signed-off-by: Athira Rajeev Reviewed-by: Madhavan Srinivasan > --- > tools/arch/powerpc/include/uapi/asm/perf_regs.h | 14 ++++++- > tools/perf/arch/powerpc/include/perf_regs.h | 5 ++- > tools/perf/arch/powerpc/util/perf_regs.c | 55 +++++++++++++++++++++++++ > 3 files changed, 72 insertions(+), 2 deletions(-) > > diff --git a/tools/arch/powerpc/include/uapi/asm/perf_regs.h b/tools/arch/powerpc/include/uapi/asm/perf_regs.h > index f599064..485b1d5 100644 > --- a/tools/arch/powerpc/include/uapi/asm/perf_regs.h > +++ b/tools/arch/powerpc/include/uapi/asm/perf_regs.h > @@ -48,6 +48,18 @@ enum perf_event_powerpc_regs { > PERF_REG_POWERPC_DSISR, > PERF_REG_POWERPC_SIER, > PERF_REG_POWERPC_MMCRA, > - PERF_REG_POWERPC_MAX, > + /* Extended registers */ > + PERF_REG_POWERPC_MMCR0, > + PERF_REG_POWERPC_MMCR1, > + PERF_REG_POWERPC_MMCR2, > + /* Max regs without the extended regs */ > + PERF_REG_POWERPC_MAX = PERF_REG_POWERPC_MMCRA + 1, > }; > + > +#define PERF_REG_PMU_MASK ((1ULL << PERF_REG_POWERPC_MAX) - 1) > + > +/* PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_300 */ > +#define PERF_REG_PMU_MASK_300 (((1ULL << (PERF_REG_POWERPC_MMCR2 + 1)) - 1) \ > + - PERF_REG_PMU_MASK) > + > #endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */ > diff --git a/tools/perf/arch/powerpc/include/perf_regs.h b/tools/perf/arch/powerpc/include/perf_regs.h > index e18a355..46ed00d 100644 > --- a/tools/perf/arch/powerpc/include/perf_regs.h > +++ b/tools/perf/arch/powerpc/include/perf_regs.h > @@ -64,7 +64,10 @@ > [PERF_REG_POWERPC_DAR] = "dar", > [PERF_REG_POWERPC_DSISR] = "dsisr", > [PERF_REG_POWERPC_SIER] = "sier", > - [PERF_REG_POWERPC_MMCRA] = "mmcra" > + [PERF_REG_POWERPC_MMCRA] = "mmcra", > + [PERF_REG_POWERPC_MMCR0] = "mmcr0", > + [PERF_REG_POWERPC_MMCR1] = "mmcr1", > + [PERF_REG_POWERPC_MMCR2] = "mmcr2", > }; > > static inline const char *perf_reg_name(int id) > diff --git a/tools/perf/arch/powerpc/util/perf_regs.c b/tools/perf/arch/powerpc/util/perf_regs.c > index 0a52429..9179230 100644 > --- a/tools/perf/arch/powerpc/util/perf_regs.c > +++ b/tools/perf/arch/powerpc/util/perf_regs.c > @@ -6,9 +6,14 @@ > > #include "../../../util/perf_regs.h" > #include "../../../util/debug.h" > +#include "../../../util/event.h" > +#include "../../../util/header.h" > +#include "../../../perf-sys.h" > > #include > > +#define PVR_POWER9 0x004E > + > const struct sample_reg sample_reg_masks[] = { > SMPL_REG(r0, PERF_REG_POWERPC_R0), > SMPL_REG(r1, PERF_REG_POWERPC_R1), > @@ -55,6 +60,9 @@ > SMPL_REG(dsisr, PERF_REG_POWERPC_DSISR), > SMPL_REG(sier, PERF_REG_POWERPC_SIER), > SMPL_REG(mmcra, PERF_REG_POWERPC_MMCRA), > + SMPL_REG(mmcr0, PERF_REG_POWERPC_MMCR0), > + SMPL_REG(mmcr1, PERF_REG_POWERPC_MMCR1), > + SMPL_REG(mmcr2, PERF_REG_POWERPC_MMCR2), > SMPL_REG_END > }; > > @@ -163,3 +171,50 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op) > > return SDT_ARG_VALID; > } > + > +uint64_t arch__intr_reg_mask(void) > +{ > + struct perf_event_attr attr = { > + .type = PERF_TYPE_HARDWARE, > + .config = PERF_COUNT_HW_CPU_CYCLES, > + .sample_type = PERF_SAMPLE_REGS_INTR, > + .precise_ip = 1, > + .disabled = 1, > + .exclude_kernel = 1, > + }; > + int fd, ret; > + char buffer[64]; > + u32 version; > + u64 extended_mask = 0; > + > + /* Get the PVR value to set the extended > + * mask specific to platform > + */ > + get_cpuid(buffer, sizeof(buffer)); > + ret = sscanf(buffer, "%u,", &version); > + > + if (ret != 1) { > + pr_debug("Failed to get the processor version, unable to output extended registers\n"); > + return PERF_REGS_MASK; > + } > + > + if (version == PVR_POWER9) > + extended_mask = PERF_REG_PMU_MASK_300; > + else > + return PERF_REGS_MASK; > + > + attr.sample_regs_intr = extended_mask; > + attr.sample_period = 1; > + event_attr_init(&attr); > + > + /* > + * check if the pmu supports perf extended regs, before > + * returning the register mask to sample. > + */ > + fd = sys_perf_event_open(&attr, 0, -1, -1, 0); > + if (fd != -1) { > + close(fd); > + return (extended_mask | PERF_REGS_MASK); > + } > + return PERF_REGS_MASK; > +}