From: Mark Rutland <mark.rutland@arm.com>
To: Shaokun Zhang <zhangshaokun@hisilicon.com>
Cc: Will Deacon <will@kernel.org>, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v5 1/2] arm64: perf: Add support caps in sysfs
Date: Tue, 21 Jul 2020 13:17:16 +0100 [thread overview]
Message-ID: <20200721121716.GB84703@C02TD0UTHF1T.local> (raw)
In-Reply-To: <1595328573-12751-1-git-send-email-zhangshaokun@hisilicon.com>
On Tue, Jul 21, 2020 at 06:49:32PM +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.
>
> Cc: Will Deacon <will@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Shaokun Zhang <zhangshaokun@hisilicon.com>
[...]
> +static int armv8pmu_get_pmu_version(void)
> +{
> + int pmuver;
> + u64 dfr0;
> +
> + dfr0 = read_sysreg(id_aa64dfr0_el1);
> + pmuver = cpuid_feature_extract_unsigned_field(dfr0,
> + ID_AA64DFR0_PMUVER_SHIFT);
> +
> + return pmuver;
> +}
> +
> +static umode_t
> +armv8pmu_caps_attr_is_visible(struct kobject *kobj, struct attribute *attr,
> + int unused)
> +{
> + int pmuver = armv8pmu_get_pmu_version();
> + u32 pmceid1 = read_sysreg(pmceid1_el0);
> +
> + /* Check the PMU version is >= v8.4 and STALL_SLOT is implemented */
> + if (pmuver >= ID_AA64DFR0_PMUVER_8_4 && (pmceid1 & BIT(31)))
> + return attr->mode;
> +
> + return 0;
> +}
> +
> +static ssize_t slots_show(struct device *dev, struct device_attribute *attr,
> + char *buf)
> +{
> + int slots = read_sysreg_s(SYS_PMMIR_EL1) & 0xFF;
> +
> + return snprintf(buf, PAGE_SIZE, "%d\n", slots);
> +}
You'll need to use the snapshots of these fields we take at probe time;
it's not safe to use read_sysreg() here as on a system with
heterogeneous CPUs this code can be running on one CPU while it's
printing information for another CPU.
Mark.
_______________________________________________
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-07-21 12:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-21 7:44 [PATCH v4 1/2] arm64: perf: Add support caps in sysfs Shaokun Zhang
2020-07-21 7:44 ` [PATCH v4 2/2] arm64: perf: Expose some new events via sysfs Shaokun Zhang
2020-07-21 8:21 ` [PATCH v4 1/2] arm64: perf: Add support caps in sysfs Will Deacon
2020-07-21 9:08 ` Shaokun Zhang
2020-07-21 10:49 ` [PATCH v5 " Shaokun Zhang
2020-07-21 10:49 ` [PATCH v5 2/2] arm64: perf: Expose some new events via sysfs Shaokun Zhang
2020-07-21 11:56 ` [PATCH v5 1/2] arm64: perf: Add support caps in sysfs Will Deacon
2020-07-22 2:25 ` Shaokun Zhang
2020-07-21 12:07 ` Will Deacon
2020-07-21 12:24 ` Mark Rutland
2020-07-21 12:17 ` Mark Rutland [this message]
2020-07-22 2:32 ` Shaokun Zhang
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=20200721121716.GB84703@C02TD0UTHF1T.local \
--to=mark.rutland@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=will@kernel.org \
--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