linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFCv4 5/7] drivers/perf: arm_pmu: expose a cpumask in sysfs
Date: Fri, 9 Sep 2016 11:24:43 +0100	[thread overview]
Message-ID: <20160909102443.GE20192@arm.com> (raw)
In-Reply-To: <1473330112-28528-6-git-send-email-mark.rutland@arm.com>

On Thu, Sep 08, 2016 at 11:21:50AM +0100, Mark Rutland wrote:
> In systems with heterogeneous CPUs, there are multiple logical CPU PMUs,
> each of which covers a subset of CPUs in the system. In some cases
> userspace needs to know which CPUs a given logical PMU covers, so we'd
> like to expose a cpumask under sysfs, similar to what is done for uncore
> PMUs.
> 
> Unfortunately, prior to commit 00e727bb389359c8 ("perf stat: Balance
> opening and reading events"), perf stat only correctly handled a cpumask
> holding a single CPU, and only when profiling in system-wide mode. In
> other cases, the presence of a cpumask file could cause perf stat to
> behave erratically.
> 
> Thus, exposing a cpumask file would break older perf binaries in cases
> where they would otherwise work.
> 
> To avoid this issue while still providing userspace with the information
> it needs, this patch exposes a differently-named file (cpus) under
> sysfs. New tools can look for this and operate correctly, while older
> tools will not be adversely affected by its presence.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> ---
>  drivers/perf/arm_pmu.c       | 21 +++++++++++++++++++++
>  include/linux/perf/arm_pmu.h |  1 +
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c
> index ac83e1e..09e9944 100644
> --- a/drivers/perf/arm_pmu.c
> +++ b/drivers/perf/arm_pmu.c
> @@ -534,6 +534,25 @@ static int armpmu_filter_match(struct perf_event *event)
>  	return cpumask_test_cpu(cpu, &armpmu->supported_cpus);
>  }
>  
> +static ssize_t armpmu_cpumask_show(struct device *dev,
> +				   struct device_attribute *attr, char *buf)
> +{
> +	struct arm_pmu *armpmu = to_arm_pmu(dev_get_drvdata(dev));
> +	return cpumap_print_to_pagebuf(true, buf, &armpmu->supported_cpus);
> +}
> +
> +static struct device_attribute armpmu_cpumask_attr =
> +		__ATTR(cpus, S_IRUGO, armpmu_cpumask_show, NULL);

You can use the DEVICE_ATTR macro for this.

Will

  reply	other threads:[~2016-09-09 10:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-08 10:21 [RFCv4 0/7] arm_pmu/perf tools: play nicely with CPU PMU cpumasks Mark Rutland
2016-09-08 10:21 ` [RFCv4 1/7] drivers/perf: arm_pmu: add common attr group fields Mark Rutland
2016-09-09 10:25   ` Will Deacon
2016-09-09 11:05     ` Mark Rutland
2016-09-08 10:21 ` [RFCv4 2/7] arm64: perf: move to common attr_group fields Mark Rutland
2016-09-08 10:21 ` [RFCv4 3/7] arm: " Mark Rutland
2016-09-08 10:21 ` [RFCv4 4/7] drivers/perf: arm_pmu: only use common attr_groups Mark Rutland
2016-09-08 10:21 ` [RFCv4 5/7] drivers/perf: arm_pmu: expose a cpumask in sysfs Mark Rutland
2016-09-09 10:24   ` Will Deacon [this message]
2016-09-09 11:04     ` Mark Rutland
2016-09-08 10:21 ` [RFCv4 6/7] perf: util: only open events on CPUs an evsel permits Mark Rutland
2016-09-08 10:21 ` [RFCv4 7/7] perf: util: support alternative sysfs cpumask Mark Rutland
2016-09-08 10:38 ` [RFCv4 0/7] arm_pmu/perf tools: play nicely with CPU PMU cpumasks Will Deacon
2016-09-08 11:29   ` Mark Rutland
2016-09-08 16:25 ` Arnaldo Carvalho de Melo
2016-09-08 18:16   ` Peter Zijlstra
2016-09-09  9:31     ` 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=20160909102443.GE20192@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).