[PATCH v4 0/5] perf script: Add general event support to event handler of python script

From: Feng Tang
Date: Thu Jun 28 2012 - 05:20:25 EST


Hi all,

Current python script can only handle trace point type of events, this
patch serie try to follow Robert Richter's idea in commit 37a058ea0
"perf script: Add generic perl handler to process events"
to similarly add a python handler for general events other than
trace points.

Also in v4, we added 2 RFC python scripts: EventClass.py as a libary and
event_analyzing_sample.py as a sample to show to handle the general
events.

Here is a sample output of using the 2 scripts:

feng@feng-i7:/dev/shm$perf record -a tree
feng@feng-i7:/dev/shm$perf script -s process_event.py

One note for the histgram is: the sample number may be very large,
so we print out '#' log2(num) times for each number.

---------------------------------
There is 100 records in gen_events table
Statistics about the general events grouped by thread/symbol/dso:

comm number histgram
==========================================
swapper 56 ######
tree 20 #####
perf 10 ####
sshd 8 ####
kworker/7:2 4 ###
ksoftirqd/7 1 #
plugin-containe 1 #

symbol number histgram
==========================================================
native_write_msr_safe 40 ######
__lock_acquire 8 ####
ftrace_graph_caller 4 ###
prepare_ftrace_return 4 ###
intel_idle 3 ##
native_sched_clock 3 ##
Unknown_symbol 2 ##
do_softirq 2 ##
lock_release 2 ##
lock_release_holdtime 2 ##
trace_graph_entry 2 ##
_IO_putc 1 #
__d_lookup_rcu 1 #
__do_fault 1 #
__schedule 1 #
_raw_spin_lock 1 #
delay_tsc 1 #
generic_exec_single 1 #
generic_fillattr 1 #

dso number histgram
==================================================================
[kernel.kallsyms] 95 #######
/lib/libc-2.12.1.so 5 ###

Thanks,
Feng

Feng Tang (5):
perf script: Add general python handler to process non-tracepoint
events
perf script: Replace "struct thread" with "struct addr_location" as a
parameter for "process_event()"
perf script/python: Pass event/thread/dso name and symbol info to
event handler in python
perf script: Add a python library EventClass.py
perf script: Add event_analyzing_sample.py as a sample for general
event handling

tools/perf/builtin-script.c | 5 +-
.../Perf-Trace-Util/lib/Perf/Trace/EventClass.py | 95 ++++++++++
.../perf/scripts/python/event_analyzing_sample.py | 193 ++++++++++++++++++++
.../perf/util/scripting-engines/trace-event-perl.c | 13 +-
.../util/scripting-engines/trace-event-python.c | 95 +++++++++-
tools/perf/util/trace-event-scripting.c | 2 +-
tools/perf/util/trace-event.h | 5 +-
7 files changed, 391 insertions(+), 17 deletions(-)
create mode 100755 tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/EventClass.py
create mode 100644 tools/perf/scripts/python/event_analyzing_sample.py

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/