From: Will Deacon <will@kernel.org>
To: Shaokun Zhang <zhangshaokun@hisilicon.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v7] arm64: perf: Add support caps in sysfs
Date: Mon, 21 Sep 2020 22:01:56 +0100 [thread overview]
Message-ID: <20200921210156.GD3811@willie-the-truck> (raw)
In-Reply-To: <1599898042-10635-1-git-send-email-zhangshaokun@hisilicon.com>
On Sat, Sep 12, 2020 at 04:07:22PM +0800, Shaokun Zhang wrote:
> ARMv8.4-PMU introduces the PMMIR_EL1 registers and some new PMU events,
> like STALL_SLOT etc, are related to it. Let's add a caps directory to
> /sys/bus/event_source/devices/armv8_pmuv3_0/ and support slots from
> PMMIR_EL1 registers in this entry. The user programs can get the slots
> from sysfs directly.
>
> /sys/bus/event_source/devices/armv8_pmuv3_0/caps/slots is exposed
> through sysfs. Both ARMv8.4-PMU and STALL_SLOT event are implemented,
> it returns the slots from PMMIR_EL1, otherwise it will return 0.
>
> Cc: Will Deacon <will@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Shaokun Zhang <zhangshaokun@hisilicon.com>
> ---
> ChangeLog in v7:
> * If this feature is not supported, return 0.
[...]
> arch/arm64/include/asm/perf_event.h | 3 ++
> arch/arm64/include/asm/sysreg.h | 2 +
> arch/arm64/kernel/perf_event.c | 103 ++++++++++++++++++++++++------------
> include/linux/perf/arm_pmu.h | 3 ++
> 4 files changed, 78 insertions(+), 33 deletions(-)
>
> diff --git a/arch/arm64/include/asm/perf_event.h b/arch/arm64/include/asm/perf_event.h
> index 2c2d7dbe8a02..60731f602d3e 100644
> --- a/arch/arm64/include/asm/perf_event.h
> +++ b/arch/arm64/include/asm/perf_event.h
> @@ -236,6 +236,9 @@
> #define ARMV8_PMU_USERENR_CR (1 << 2) /* Cycle counter can be read at EL0 */
> #define ARMV8_PMU_USERENR_ER (1 << 3) /* Event counter can be read at EL0 */
>
> +/* PMMIR_EL1.SLOTS mask */
> +#define ARMV8_PMU_SLOTS_MASK 0xff
> +
> #ifdef CONFIG_PERF_EVENTS
> struct pt_regs;
> extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
> diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
> index 554a7e8ecb07..921773adff5e 100644
> --- a/arch/arm64/include/asm/sysreg.h
> +++ b/arch/arm64/include/asm/sysreg.h
> @@ -321,6 +321,8 @@
> #define SYS_PMINTENSET_EL1 sys_reg(3, 0, 9, 14, 1)
> #define SYS_PMINTENCLR_EL1 sys_reg(3, 0, 9, 14, 2)
>
> +#define SYS_PMMIR_EL1 sys_reg(3, 0, 9, 14, 6)
> +
> #define SYS_MAIR_EL1 sys_reg(3, 0, 10, 2, 0)
> #define SYS_AMAIR_EL1 sys_reg(3, 0, 10, 3, 0)
>
> diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
> index 462f9a9cc44b..953d92145908 100644
> --- a/arch/arm64/kernel/perf_event.c
> +++ b/arch/arm64/kernel/perf_event.c
> @@ -302,6 +302,28 @@ static struct attribute_group armv8_pmuv3_format_attr_group = {
> .attrs = armv8_pmuv3_format_attrs,
> };
>
> +static ssize_t slots_show(struct device *dev, struct device_attribute *attr,
> + char *page)
> +{
> + struct pmu *pmu = dev_get_drvdata(dev);
> + struct arm_pmu *cpu_pmu = container_of(pmu, struct arm_pmu, pmu);
> + int slots = cpu_pmu->reg_pmmir & ARMV8_PMU_SLOTS_MASK;
> +
> + return snprintf(page, PAGE_SIZE, "0x%02x\n", slots);
I'm a little bit nervous about %02x here, as future versions of the
architecture could extend PMMIR.SLOTS and parsers would have a bit of a
rotten time dealing with the new immediates. Why don't we just make it
%08x instead, and have 'int slots' be 'u32 slots'?
Otherwise patch looks fine, thanks. Happy to apply a new version with that
change.
Will
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-09-21 21:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-12 8:07 [PATCH v7] arm64: perf: Add support caps in sysfs Shaokun Zhang
2020-09-21 21:01 ` Will Deacon [this message]
2020-09-22 5:53 ` [PATCH v8] arm64: perf: Add support caps under sysfs Shaokun Zhang
2020-09-28 22:13 ` Will Deacon
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=20200921210156.GD3811@willie-the-truck \
--to=will@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=zhangshaokun@hisilicon.com \
/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