linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFCv2 0/4] perf tools: play nicely with CPU PMU cpumasks
@ 2016-07-15 10:08 Mark Rutland
  2016-07-15 10:08 ` [RFCv2 1/4] perf stat: balance opening and reading events Mark Rutland
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Mark Rutland @ 2016-07-15 10:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: acme, adrian.hunter, alexander.shishkin, hekuang, jolsa,
	kan.liang, mark.rutland, mingo, peterz, wangnan0

Hi,

I'm trying to make the perf tool play better with PMUs in heterogeneous systems
(e.g. big.LITTLE). These patches fix some brokenness that exists today, but
they require the addition of a cpumask file to each CPU PMU sysfs directory,
and this happens to break prior versions of perf-stat. Due to this, I have not
yet added a cpumask attribute to the ARM PMU code.

In these system we have separate logical PMUs for discrete sets of CPUs. For
example, on an ARM Juno system we have a logical PMU for all Cortex-A53 CPUs,
and a logical PMU for all the Cortex-A57 CPUs. The logical PMUs allow
task-bound events, but reject CPU-bound events for CPUs they do not cover.

Currently perf-record doesn't work for these PMUs, unless forced to use
per-thread mmaps. In the absence of a cpumask, it tries to open events on CPUs
not supported by a PMU, and gives up. In the presence of a cpumask, it ends up
failing to mmap, as the evlist->cpus map contains a different set of CPUs from
the evsel->cpus map populated from the cpumask.

Today's perf-stat can profile a task in the absence of a cpumask file, but in
the presence of one ends up blocking after the profiled task exits. Due to an
inconsistency between __perf_evsel__open and read_counter, it ends up treating
some uninitialised memory as a file descriptor, and typically ends up blocked
on stdin. That can avoided as in patch 1, but existing binaries would be broken
by the addition of the cpumask kernel-side.

To cater for this, this series adds support for a new PMU sysfs file,
supported_cpus, listing a number of CPUs that a logical PMU covers. As old
binaries will not look for this, this can be safely added to the kernel without
risk of breakage.

Does using a sysfs cpumask to handle (heterogeneous) CPU PMUs feel like the
right approach?

Does it make sense to have a differently-named cpumask file that only new tools
will look at?

Since v1 [1]:
* Avoid double cpu_map__idx() call in perf_evlist__mmap_per_evsel
* Look for a supported_cpumask file when a cpumask file is not present

Thanks,
Mark.

[1] http://lkml.kernel.org/r/1467907474-3290-1-git-send-email-mark.rutland@arm.com

Mark Rutland (4):
  perf stat: balance opening and reading events
  perf: util: Add more cpu_map helpers
  perf: util: only open events on CPUs an evsel permits
  perf: util: support sysfs supported_cpumask file

 tools/perf/builtin-stat.c |  8 ++++++--
 tools/perf/util/cpumap.c  | 14 ++++++++++++--
 tools/perf/util/cpumap.h  |  2 ++
 tools/perf/util/evlist.c  |  8 +++++++-
 tools/perf/util/pmu.c     | 15 ++++++++++++---
 5 files changed, 39 insertions(+), 8 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-07-21  9:49 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-15 10:08 [RFCv2 0/4] perf tools: play nicely with CPU PMU cpumasks Mark Rutland
2016-07-15 10:08 ` [RFCv2 1/4] perf stat: balance opening and reading events Mark Rutland
2016-07-18 14:32   ` Jiri Olsa
2016-07-19  6:53   ` [tip:perf/core] perf stat: Balance " tip-bot for Mark Rutland
2016-07-15 10:08 ` [RFCv2 2/4] perf: util: Add more cpu_map helpers Mark Rutland
2016-07-18 14:32   ` Jiri Olsa
2016-07-19  6:53   ` [tip:perf/core] perf cpu_map: Add more helpers tip-bot for Mark Rutland
2016-07-15 10:08 ` [RFCv2 3/4] perf: util: only open events on CPUs an evsel permits Mark Rutland
2016-07-18 14:32   ` Jiri Olsa
2016-07-18 22:46     ` Arnaldo Carvalho de Melo
2016-07-19  6:20       ` Jiri Olsa
2016-07-15 10:08 ` [RFCv2 4/4] perf: util: support sysfs supported_cpumask file Mark Rutland
2016-07-18 14:30   ` Jiri Olsa
2016-07-18 15:00     ` Mark Rutland
2016-07-21  8:10       ` Jiri Olsa
2016-07-21  9:49         ` Mark Rutland
2016-07-18 16:38   ` Suzuki K Poulose
2016-07-18 17:13     ` Mark Rutland

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).