linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 00/21] perf tools: Add toggling events support
@ 2013-09-25 12:50 Jiri Olsa
  2013-09-25 12:50 ` [PATCH 01/21] perf tools: Introduce perf_evlist__wait_workload function Jiri Olsa
                   ` (22 more replies)
  0 siblings, 23 replies; 35+ messages in thread
From: Jiri Olsa @ 2013-09-25 12:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Corey Ashford,
	Frederic Weisbecker, Ingo Molnar, Paul Mackerras, Peter Zijlstra,
	Don Zickus, Andi Kleen, Adrian Hunter, Stephane Eranian

hi,
sending *RFC* for toggling events support.

Adding perf interface that allows to create toggle events, which can
enable or disable another event. Whenever the toggle event is triggered
(has overflow), it toggles another event state and either starts or
stops it.

The goal is to be able to create toggling tracepoint events to enable and
disable HW counters, but the interface is generic enough to be used for
any kind of event. 

It's based on the Frederic's patchset:
https://lkml.org/lkml/2011/3/14/346

Most of the changelogs info is on wiki:
https://perf.wiki.kernel.org/index.php/Jolsa_Features_Togle_Event

In a nutshell:
  The interface is added to the sys_perf_event_open syscall
  and new ioctl was added for completeness, check:
    perf: Add event toggle sys_perf_event_open interface
    perf: Add event toggle ioctl interface

  The perf tool interface is pretty rough at the moment. We use
  'on' and 'off' terms to specify the toggling event, like:
    -e 'cycles,irq_entry/on=cycles/,irq_exit/off=cycles/'

  Meaning:
    - irq_entry toggles on (starts) cycles, and irq_exit toggled off (stops) cycles.
    - cycles is started as paused 

   Looking forward to some ideas for better interface in here ;-)

The patchset is available at:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/core_toggle

thanks for comments,
jirka


Example:
  Define toggle(on/off) events: 
    # perf probe -a fork_entry=do_fork
    # perf probe -a fork_exit=do_fork%return

  Following record session samples only within do_fork function: 
    # perf record -g -e '{cycles,cache-misses}:k,probe:fork_entry/on=cycles/,probe:fork_exit/off=cycles/' \ 
      perf bench sched messaging

  Following stat session measure cycles within do_fork function: 
    # perf stat -e '{cycles,cache-misses}:k,probe:fork_entry/on=cycles/,probe:fork_exit/off=cycles/' \ 
      perf bench sched messaging

      # Running sched/messaging benchmark...
      # 20 sender and receiver processes per group
      # 1 groups == 40 processes run

           Total time: 0.073 [sec]

       Performance counter stats for './perf bench sched messaging -g 1':

              20,935,464 cycles                    #    0.000 GHz
                  18,897 cache-misses
                      40 probe:fork_entry
                      40 probe:fork_exit

             0.086319682 seconds time elapsed

Example:
  Measure interrupts cycles:
  # ./perf stat -e 'cycles,cycles/name=cycles_irq/,irq:irq_handler_entry/on=cycles_irq/,irq:irq_handler_exit/off=cycles_irq/' -a sleep 10

   Performance counter stats for 'sleep 10':

      50,680,084,994 cycles                    #    0.000 GHz                     [100.00%]
             652,690 cycles_irq                #    0.000 GHz                    
                  33 irq:irq_handler_entry                                        [100.00%]
                  33 irq:irq_handler_exit                                        

        10.002084400 seconds time elapsed

Check uprobes example at:
https://perf.wiki.kernel.org/index.php/Jolsa_Features_Togle_Event#Example_-_using_u.28ret.29probes


Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Andi Kleen <ak@linux.jf.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Stephane Eranian <eranian@google.com>
---
Frederic Weisbecker (2):
      perf: Be more specific on pmu related event init naming
      perf: Split allocation and initialization code

