mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC 0/4] perf tool: Adding ratios support
@ 2013-01-15 13:39 Jiri Olsa
  2013-01-15 13:39 ` [PATCH 1/4] perf tool: Remove unused 'unset' parameter from parse_events Jiri Olsa
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Jiri Olsa @ 2013-01-15 13:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Corey Ashford,
	Frederic Weisbecker, Ingo Molnar, Paul Mackerras, Peter Zijlstra,
	Andi Kleen, David Ahern, Ulrich Drepper

hi,
adding support to predefine event ratios formulas so they could
be used easily in perf.

The formulas are handed in the config file with following format:

  set {
        events = {cycles,instructions,branch-instructions}:u

        cpi {
                formula = cycles / instructions
                desc = cycles per instruction
        }

	branch-rate {
                formula = branch-instructions / instructions
                desc = branch rate
        }
  }

  The 'set' defines set of counter that share same events.
  Each 'set' defines:
    events   - event string that would go into stat/record -e option
    counters - any number of counters based on above events

  Each counter (cpi/branch-rate) defines
    formula - formula with that produce the counter number
              event names and numbers could be used
    desc    - text description of the counter

The formula can currently contain any event from the set::events
plus any number (int). There'll be support in future for outside
values runtime and other if needed.

My current thinking is to have generic formulas file(s) for architectural
events and add arch-specific ones once when we have the support for
non-architectural events (already sent RFC, v2 is on its way..).

Example:

With following formula.conf config file:
---
  cpi {
          events = {cycles,instructions}:u

          CPI {
                  formula = cycles / instructions
                  desc = cycles per instruction
          }
  }

  branch {
          events = {instructions,branch-instructions,branch-misses}:u

          branch-rate {
                  formula = branch-instructions / instructions
                  desc = branch rate
          }

          branch-miss-rate {
                  formula = branch-misses / instructions
                  desc = branch misprediction rate
          }

          branch-miss-ratio{
                  formula = branch-misses / branch-instructions
                  desc = branch misprediction ratio
          }
  }
---

You'll get following result:

  $ perf stat -f formula.conf:branch kill
  usage: kill [ -s signal | -p ] [ -a ] pid ...
         kill -l [ signal ]

   Performance counter stats for 'kill':

             184,195 instructions              #    0.00  insns per cycle
              40,907 branch-instructions
               4,815 branch-misses             #   11.77% of all branches

         0.000655767 seconds time elapsed

          0.22208529 branch-rate               #  branch rate
          0.02614077 branch-miss-rate          #  branch misprediction rate
          0.11770602 branch-miss-ratio         #  branch misprediction ratio

  $ perf stat -f formula.conf:cpi kill
  usage: kill [ -s signal | -p ] [ -a ] pid ...
         kill -l [ signal ]

   Performance counter stats for 'kill':

             356,635 cycles                    #    0.000 GHz
             187,191 instructions              #    0.52  insns per cycle

         0.001907600 seconds time elapsed

          1.90519309 CPI                       #  cycles per instruction


Available also at:
  git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/linux.git
  perf/ratios2


thanks for any ideas,
jirka

Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ulrich Drepper <drepper@gmail.com>
---
 tools/perf/Makefile                     |  11 +++
 tools/perf/builtin-stat.c               |  61 ++++++++++++++-
 tools/perf/formula.conf                 |  28 +++++++
 tools/perf/tests/evsel-roundtrip-name.c |   4 +-
 tools/perf/tests/hists_link.c           |   4 +-
 tools/perf/tests/parse-events.c         |   2 +-
 tools/perf/util/evlist.c                |  13 ++++
 tools/perf/util/evlist.h                |   4 +
 tools/perf/util/formula.c               | 387 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/formula.h               | 113 +++++++++++++++++++++++++++
 tools/perf/util/formula.l               | 119 ++++++++++++++++++++++++++++
 tools/perf/util/formula.y               | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/parse-events.c          |   5 +-
 tools/perf/util/parse-events.h          |   3 +-
 14 files changed, 991 insertions(+), 11 deletions(-)


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

end of thread, other threads:[~2013-01-25 11:53 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-15 13:39 [RFC 0/4] perf tool: Adding ratios support Jiri Olsa
2013-01-15 13:39 ` [PATCH 1/4] perf tool: Remove unused 'unset' parameter from parse_events Jiri Olsa
2013-01-25 11:52   ` [tip:perf/core] perf tools: " tip-bot for Jiri Olsa
2013-01-15 13:39 ` [PATCH 2/4] perf tool: Add formula interface to interface ratio definitions Jiri Olsa
2013-01-15 13:39 ` [PATCH 3/4] perf stat: Adding -f option to load and process ratios Jiri Olsa
2013-01-15 13:39 ` [PATCH 4/4] perf tool: Adding formula.conf file for testing Jiri Olsa
2013-01-16 13:13 ` [RFC 0/4] perf tool: Adding ratios support Will Deacon
2013-01-16 13:30   ` Jiri Olsa
2013-01-17 10:23     ` Will Deacon
2013-01-21 19:13       ` Jiri Olsa
2013-01-22  9:45         ` Will Deacon
2013-01-16 14:00 ` Ulrich Drepper
2013-01-16 14:25   ` Jiri Olsa
2013-01-16 15:12     ` Ulrich Drepper
2013-01-17  1:03       ` Namhyung Kim
2013-01-17 16:05         ` Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome