linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/10] perf: Add support for PMU events in JSON format
@ 2015-05-27 21:23 Sukadev Bhattiprolu
  2015-05-27 21:23 ` [PATCH 01/10] perf, tools: Add jsmn `jasmine' JSON parser Sukadev Bhattiprolu
                   ` (11 more replies)
  0 siblings, 12 replies; 24+ messages in thread
From: Sukadev Bhattiprolu @ 2015-05-27 21:23 UTC (permalink / raw)
  To: mingo, ak, Michael Ellerman, Jiri Olsa, Arnaldo Carvalho de Melo,
	Paul Mackerras
  Cc: namhyung, linuxppc-dev, linux-kernel

CPUs support a large number of performance monitoring events (PMU events)
and often these events are very specific to an architecture/model of the
CPU. To use most of these PMU events with perf we currently have to identify
the events by their raw codes:

	perf stat -e r100f2 sleep 1

This patchset allows architectures to specify these PMU events in a JSON
files which are defined in the tools/perf/pmu-events/arch/ directory of
the mainline tree

	Eg: snippet from 004d0100.json (in patch 4)
	[
		
	  {
	    "EventCode": "0x100f2",
	    "EventName": "PM_1PLUS_PPC_CMPL",
	    "BriefDescription": "1 or more ppc insts finished,",
	    "PublicDescription": "1 or more ppc insts finished (completed).,"
	  },
	]

When building the perf tool, this patchset, first builds/uses a 'jevents'
which locates all the JSON files for the architecture (currently Powerpc).
The jevents binary then translates the JSON files into into a C-style
"PMU events table":

	struct pmu_event pme_power8[] = {
		
		...

		{
			.name = "pm_1plus_ppc_cmpl",
			.event = "event=0x100f2",
			.desc = "1 or more ppc insts finished,",
		},

		...
	}

where the "power8" in the table name is derived from the name of the JSON file.

The jevents binary also looks for a "mapfile" to map a processor model/
version to a specific events table:

	$ cat mapfile.csv
	004b0000,1,power8.json,core
	004c0000,1,power8.json,core
	004d0000,1,power8.json,core
	
and uses this to build a mapping table:

	struct pmu_events_map pmu_events_map[] = {
	{
		.cpuid = "004b0000",
		.version = "1",
		.type = "core",
		.table = pme_power8
	},
	
This mapping and events tables for the architecture are then included in
the perf binary during build.

At run time, perf identifies the specific events table, based on the model
of the CPU perf is running on. Perf uses that table to create event aliases
which would allow the user to specify the event as:

	perf stat -e pm_1plus_ppc_cmpl sleep 1

Note:
	- All known events tables for the architecture are included in the
	  perf binary.

	- Inconsistencies between the JSON files and the mapfile can result
	  in build failures in perf (although jevents try to recover from
	  some and continue the build by leaving out event aliases).

	- For architectures that don't have any JSON files, an empty mapping
	  table is created and they should continue to build)

Thanks to input from Andi Kleen, Jiri Olsa, Namhyung Kim and Ingo Molnar.

These patches are available from

	git@github.com:sukadev/linux.git #branch json-v11

Andi Kleen (8):
  perf, tools: Add jsmn `jasmine' JSON parser
  jevents: Program to convert JSON file to C style file
  perf, tools: Handle header line in mapfile
  perf, tools: Allow events with dot
  perf, tools: Support CPU id matching for x86 v2
  perf, tools: Support alias descriptions
  perf, tools: Query terminal width and use in perf list
  perf, tools: Add a --no-desc flag to perf list