Jiri Olsa (19):
      perf tools: Introduce perf_evlist__wait_workload function
      perf tools: Separate sys_perf_event_open call into evsel_open
      perf x86: Update event count properly for read syscall
      perf: Move event state initialization before/behind the pmu add/del calls
      perf: Add event toggle sys_perf_event_open interface
      perf: Add event toggle ioctl interface
      perf: Toggle whole group in toggle event overflow
      perf: Add new 'paused' attribute
      perf: Account toggle masters for toggled event
      perf: Support event inheritance for toggle feature
      perf tests: Adding event simple toggling test
      perf tests: Adding event group toggling test
      perf tests: Adding event inherit toggling test
      perf tools: Allow numeric event to change name via name term
      perf tools: Add event_config_optional parsing rule
      perf tools: Rename term related parsing function/variable properly
      perf tools: Carry term string value for symbols events
      perf tools: Add support to parse event on/off toggle terms
      perf tools: Add record/stat support for toggling events

 arch/x86/kernel/cpu/perf_event.c                |   6 +-
 include/linux/perf_event.h                      |  12 +++
 include/uapi/linux/perf_event.h                 |   7 +-
 kernel/events/core.c                            | 396 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
 tools/perf/Makefile                             |   6 ++
 tools/perf/arch/x86/tests/toggle-event-raw-64.S |  28 ++++++
 tools/perf/builtin-record.c                     |   7 ++
 tools/perf/builtin-stat.c                       |  12 +++
 tools/perf/tests/builtin-test.c                 |  12 +++
 tools/perf/tests/perf-record.c                  |   1 +
 tools/perf/tests/task-exit.c                    |   5 ++
 tools/perf/tests/tests.h                        |   3 +
 tools/perf/tests/toggle-event-group.c           | 195 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/tests/toggle-event-inherit.c         | 132 ++++++++++++++++++++++++++++
 tools/perf/tests/toggle-event-raw.c             | 106 ++++++++++++++++++++++
 tools/perf/util/evlist.c                        |  97 +++++++++++++++++++++
 tools/perf/util/evlist.h                        |   3 +
 tools/perf/util/evsel.c                         |  53 ++++++-----
 tools/perf/util/evsel.h                         |   4 +
 tools/perf/util/parse-events.c                  | 131 +++++++++++++++++++---------
 tools/perf/util/parse-events.h                  |   9 +-
 tools/perf/util/parse-events.l                  |   6 +-
 tools/perf/util/parse-events.y                  |  68 +++++++++------
 tools/perf/util/record.c                        |   2 +
 24 files changed, 1167 insertions(+), 134 deletions(-)
 create mode 100644 tools/perf/arch/x86/tests/toggle-event-raw-64.S
 create mode 100644 tools/perf/tests/toggle-event-group.c
 create mode 100644 tools/perf/tests/toggle-event-inherit.c
 create mode 100644 tools/perf/tests/toggle-event-raw.c

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

end of thread, other threads:[~2013-09-26 15:45 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-25 12:50 [RFC 00/21] perf tools: Add toggling events support Jiri Olsa
2013-09-25 12:50 ` [PATCH 01/21] perf tools: Introduce perf_evlist__wait_workload function Jiri Olsa
2013-09-25 12:50 ` [PATCH 02/21] perf tools: Separate sys_perf_event_open call into evsel_open Jiri Olsa
2013-09-25 12:50 ` [PATCH 03/21] perf x86: Update event count properly for read syscall Jiri Olsa
2013-09-25 12:50 ` [PATCH 04/21] perf: Move event state initialization before/behind the pmu add/del calls Jiri Olsa
2013-09-25 12:50 ` [PATCH 05/21] perf: Add event toggle sys_perf_event_open interface Jiri Olsa
2013-09-25 22:36   ` Sukadev Bhattiprolu
2013-09-26 12:27     ` Jiri Olsa
2013-09-25 12:50 ` [PATCH 06/21] perf: Add event toggle ioctl interface Jiri Olsa
2013-09-25 19:46   ` Vince Weaver
2013-09-26 12:30     ` Jiri Olsa
2013-09-26 13:03       ` Vince Weaver
2013-09-25 12:50 ` [PATCH 07/21] perf: Toggle whole group in toggle event overflow Jiri Olsa
2013-09-25 12:50 ` [PATCH 08/21] perf: Add new 'paused' attribute Jiri Olsa
2013-09-25 22:41   ` Sukadev Bhattiprolu
2013-09-26 12:24     ` Jiri Olsa
2013-09-25 12:50 ` [PATCH 09/21] perf: Account toggle masters for toggled event Jiri Olsa
2013-09-25 12:50 ` [PATCH 10/21] perf: Be more specific on pmu related event init naming Jiri Olsa
2013-09-25 12:50 ` [PATCH 11/21] perf: Split allocation and initialization code Jiri Olsa
2013-09-25 12:50 ` [PATCH 12/21] perf: Support event inheritance for toggle feature Jiri Olsa
2013-09-25 12:50 ` [PATCH 13/21] perf tests: Adding event simple toggling test Jiri Olsa
2013-09-25 12:50 ` [PATCH 14/21] perf tests: Adding event group " Jiri Olsa
2013-09-25 12:50 ` [PATCH 15/21] perf tests: Adding event inherit " Jiri Olsa
2013-09-25 12:50 ` [PATCH 16/21] perf tools: Allow numeric event to change name via name term Jiri Olsa
2013-09-25 12:50 ` [PATCH 17/21] perf tools: Add event_config_optional parsing rule Jiri Olsa
2013-09-25 12:50 ` [PATCH 18/21] perf tools: Rename term related parsing function/variable properly Jiri Olsa
2013-09-25 12:50 ` [PATCH 19/21] perf tools: Carry term string value for symbols events Jiri Olsa
2013-09-25 12:50 ` [PATCH 20/21] perf tools: Add support to parse event on/off toggle terms Jiri Olsa
2013-09-25 12:50 ` [PATCH 21/21] perf tools: Add record/stat support for toggling events Jiri Olsa
2013-09-25 19:12 ` [RFC 00/21] perf tools: Add toggling events support Andi Kleen
2013-09-26  7:03   ` Ingo Molnar
2013-09-26 15:45     ` Andi Kleen
2013-09-26 12:11   ` Jiri Olsa
2013-09-26 11:31 ` Stephane Eranian
2013-09-26 12:20   ` 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).