perf script python: Allow reporting the [un]throttle PERF_RECORD_ meta event
perf_events may sometimes throttle an event due to creating too many
samples during a given timer tick.
As of now, the perf tool will not report on throttling, which means this
is a silent error.
Implement a callback for the throttle and unthrottle events within the
Python scripting engine, which can allow scripts to detect and report
when events may have been lost due to throttling.
The simplest script to report throttle events is:
def throttle(*args):
print("throttle" + repr(args))
def unthrottle(*args):
print("unthrottle" + repr(args))
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20210901210815.133251-1-stephen.s.brennan@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
71f7f897c3
commit
538d9c1829
@@ -2492,6 +2492,17 @@ process_lost_event(struct perf_tool *tool,
|
||||
sample->tid);
|
||||
}
|
||||
|
||||
static int
|
||||
process_throttle_event(struct perf_tool *tool __maybe_unused,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct machine *machine)
|
||||
{
|
||||
if (scripting_ops && scripting_ops->process_throttle)
|
||||
scripting_ops->process_throttle(event, sample, machine);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
process_finished_round_event(struct perf_tool *tool __maybe_unused,
|
||||
union perf_event *event,
|
||||
@@ -3652,6 +3663,8 @@ int cmd_script(int argc, const char **argv)
|
||||
.stat_config = process_stat_config_event,
|
||||
.thread_map = process_thread_map_event,
|
||||
.cpu_map = process_cpu_map_event,
|
||||
.throttle = process_throttle_event,
|
||||
.unthrottle = process_throttle_event,
|
||||
.ordered_events = true,
|
||||
.ordering_requires_timestamps = true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user