Sukadev Bhattiprolu (2):
  Use pmu_events_map table to create event aliases
  perf: Add power8 PMU events in JSON format

 tools/perf/Documentation/perf-list.txt         |    8 +-
 tools/perf/Makefile.perf                       |   25 +-
 tools/perf/arch/powerpc/util/header.c          |   11 +
 tools/perf/arch/x86/util/header.c              |   24 +-
 tools/perf/builtin-list.c                      |   12 +-
 tools/perf/pmu-events/Build                    |   10 +
 tools/perf/pmu-events/README                   |   67 +
 tools/perf/pmu-events/arch/powerpc/mapfile.csv |   17 +
 tools/perf/pmu-events/arch/powerpc/power8.json | 6380 ++++++++++++++++++++++++
 tools/perf/pmu-events/jevents.c                |  686 +++
 tools/perf/pmu-events/jevents.h                |   17 +
 tools/perf/pmu-events/jsmn.c                   |  313 ++
 tools/perf/pmu-events/jsmn.h                   |   67 +
 tools/perf/pmu-events/json.c                   |  162 +
 tools/perf/pmu-events/json.h                   |   36 +
 tools/perf/pmu-events/pmu-events.h             |   35 +
 tools/perf/util/cache.h                        |    1 +
 tools/perf/util/header.h                       |    3 +-
 tools/perf/util/pager.c                        |   15 +
 tools/perf/util/parse-events.c                 |    4 +-
 tools/perf/util/parse-events.h                 |    2 +-
 tools/perf/util/parse-events.l                 |    5 +-
 tools/perf/util/pmu.c                          |  185 +-
 tools/perf/util/pmu.h                          |    3 +-
 24 files changed, 8036 insertions(+), 52 deletions(-)
 create mode 100644 tools/perf/pmu-events/Build
 create mode 100644 tools/perf/pmu-events/README
 create mode 100644 tools/perf/pmu-events/arch/powerpc/mapfile.csv
 create mode 100644 tools/perf/pmu-events/arch/powerpc/power8.json
 create mode 100644 tools/perf/pmu-events/jevents.c
 create mode 100644 tools/perf/pmu-events/jevents.h
 create mode 100644 tools/perf/pmu-events/jsmn.c
 create mode 100644 tools/perf/pmu-events/jsmn.h
 create mode 100644 tools/perf/pmu-events/json.c
 create mode 100644 tools/perf/pmu-events/json.h
 create mode 100644 tools/perf/pmu-events/pmu-events.h

-- 
1.7.9.5

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

end of thread, other threads:[~2015-06-01 10:02 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-27 21:23 [PATCH 0/10] perf: Add support for PMU events in JSON format Sukadev Bhattiprolu
2015-05-27 21:23 ` [PATCH 01/10] perf, tools: Add jsmn `jasmine' JSON parser Sukadev Bhattiprolu
2015-05-27 21:23 ` [PATCH 02/10] jevents: Program to convert JSON file to C style file Sukadev Bhattiprolu
2015-05-28 12:06   ` Jiri Olsa
2015-05-28 12:09   ` Jiri Olsa
2015-05-27 21:23 ` [PATCH 03/10] Use pmu_events_map table to create event aliases Sukadev Bhattiprolu
2015-05-28 12:46   ` Jiri Olsa
2015-05-27 21:23 ` [PATCH 04/10] perf, tools: Handle header line in mapfile Sukadev Bhattiprolu
2015-05-28 12:42   ` Jiri Olsa
2015-05-29  5:45     ` Sukadev Bhattiprolu
2015-05-29  9:13       ` Jiri Olsa
2015-05-30  5:49         ` Andi Kleen
2015-06-01 10:01           ` Jiri Olsa
2015-05-27 21:23 ` [PATCH 05/10] perf, tools: Allow events with dot Sukadev Bhattiprolu
2015-05-27 21:23 ` [PATCH 06/10] perf, tools: Support CPU id matching for x86 v2 Sukadev Bhattiprolu
2015-05-27 21:23 ` [PATCH 07/10] perf, tools: Support alias descriptions Sukadev Bhattiprolu
2015-05-27 21:23 ` [PATCH 08/10] perf, tools: Query terminal width and use in perf list Sukadev Bhattiprolu
2015-05-27 21:23 ` [PATCH 09/10] perf, tools: Add a --no-desc flag to " Sukadev Bhattiprolu
2015-05-28 12:39   ` Jiri Olsa
2015-05-28 18:07     ` Andi Kleen
2015-05-27 21:23 ` [PATCH 10/10] perf: Add power8 PMU events in JSON format Sukadev Bhattiprolu
2015-05-28 11:42 ` [PATCH 0/10] perf: Add support for " Jiri Olsa
2015-05-28 12:43   ` Jiri Olsa
2015-05-28 11:43 ` Jiri Olsa

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