perf/core new feature: 'perf stat record/report'
Arnaldo Carvalho de Melo
maintainerFrom: Arnaldo Carvalho de Melo <[email protected]>
Hi Ingo,
Please consider pulling, cool new feature! This is on top of the
perf-core-for-mingo-2.1 tag, with that RHEL6.7 bugfix, I had also to go over this one fixing stuff in many spots :-\
- Arnaldo
The following changes since commit 1843b4e057b7717db21a3ad96fa16d6b4ee8f6c4:
tools subcmd: Rename subcmd header include guards (2015-12-17 14:27:14 -0300)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-3
for you to fetch changes up to 89af4e05c21d68f22e07fe66940ea675615a49ed:
perf stat report: Allow to override aggr_mode (2015-12-17 16:30:30 -0300)
----------------------------------------------------------------
perf/core improvement.
User visible:
- Generate perf.data files from 'perf stat', to tap into the scripting capabilities perf has instead of defining a 'perf stat' specific scripting support to calculate event ratios, etc. Simple example:
$ perf stat record -e cycles usleep 1
Performance counter stats for 'usleep 1':
1,134,996 cycles
0.000670644 seconds time elapsed$ perf stat report
Performance counter stats for '/home/acme/bin/perf stat record -e cycles usleep 1':
1,134,996 cycles
0.000670644 seconds time elapsed$
It generates PERF_RECORD_ userspace records to store the details:
$ perf report -D | grep PERF_RECORD 0xf0 [0x28]: PERF_RECORD_THREAD_MAP nr: 1 thread: 27637 0x118 [0x12]: PERF_RECORD_CPU_MAP nr: 1 cpu: 65535 0x12a [0x40]: PERF_RECORD_STAT_CONFIG 0x16a [0x30]: PERF_RECORD_STAT -1 -1 0x19a [0x40]: PERF_RECORD_MMAP -1/0: [0xffffffff81000000(0x1f000000) @ 0xffffffff81000000]: x [kernel.kallsyms]_text 0x1da [0x18]: PERF_RECORD_STAT_ROUND [acme@ssdandy linux]$
An effort was made to make perf.data files generated like this to not generate cryptic messages when processed by older tools.
The 'perf script' bits need rebasing, will go up later.
Jiri's cover letter for this series:
The initial attempt defined its own formula lang and allowed triggering user's script on the end of the stat command:
http://marc.info/?l=linux-kernel&m=136742146322273&w=2
This patchset abandons the idea of new formula language and rather adds support to:
- store stat data into perf.data file
- add python support to process stat events
Basically it allows to store stat data into perf.data and post process it with python scripts in a similar way we do for sampling data.
The stat data are stored in new stat, stat-round, stat-config user events.
stat - stored for each read syscall of the counter
stat round - stored for each interval or end of the command invocation stat config - stores all the config information needed to process data
so report tool could restore the same output as record
The python script can now define 'stat__<eventname>_<modifier>' functions to get stat events data and 'stat__interval' to get stat-round data.
See CPI script example in scripts/python/stat-cpi.py.
----------------------------------------------------------------
Jiri Olsa (43):
perf thread_map: Add thread_map user level event
perf thread_map: Add thread_map event sythesize function perf thread_map: Add thread_map__new_event function perf thread_map: Add perf_event__fprintf_thread_map function perf cpu_map: Add cpu_map user level event
perf cpu_map: Add cpu_map event synthesize function perf cpu_map: Add cpu_map__new_event function
perf cpu_map: Add perf_event__fprintf_cpu_map function perf tools: Add stat config user level event
perf tools: Add stat config event synthesize function perf tools: Add stat config event read function
perf tools: Add stat user level event
perf tools: Add stat event synthesize function
perf tools: Add stat event read function
perf tools: Add stat round user level event
perf tools: Add stat round event synthesize function perf tools: Add stat events fprintf functions
perf tools: Add event_update user level event
perf tools: Add event_update event unit type
perf tools: Add event_update event scale type
perf tools: Add event_update event name type
perf tools: Add event_update event cpus type
perf tools: Add perf_event__fprintf_event_update function perf report: Display newly added events in raw dump perf tools: Introduce stat perf.data header feature perf stat record: Add record command
perf stat record: Initialize record features
perf stat record: Synthesize stat record data
perf evlist: Export id_add_fd()
perf stat record: Store events IDs in perf data file perf stat record: Add pipe support for record command perf stat record: Write stat events on record
perf stat record: Write stat round events on record perf stat record: Do not allow record with multiple runs mode perf stat record: Synthesize event update events
perf stat report: Add report command
perf stat report: Process cpu/threads maps
perf stat report: Process stat config event
perf stat report: Add support to initialize aggr_map from file perf stat report: Move csv_sep initialization before report command perf stat report: Process stat and stat round events perf stat report: Process event update events
perf stat report: Allow to override aggr_mode
tools/perf/Documentation/perf-stat.txt | 34 ++ tools/perf/builtin-record.c | 2 + tools/perf/builtin-stat.c | 614 ++++++++++++++++++++++++++++++++- tools/perf/tests/Build | 3 + tools/perf/tests/builtin-test.c | 24 ++ tools/perf/tests/cpumap.c | 88 +++++ tools/perf/tests/event_update.c | 117 +++++++ tools/perf/tests/stat.c | 111 ++++++ tools/perf/tests/tests.h | 6 + tools/perf/tests/thread-map.c | 43 +++ tools/perf/util/cpumap.c | 42 +++ tools/perf/util/cpumap.h | 1 + tools/perf/util/event.c | 308 +++++++++++++++++ tools/perf/util/event.h | 150 +++++++- tools/perf/util/evlist.c | 6 +- tools/perf/util/evlist.h | 3 + tools/perf/util/header.c | 205 +++++++++++ tools/perf/util/header.h | 17 + tools/perf/util/session.c | 189 ++++++++++ tools/perf/util/stat.c | 62 ++++ tools/perf/util/stat.h | 10 + tools/perf/util/thread_map.c | 27 ++ tools/perf/util/thread_map.h | 3 + tools/perf/util/tool.h | 8 +- 24 files changed, 2054 insertions(+), 19 deletions(-) create mode 100644 tools/perf/tests/cpumap.c create mode 100644 tools/perf/tests/event_update.c create mode 100644 tools/perf/tests/stat.c
Arnaldo Carvalho de Melo
maintainerPATCH 1/43 perf thread_map: Add thread_map user level event
From: Jiri Olsa <[email protected]>
Adding the thread_map event to pass/store thread maps as data in the pipe/perf.data.
Storing the thread ID along with the standard comm[16] thread name string.
--- tools/perf/util/event.c | 1 + tools/perf/util/event.h | 13 +++++++++++++ tools/perf/util/session.c | 26 ++++++++++++++++++++++++++ tools/perf/util/tool.h | 3 ++- 4 files changed, 42 insertions(+), 1 deletion(-)
tools/perf/util/event.c +1 -0
@@ -37,6 +37,7 @@ static const char *perf_event__names[] = { [PERF_RECORD_AUXTRACE_INFO] = "AUXTRACE_INFO", [PERF_RECORD_AUXTRACE] = "AUXTRACE", [PERF_RECORD_AUXTRACE_ERROR] = "AUXTRACE_ERROR", + [PERF_RECORD_THREAD_MAP] = "THREAD_MAP", };const char *perf_event__name (unsigned int id)
tools/perf/util/event.h +13 -0
@@ -226,6 +226,7 @@ enum perf_user_event_type { /* above any possible kernel type */PERF_RECORD_AUXTRACE_INFO =70 ,PERF_RECORD_AUXTRACE =71 ,PERF_RECORD_AUXTRACE_ERROR =72 , +PERF_RECORD_THREAD_MAP =73 , PERF_RECORD_HEADER_MAX };
@@ -356,6 +357,17 @@ struct context_switch_event {u32 next_prev_tid; }; +struct thread_map_event_entry { +u64 pid; +char comm[16 ]; +}; + +struct thread_map_event { +struct perf_event_header header; +u64 nr; +struct thread_map_event_entry entries[]; +}; +union perf_event {struct perf_event_header header;struct mmap_event mmap;
@@ -378,6 +390,7 @@ union perf_event {struct aux_event aux;struct itrace_start_event itrace_start;struct context_switch_event context_switch; +struct thread_map_event thread_map; };void perf_event__print_totals (void );
tools/perf/util/session.c +26 -0
@@ -296,6 +296,16 @@ int process_event_auxtrace_error_stub(struct perf_tool *tool __maybe_unused,return 0 ; } + +static +int process_event_thread_map_stub (struct perf_tool *tool__maybe_unused , +union perf_event *event__maybe_unused , +struct perf_session *session__maybe_unused ) +{ +dump_printf (": unhandled!\n" ); +return 0 ; +} +void perf_tool__fill_defaults (struct perf_tool *tool) {if (tool->sample ==NULL )
@@ -346,6 +356,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool) tool->auxtrace = process_event_auxtrace_stub;if (tool->auxtrace_error ==NULL ) tool->auxtrace_error = process_event_auxtrace_error_stub; +if (tool->thread_map ==NULL ) + tool->thread_map = process_event_thread_map_stub; }static void swap_sample_id_all (union perf_event *event,void *data)
@@ -616,6 +628,17 @@ static void perf_event__auxtrace_error_swap(union perf_event *event, event->auxtrace_error.ip =bswap_64 (event->auxtrace_error.ip); } +static void perf_event__thread_map_swap (union perf_event *event, +bool sample_id_all__maybe_unused ) +{ +unsigned i; + + event->thread_map.nr =bswap_64 (event->thread_map.nr); + +for (i =0 ; i < event->thread_map.nr; i++) + event->thread_map.entries[i].pid =bswap_64 (event->thread_map.entries[i].pid); +} +typedef void (*perf_event__swap_op )(union perf_event *event,bool sample_id_all);
@@ -643,6 +666,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { [PERF_RECORD_AUXTRACE_INFO] = perf_event__auxtrace_info_swap, [PERF_RECORD_AUXTRACE] = perf_event__auxtrace_swap, [PERF_RECORD_AUXTRACE_ERROR] = perf_event__auxtrace_error_swap, + [PERF_RECORD_THREAD_MAP] = perf_event__thread_map_swap, [PERF_RECORD_HEADER_MAX] = NULL, };
@@ -1179,6 +1203,8 @@ static s64 perf_session__process_user_event(struct perf_session *session,case PERF_RECORD_AUXTRACE_ERROR :perf_session__auxtrace_error_inc (session, event);return tool->auxtrace_error (tool, event, session); +case PERF_RECORD_THREAD_MAP : +return tool->thread_map (tool, event, session);default :return -EINVAL ; }
tools/perf/util/tool.h +2 -1
@@ -55,7 +55,8 @@ struct perf_tool {event_op2 build_id, id_index, auxtrace_info, - auxtrace_error; + auxtrace_error, + thread_map;event_op3 auxtrace;bool ordered_events;bool ordering_requires_timestamps;
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 2/43 perf thread_map: Add thread_map event sythesize function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Introduce the perf_event__synthesize_thread_map2 function to synthesize struct thread_map.
The perf_event__synthesize_thread_map name is already taken for synthesizing the complete threads data (comm/mmap/fork).
--- tools/perf/tests/builtin-test.c | 4 ++++ tools/perf/tests/tests.h | 1 + tools/perf/tests/thread-map.c | 29 +++++++++++++++++++++++++++++ tools/perf/util/event.c | 36 ++++++++++++++++++++++++++++++++++++ tools/perf/util/event.h | 4 ++++ 5 files changed, 74 insertions(+)
tools/perf/tests/builtin-test.c +4 -0
@@ -180,6 +180,10 @@ static struct test generic_tests[] = { }, }, { + .desc = "Test thread map synthesize", + .func = test__thread_map_synthesize, + }, + { .func = NULL, }, };
tools/perf/tests/tests.h +1 -0
@@ -79,6 +79,7 @@ int test__bpf(int subtest);const char *test__bpf_subtest_get_desc (int subtest);int test__bpf_subtest_get_nr (void );int test_session_topology (int subtest); +int test__thread_map_synthesize (int subtest);#if defined(__arm__) || defined(__aarch64__)#ifdef HAVE_DWARF_UNWIND_SUPPORT
tools/perf/tests/thread-map.c +29 -0
@@ -40,3 +40,32 @@ int test__thread_map(int subtest __maybe_unused)thread_map__put (map);return 0 ; } + +static int process_event (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_sample *sample__maybe_unused , +struct machine *machine__maybe_unused ) +{ +struct thread_map_event *map = &event->thread_map; + +TEST_ASSERT_VAL ("wrong nr" , map->nr ==1 ); +TEST_ASSERT_VAL ("wrong pid" , map->entries[0 ].pid == (u64 )getpid ()); +TEST_ASSERT_VAL ("wrong comm" , !strcmp (map->entries[0 ].comm,"perf" )); +return 0 ; +} + +int test__thread_map_synthesize (int subtest__maybe_unused ) +{ +struct thread_map *threads; + +/* test map on current pid */ + threads =thread_map__new_by_pid (getpid ()); +TEST_ASSERT_VAL ("failed to alloc map" , threads); + +thread_map__read_comms (threads); + +TEST_ASSERT_VAL ("failed to synthesize map" , + !perf_event__synthesize_thread_map2 (NULL , threads, process_event,NULL )); + +return 0 ; +}
tools/perf/util/event.c +36 -0
@@ -700,6 +700,42 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,return err; } +int perf_event__synthesize_thread_map2 (struct perf_tool *tool, +struct thread_map *threads, +perf_event__handler_t process, +struct machine *machine) +{ +union perf_event *event; +int i, err, size; + + size =sizeof (event->thread_map); + size += threads->nr *sizeof (event->thread_map.entries[0 ]); + + event =zalloc (size); +if (!event) +return -ENOMEM ; + + event->header.type =PERF_RECORD_THREAD_MAP ; + event->header.size = size; + event->thread_map.nr = threads->nr; + +for (i =0 ; i < threads->nr; i++) { +struct thread_map_event_entry *entry = &event->thread_map.entries[i]; +char *comm =thread_map__comm (threads, i); + +if (!comm) + comm = (char *)"" ; + + entry->pid =thread_map__pid (threads, i); +strncpy ((char *) &entry->comm, comm,sizeof (entry->comm)); + } + + err =process (tool, event,NULL , machine); + +free (event); +return err; +} +size_t perf_event__fprintf_comm (union perf_event *event,FILE *fp) {const char *s;
tools/perf/util/event.h +4 -0
@@ -408,6 +408,10 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,perf_event__handler_t process, struct machine *machine, bool mmap_data, unsigned int proc_map_timeout); +int perf_event__synthesize_thread_map2 (struct perf_tool *tool, +struct thread_map *threads, +perf_event__handler_t process, +struct machine *machine); int perf_event__synthesize_threads(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine, bool mmap_data,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 3/43 perf thread_map: Add thread_map__new_event function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Introducing the thread_map__new_event function to create a struct thread_map object from a thread_map event.
--- tools/perf/tests/thread-map.c | 14 ++++++++++++++ tools/perf/util/thread_map.c | 27 +++++++++++++++++++++++++++ tools/perf/util/thread_map.h | 3 +++ 3 files changed, 44 insertions(+)
tools/perf/tests/thread-map.c +14 -0
@@ -47,10 +47,24 @@ static int process_event(struct perf_tool *tool __maybe_unused, struct machine *machine __maybe_unused) {struct thread_map_event *map = &event->thread_map; +struct thread_map *threads;TEST_ASSERT_VAL ("wrong nr" , map->nr ==1 );TEST_ASSERT_VAL ("wrong pid" , map->entries[0 ].pid == (u64 )getpid ());TEST_ASSERT_VAL ("wrong comm" , !strcmp (map->entries[0 ].comm,"perf" )); + + threads =thread_map__new_event (&event->thread_map); +TEST_ASSERT_VAL ("failed to alloc map" , threads); + +TEST_ASSERT_VAL ("wrong nr" , threads->nr ==1 ); +TEST_ASSERT_VAL ("wrong pid" , +thread_map__pid (threads,0 ) ==getpid ()); +TEST_ASSERT_VAL ("wrong comm" , +thread_map__comm (threads,0 ) && + !strcmp (thread_map__comm (threads,0 ),"perf" )); +TEST_ASSERT_VAL ("wrong refcnt" , +atomic_read (&threads->refcnt) ==1 ); +thread_map__put (threads);return 0 ; }
tools/perf/util/thread_map.c +27 -0
@@ -13,6 +13,7 @@#include "thread_map.h" #include "util.h" #include "debug.h" +#include "event.h" /* Skip "." and ".." directories */ static int filter (const struct dirent *dir)
@@ -409,3 +410,29 @@ void thread_map__read_comms(struct thread_map *threads)for (i =0 ; i < threads->nr; ++i)comm_init (threads, i); } + +static void thread_map__copy_event (struct thread_map *threads, +struct thread_map_event *event) +{ +unsigned i; + + threads->nr = (int ) event->nr; + +for (i =0 ; i < event->nr; i++) { +thread_map__set_pid (threads, i, (pid_t ) event->entries[i].pid); + threads->map[i].comm =strndup (event->entries[i].comm,16 ); + } + +atomic_set (&threads->refcnt,1 ); +} + +struct thread_map *thread_map__new_event (struct thread_map_event *event) +{ +struct thread_map *threads; + + threads =thread_map__alloc (event->nr); +if (threads) +thread_map__copy_event (threads, event); + +return threads; +}
tools/perf/util/thread_map.h +3 -0
@@ -16,11 +16,14 @@ struct thread_map {struct thread_map_data map[]; }; +struct thread_map_event ; +struct thread_map *thread_map__new_dummy (void );struct thread_map *thread_map__new_by_pid (pid_t pid);struct thread_map *thread_map__new_by_tid (pid_t tid);struct thread_map *thread_map__new_by_uid (uid_t uid);struct thread_map *thread_map__new (pid_t pid,pid_t tid,uid_t uid); +struct thread_map *thread_map__new_event (struct thread_map_event *event);struct thread_map *thread_map__get (struct thread_map *map);void thread_map__put (struct thread_map *map);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 4/43 perf thread_map: Add perf_event__fprintf_thread_map function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
To display a thread_map event for a raw dump.
--- tools/perf/util/event.c | 16 ++++++++++++++++ tools/perf/util/event.h | 1 + 2 files changed, 17 insertions(+)
tools/perf/util/event.c +16 -0
@@ -820,6 +820,22 @@ size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp) event->mmap2.filename); } +size_t perf_event__fprintf_thread_map (union perf_event *event,FILE *fp) +{ +struct thread_map *threads =thread_map__new_event (&event->thread_map); +size_t ret; + + ret =fprintf (fp," nr: " ); + +if (threads) + ret +=thread_map__fprintf (threads, fp); +else + ret +=fprintf (fp,"failed to get threads from event\n" ); + +thread_map__put (threads); +return ret; +} + int perf_event__process_mmap(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample,
tools/perf/util/event.h +1 -0
@@ -516,6 +516,7 @@ size_t perf_event__fprintf_task(union perf_event *event, FILE *fp);size_t perf_event__fprintf_aux (union perf_event *event,FILE *fp);size_t perf_event__fprintf_itrace_start (union perf_event *event,FILE *fp);size_t perf_event__fprintf_switch (union perf_event *event,FILE *fp); +size_t perf_event__fprintf_thread_map (union perf_event *event,FILE *fp);size_t perf_event__fprintf (union perf_event *event,FILE *fp); u64 kallsyms__get_function_start(const char *kallsyms_filename,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 5/43 perf cpu_map: Add cpu_map user level event
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding the cpu_map event to pass/store cpu maps as data in a pipe/perf.data.
We store maps in 2 formats:
- list of cpus
- mask of cpus
The format that takes less space is selected transparently in the following patch.
The interface is made generic, so we could add the cpumap event data into another event in the following patches.
--- tools/perf/util/event.c | 1 + tools/perf/util/event.h | 28 ++++++++++++++++++++++++++ tools/perf/util/session.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/tool.h | 3 ++- 4 files changed, 81 insertions(+), 1 deletion(-)
tools/perf/util/event.c +1 -0
@@ -38,6 +38,7 @@ static const char *perf_event__names[] = { [PERF_RECORD_AUXTRACE] = "AUXTRACE", [PERF_RECORD_AUXTRACE_ERROR] = "AUXTRACE_ERROR", [PERF_RECORD_THREAD_MAP] = "THREAD_MAP", + [PERF_RECORD_CPU_MAP] = "CPU_MAP", };const char *perf_event__name (unsigned int id)
tools/perf/util/event.h +28 -0
@@ -227,6 +227,7 @@ enum perf_user_event_type { /* above any possible kernel type */PERF_RECORD_AUXTRACE =71 ,PERF_RECORD_AUXTRACE_ERROR =72 ,PERF_RECORD_THREAD_MAP =73 , +PERF_RECORD_CPU_MAP =74 , PERF_RECORD_HEADER_MAX };
@@ -271,6 +272,32 @@ struct events_stats {u32 nr_proc_map_timeout; }; +enum { +PERF_CPU_MAP__CPUS =0 , +PERF_CPU_MAP__MASK =1 , +}; + +struct cpu_map_entries { +u16 nr; +u16 cpu[]; +}; + +struct cpu_map_mask { +u16 nr; +u16 long_size; +unsigned long mask[]; +}; + +struct cpu_map_data { +u16 type; +char data[]; +}; + +struct cpu_map_event { +struct perf_event_header header; +struct cpu_map_data data; +}; +struct attr_event {struct perf_event_header header;struct perf_event_attr attr;
@@ -391,6 +418,7 @@ union perf_event {struct itrace_start_event itrace_start;struct context_switch_event context_switch;struct thread_map_event thread_map; +struct cpu_map_event cpu_map; };void perf_event__print_totals (void );
tools/perf/util/session.c +50 -0
80 lines not on this page · raw message
tools/perf/util/tool.h +2 -1
@@ -56,7 +56,8 @@ struct perf_tool { id_index, auxtrace_info, auxtrace_error, - thread_map; + thread_map, + cpu_map;event_op3 auxtrace;bool ordered_events;bool ordering_requires_timestamps;
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 6/43 perf cpu_map: Add cpu_map event synthesize function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Introduce the perf_event__synthesize_cpu_map function to synthesize a struct cpu_map.
Added generic interface:
cpu_map_data__alloc
cpu_map_data__synthesize
to make the cpu_map synthesizing usable for other events.
--- tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test.c | 4 ++ tools/perf/tests/cpumap.c | 71 ++++++++++++++++++++++ tools/perf/tests/tests.h | 1 + tools/perf/util/event.c | 131 ++++++++++++++++++++++++++++++++++++++++ tools/perf/util/event.h | 8 +++ 6 files changed, 216 insertions(+) create mode 100644 tools/perf/tests/cpumap.c
tools/perf/tests/Build +1 -0
@@ -34,6 +34,7 @@ perf-y += thread-map.o perf-y += llvm.o llvm-src-base.o llvm-src-kbuild.o llvm-src-prologue.o perf-y += bpf.o perf-y += topology.o +perf-y += cpumap.o $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build $(call rule_mkdir)
tools/perf/tests/builtin-test.c +4 -0
@@ -184,6 +184,10 @@ static struct test generic_tests[] = { .func = test__thread_map_synthesize, }, { + .desc = "Test cpu map synthesize", + .func = test__cpu_map_synthesize, + }, + { .func = NULL, }, };
tools/perf/tests/cpumap.c new file +71 -0
71 lines not on this page · raw message
tools/perf/tests/tests.h +1 -0
@@ -80,6 +80,7 @@ const char *test__bpf_subtest_get_desc(int subtest);int test__bpf_subtest_get_nr (void );int test_session_topology (int subtest);int test__thread_map_synthesize (int subtest); +int test__cpu_map_synthesize (int subtest);#if defined(__arm__) || defined(__aarch64__)#ifdef HAVE_DWARF_UNWIND_SUPPORT
tools/perf/util/event.c +131 -0
137 lines not on this page · raw message
tools/perf/util/event.h +8 -0
@@ -425,6 +425,7 @@ void perf_event__print_totals(void);struct perf_tool ;struct thread_map ; +struct cpu_map ; typedef int (*perf_event__handler_t)(struct perf_tool *tool, union perf_event *event,
@@ -440,6 +441,10 @@ int perf_event__synthesize_thread_map2(struct perf_tool *tool,struct thread_map *threads, perf_event__handler_t process, struct machine *machine); +int perf_event__synthesize_cpu_map (struct perf_tool *tool, +struct cpu_map *cpus, +perf_event__handler_t process, +struct machine *machine); int perf_event__synthesize_threads(struct perf_tool *tool, perf_event__handler_t process, struct machine *machine, bool mmap_data,
@@ -550,4 +555,7 @@ size_t perf_event__fprintf(union perf_event *event, FILE *fp);u64 kallsyms__get_function_start (const char *kallsyms_filename,const char *symbol_name); +void *cpu_map_data__alloc (struct cpu_map *map,size_t *size,u16 *type,int *max); +void cpu_map_data__synthesize (struct cpu_map_data *data,struct cpu_map *map, +u16 type,int max);#endif /* __PERF_RECORD_H */
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 7/43 perf cpu_map: Add cpu_map__new_event function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Introducing the cpu_map__new_event function to create a struct cpu_map object from a cpu_map event.
--- tools/perf/tests/cpumap.c | 25 +++++++++++++++++++++---- tools/perf/util/cpumap.c | 42 ++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/cpumap.h | 1 + 3 files changed, 64 insertions(+), 4 deletions(-)
tools/perf/tests/cpumap.c +21 -4
@@ -6,12 +6,13 @@ static int process_event_mask(struct perf_tool *tool __maybe_unused,struct perf_sample *sample__maybe_unused , struct machine *machine __maybe_unused) { - struct cpu_map_event *map = &event->cpu_map; + struct cpu_map_event *map_event = &event->cpu_map;struct cpu_map_mask *mask;struct cpu_map_data *data; +struct cpu_map *map;int i; - data = &map->data; + data = &map_event->data;TEST_ASSERT_VAL ("wrong type" , data->type ==PERF_CPU_MAP__MASK );
@@ -23,6 +24,14 @@ static int process_event_mask(struct perf_tool *tool __maybe_unused,TEST_ASSERT_VAL ("wrong cpu" ,test_bit (i, mask->mask)); } + map =cpu_map__new_data (data); +TEST_ASSERT_VAL ("wrong nr" , map->nr ==20 ); + +for (i =0 ; i <20 ; i++) { +TEST_ASSERT_VAL ("wrong cpu" , map->map[i] == i); + } + +cpu_map__put (map);return 0 ; }
@@ -31,11 +40,12 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused,struct perf_sample *sample__maybe_unused , struct machine *machine __maybe_unused) { - struct cpu_map_event *map = &event->cpu_map; + struct cpu_map_event *map_event = &event->cpu_map;struct cpu_map_entries *cpus;struct cpu_map_data *data; +struct cpu_map *map; - data = &map->data; + data = &map_event->data;TEST_ASSERT_VAL ("wrong type" , data->type ==PERF_CPU_MAP__CPUS );
@@ -44,6 +54,13 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused,TEST_ASSERT_VAL ("wrong nr" , cpus->nr ==2 );TEST_ASSERT_VAL ("wrong cpu" , cpus->cpu[0 ] ==1 );TEST_ASSERT_VAL ("wrong cpu" , cpus->cpu[1 ] ==256 ); + + map =cpu_map__new_data (data); +TEST_ASSERT_VAL ("wrong nr" , map->nr ==2 ); +TEST_ASSERT_VAL ("wrong cpu" , map->map[0 ] ==1 ); +TEST_ASSERT_VAL ("wrong cpu" , map->map[1 ] ==256 ); +TEST_ASSERT_VAL ("wrong refcnt" ,atomic_read (&map->refcnt) ==1 ); +cpu_map__put (map);return 0 ; }
tools/perf/util/cpumap.c +42 -0
54 lines not on this page · raw message
tools/perf/util/cpumap.h +1 -0
@@ -17,6 +17,7 @@ struct cpu_map {struct cpu_map *cpu_map__new (const char *cpu_list);struct cpu_map *cpu_map__empty_new (int nr);struct cpu_map *cpu_map__dummy_new (void ); +struct cpu_map *cpu_map__new_data (struct cpu_map_data *data);struct cpu_map *cpu_map__read (FILE *file);size_t cpu_map__fprintf (struct cpu_map *map,FILE *fp);int cpu_map__get_socket_id (int cpu);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 8/43 perf cpu_map: Add perf_event__fprintf_cpu_map function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
To display a cpu_map event for raw dump.
--- tools/perf/util/event.c | 16 ++++++++++++++++ tools/perf/util/event.h | 1 + 2 files changed, 17 insertions(+)
tools/perf/util/event.c +16 -0
@@ -968,6 +968,22 @@ size_t perf_event__fprintf_thread_map(union perf_event *event, FILE *fp)return ret; } +size_t perf_event__fprintf_cpu_map (union perf_event *event,FILE *fp) +{ +struct cpu_map *cpus =cpu_map__new_data (&event->cpu_map.data); +size_t ret; + + ret =fprintf (fp," nr: " ); + +if (cpus) + ret +=cpu_map__fprintf (cpus, fp); +else + ret +=fprintf (fp,"failed to get cpumap from event\n" ); + +cpu_map__put (cpus); +return ret; +} + int perf_event__process_mmap(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample,
tools/perf/util/event.h +1 -0
@@ -550,6 +550,7 @@ size_t perf_event__fprintf_aux(union perf_event *event, FILE *fp);size_t perf_event__fprintf_itrace_start (union perf_event *event,FILE *fp);size_t perf_event__fprintf_switch (union perf_event *event,FILE *fp);size_t perf_event__fprintf_thread_map (union perf_event *event,FILE *fp); +size_t perf_event__fprintf_cpu_map (union perf_event *event,FILE *fp);size_t perf_event__fprintf (union perf_event *event,FILE *fp); u64 kallsyms__get_function_start(const char *kallsyms_filename,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 9/43 perf tools: Add stat config user level event
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding the stat config event to pass/store stat config data, so report tools (report/script) know how to interpret stat data.
The config data is stored in a 'tag|value' way to allow for easy extension and backwards compatibility.
--- tools/perf/util/event.c | 1 + tools/perf/util/event.h | 20 ++++++++++++++++++++ tools/perf/util/session.c | 24 ++++++++++++++++++++++++ tools/perf/util/tool.h | 3 ++- 4 files changed, 47 insertions(+), 1 deletion(-)
tools/perf/util/event.c +1 -0
@@ -39,6 +39,7 @@ static const char *perf_event__names[] = { [PERF_RECORD_AUXTRACE_ERROR] = "AUXTRACE_ERROR", [PERF_RECORD_THREAD_MAP] = "THREAD_MAP", [PERF_RECORD_CPU_MAP] = "CPU_MAP", + [PERF_RECORD_STAT_CONFIG] = "STAT_CONFIG", };const char *perf_event__name (unsigned int id)
tools/perf/util/event.h +20 -0
@@ -228,6 +228,7 @@ enum perf_user_event_type { /* above any possible kernel type */PERF_RECORD_AUXTRACE_ERROR =72 ,PERF_RECORD_THREAD_MAP =73 ,PERF_RECORD_CPU_MAP =74 , +PERF_RECORD_STAT_CONFIG =75 , PERF_RECORD_HEADER_MAX };
@@ -395,6 +396,24 @@ struct thread_map_event {struct thread_map_event_entry entries[]; }; +enum { +PERF_STAT_CONFIG_TERM__AGGR_MODE =0 , +PERF_STAT_CONFIG_TERM__INTERVAL =1 , +PERF_STAT_CONFIG_TERM__SCALE =2 , +PERF_STAT_CONFIG_TERM__MAX =3 , +}; + +struct stat_config_event_entry { +u64 tag; +u64 val; +}; + +struct stat_config_event { +struct perf_event_header header; +u64 nr; +struct stat_config_event_entry data[]; +}; +union perf_event {struct perf_event_header header;struct mmap_event mmap;
@@ -419,6 +438,7 @@ union perf_event {struct context_switch_event context_switch;struct thread_map_event thread_map;struct cpu_map_event cpu_map; +struct stat_config_event stat_config; };void perf_event__print_totals (void );
tools/perf/util/session.c +24 -0
@@ -315,6 +315,15 @@ int process_event_cpu_map_stub(struct perf_tool *tool __maybe_unused,return 0 ; } +static +int process_event_stat_config_stub (struct perf_tool *tool__maybe_unused , +union perf_event *event__maybe_unused , +struct perf_session *session__maybe_unused ) +{ +dump_printf (": unhandled!\n" ); +return 0 ; +} +void perf_tool__fill_defaults (struct perf_tool *tool) {if (tool->sample ==NULL )
@@ -369,6 +378,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool) tool->thread_map = process_event_thread_map_stub;if (tool->cpu_map ==NULL ) tool->cpu_map = process_event_cpu_map_stub; +if (tool->stat_config ==NULL ) + tool->stat_config = process_event_stat_config_stub; }static void swap_sample_id_all (union perf_event *event,void *data)
@@ -686,6 +697,16 @@ static void perf_event__cpu_map_swap(union perf_event *event, } } +static void perf_event__stat_config_swap (union perf_event *event, +bool sample_id_all__maybe_unused ) +{ +u64 size; + + size = event->stat_config.nr *sizeof (event->stat_config.data[0 ]); + size +=1 ;/* nr item itself */ +mem_bswap_64 (&event->stat_config.nr, size); +} +typedef void (*perf_event__swap_op )(union perf_event *event,bool sample_id_all);
@@ -715,6 +736,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { [PERF_RECORD_AUXTRACE_ERROR] = perf_event__auxtrace_error_swap, [PERF_RECORD_THREAD_MAP] = perf_event__thread_map_swap, [PERF_RECORD_CPU_MAP] = perf_event__cpu_map_swap, + [PERF_RECORD_STAT_CONFIG] = perf_event__stat_config_swap, [PERF_RECORD_HEADER_MAX] = NULL, };
@@ -1255,6 +1277,8 @@ static s64 perf_session__process_user_event(struct perf_session *session,return tool->thread_map (tool, event, session);case PERF_RECORD_CPU_MAP :return tool->cpu_map (tool, event, session); +case PERF_RECORD_STAT_CONFIG : +return tool->stat_config (tool, event, session);default :return -EINVAL ; }
tools/perf/util/tool.h +2 -1
@@ -57,7 +57,8 @@ struct perf_tool { auxtrace_info, auxtrace_error, thread_map, - cpu_map; + cpu_map, + stat_config;event_op3 auxtrace;bool ordered_events;bool ordering_requires_timestamps;
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 10/43 perf tools: Add stat config event synthesize function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Introduce the perf_event__synthesize_stat_config to synthesize a 'struct perf_stat_config'.
Storing the stat config in the form of tag-value pairs will, I believe, sort out future version extensibility issues.
--- tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test.c | 4 ++++ tools/perf/tests/stat.c | 53 +++++++++++++++++++++++++++++++++++++++++ tools/perf/tests/tests.h | 1 + tools/perf/util/event.c | 40 +++++++++++++++++++++++++++++++ tools/perf/util/event.h | 5 ++++ 6 files changed, 104 insertions(+) create mode 100644 tools/perf/tests/stat.c
tools/perf/tests/Build +1 -0
@@ -35,6 +35,7 @@ perf-y += llvm.o llvm-src-base.o llvm-src-kbuild.o llvm-src-prologue.o perf-y += bpf.o perf-y += topology.o perf-y += cpumap.o +perf-y += stat.o $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build $(call rule_mkdir)
tools/perf/tests/builtin-test.c +4 -0
@@ -188,6 +188,10 @@ static struct test generic_tests[] = { .func = test__cpu_map_synthesize, }, { + .desc = "Test stat config synthesize", + .func = test__synthesize_stat_config, + }, + { .func = NULL, }, };
tools/perf/tests/stat.c new file +53 -0
53 lines not on this page · raw message
tools/perf/tests/tests.h +1 -0
@@ -81,6 +81,7 @@ int test__bpf_subtest_get_nr(void);int test_session_topology (int subtest);int test__thread_map_synthesize (int subtest);int test__cpu_map_synthesize (int subtest); +int test__synthesize_stat_config (int subtest);#if defined(__arm__) || defined(__aarch64__)#ifdef HAVE_DWARF_UNWIND_SUPPORT
tools/perf/util/event.c +40 -0
@@ -10,6 +10,8 @@#include "thread.h" #include "thread_map.h" #include "symbol/kallsyms.h" +#include "asm/bug.h" +#include "stat.h" static const char *perf_event__names[] = { [0 ] ="TOTAL" ,
@@ -869,6 +871,44 @@ int perf_event__synthesize_cpu_map(struct perf_tool *tool,return err; } +int perf_event__synthesize_stat_config (struct perf_tool *tool, +struct perf_stat_config *config, +perf_event__handler_t process, +struct machine *machine) +{ +struct stat_config_event *event; +int size, i =0 , err; + + size =sizeof (*event); + size += (PERF_STAT_CONFIG_TERM__MAX *sizeof (event->data[0 ])); + + event =zalloc (size); +if (!event) +return -ENOMEM ; + + event->header.type =PERF_RECORD_STAT_CONFIG ; + event->header.size = size; + event->nr =PERF_STAT_CONFIG_TERM__MAX ; + +#define ADD (__term, __val) \ + event->data[i].tag = PERF_STAT_CONFIG_TERM__##__term; \ + event->data[i].val = __val; \ + i++; + + ADD(AGGR_MODE, config->aggr_mode) + ADD(INTERVAL, config->interval) + ADD(SCALE, config->scale) + +WARN_ONCE (i !=PERF_STAT_CONFIG_TERM__MAX , +"stat config terms unbalanced\n" ); +#undef ADD + + err =process (tool, (union perf_event *) event,NULL , machine); + +free (event); +return err; +} +size_t perf_event__fprintf_comm (union perf_event *event,FILE *fp) {const char *s;
tools/perf/util/event.h +5 -0
@@ -446,6 +446,7 @@ void perf_event__print_totals(void);struct perf_tool ;struct thread_map ;struct cpu_map ; +struct perf_stat_config ; typedef int (*perf_event__handler_t)(struct perf_tool *tool, union perf_event *event,
@@ -472,6 +473,10 @@ int perf_event__synthesize_threads(struct perf_tool *tool,int perf_event__synthesize_kernel_mmap (struct perf_tool *tool,perf_event__handler_t process,struct machine *machine); +int perf_event__synthesize_stat_config (struct perf_tool *tool, +struct perf_stat_config *config, +perf_event__handler_t process, +struct machine *machine); int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t process,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 11/43 perf tools: Add stat config event read function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Introducing the perf_event__read_stat_config function to read a struct perf_stat_config object data from a stat config event.
--- tools/perf/tests/stat.c | 6 ++++++ tools/perf/util/event.c | 24 ++++++++++++++++++++++++ tools/perf/util/event.h | 2 ++ 3 files changed, 32 insertions(+)
tools/perf/tests/stat.c +6 -0
@@ -24,6 +24,7 @@ static int process_event(struct perf_tool *tool __maybe_unused, struct machine *machine __maybe_unused) {struct stat_config_event *config = &event->stat_config; +struct perf_stat_config stat_config;#define HAS (term, val) \ has_term(config, PERF_STAT_CONFIG_TERM__##term, val)
@@ -35,6 +36,11 @@ static int process_event(struct perf_tool *tool __maybe_unused,#undef HAS +perf_event__read_stat_config (&stat_config, config); + +TEST_ASSERT_VAL ("wrong aggr_mode" , stat_config.aggr_mode ==AGGR_CORE ); +TEST_ASSERT_VAL ("wrong scale" , stat_config.scale ==1 ); +TEST_ASSERT_VAL ("wrong interval" , stat_config.interval ==1 );return 0 ; }
tools/perf/util/event.c +24 -0
@@ -909,6 +909,30 @@ int perf_event__synthesize_stat_config(struct perf_tool *tool,return err; } +void perf_event__read_stat_config (struct perf_stat_config *config, +struct stat_config_event *event) +{ +unsigned i; + +for (i =0 ; i < event->nr; i++) { + +switch (event->data[i].tag) { +#define CASE (__term, __val) \ + case PERF_STAT_CONFIG_TERM__##__term: \ + config->__val = event->data[i].val; \ + break; + + CASE(AGGR_MODE, aggr_mode) + CASE(SCALE, scale) + CASE(INTERVAL, interval) +#undef CASE +default : +pr_warning ("unknown stat config term %" PRIu64"\n" , + event->data[i].tag); + } + } +} +size_t perf_event__fprintf_comm (union perf_event *event,FILE *fp) {const char *s;
tools/perf/util/event.h +2 -0
@@ -477,6 +477,8 @@ int perf_event__synthesize_stat_config(struct perf_tool *tool,struct perf_stat_config *config, perf_event__handler_t process, struct machine *machine); +void perf_event__read_stat_config (struct perf_stat_config *config, +struct stat_config_event *event); int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t process,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 12/43 perf tools: Add stat user level event
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding a stat event to store a 'struct perf_counter_values' for a given event/cpu/thread.
--- tools/perf/util/event.c | 1 + tools/perf/util/event.h | 19 +++++++++++++++++++ tools/perf/util/session.c | 25 +++++++++++++++++++++++++ tools/perf/util/tool.h | 3 ++- 4 files changed, 47 insertions(+), 1 deletion(-)
tools/perf/util/event.c +1 -0
@@ -42,6 +42,7 @@ static const char *perf_event__names[] = { [PERF_RECORD_THREAD_MAP] = "THREAD_MAP", [PERF_RECORD_CPU_MAP] = "CPU_MAP", [PERF_RECORD_STAT_CONFIG] = "STAT_CONFIG", + [PERF_RECORD_STAT] = "STAT", };const char *perf_event__name (unsigned int id)
tools/perf/util/event.h +19 -0
@@ -229,6 +229,7 @@ enum perf_user_event_type { /* above any possible kernel type */PERF_RECORD_THREAD_MAP =73 ,PERF_RECORD_CPU_MAP =74 ,PERF_RECORD_STAT_CONFIG =75 , +PERF_RECORD_STAT =76 , PERF_RECORD_HEADER_MAX };
@@ -414,6 +415,23 @@ struct stat_config_event {struct stat_config_event_entry data[]; }; +struct stat_event { +struct perf_event_header header; + +u64 id; +u32 cpu; +u32 thread; + +union { +struct { +u64 val; +u64 ena; +u64 run; + }; +u64 values[3 ]; + }; +}; +union perf_event {struct perf_event_header header;struct mmap_event mmap;
@@ -439,6 +457,7 @@ union perf_event {struct thread_map_event thread_map;struct cpu_map_event cpu_map;struct stat_config_event stat_config; +struct stat_event stat; };void perf_event__print_totals (void );
tools/perf/util/session.c +25 -0
@@ -324,6 +324,15 @@ int process_event_stat_config_stub(struct perf_tool *tool __maybe_unused,return 0 ; } +static int process_stat_stub (struct perf_tool *tool__maybe_unused , +union perf_event *event__maybe_unused , +struct perf_session *perf_session +__maybe_unused ) +{ +dump_printf (": unhandled!\n" ); +return 0 ; +} +void perf_tool__fill_defaults (struct perf_tool *tool) {if (tool->sample ==NULL )
@@ -380,6 +389,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool) tool->cpu_map = process_event_cpu_map_stub;if (tool->stat_config ==NULL ) tool->stat_config = process_event_stat_config_stub; +if (tool->stat ==NULL ) + tool->stat = process_stat_stub; }static void swap_sample_id_all (union perf_event *event,void *data)
@@ -707,6 +718,17 @@ static void perf_event__stat_config_swap(union perf_event *event,mem_bswap_64 (&event->stat_config.nr, size); } +static void perf_event__stat_swap (union perf_event *event, +bool sample_id_all__maybe_unused ) +{ + event->stat.id =bswap_64 (event->stat.id); + event->stat.thread =bswap_32 (event->stat.thread); + event->stat.cpu =bswap_32 (event->stat.cpu); + event->stat.val =bswap_64 (event->stat.val); + event->stat.ena =bswap_64 (event->stat.ena); + event->stat.run =bswap_64 (event->stat.run); +} +typedef void (*perf_event__swap_op )(union perf_event *event,bool sample_id_all);
@@ -737,6 +759,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { [PERF_RECORD_THREAD_MAP] = perf_event__thread_map_swap, [PERF_RECORD_CPU_MAP] = perf_event__cpu_map_swap, [PERF_RECORD_STAT_CONFIG] = perf_event__stat_config_swap, + [PERF_RECORD_STAT] = perf_event__stat_swap, [PERF_RECORD_HEADER_MAX] = NULL, };
@@ -1279,6 +1302,8 @@ static s64 perf_session__process_user_event(struct perf_session *session,return tool->cpu_map (tool, event, session);case PERF_RECORD_STAT_CONFIG :return tool->stat_config (tool, event, session); +case PERF_RECORD_STAT : +return tool->stat (tool, event, session);default :return -EINVAL ; }
tools/perf/util/tool.h +2 -1
@@ -58,7 +58,8 @@ struct perf_tool { auxtrace_error, thread_map, cpu_map, - stat_config; + stat_config, + stat;event_op3 auxtrace;bool ordered_events;bool ordering_requires_timestamps;
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 13/43 perf tools: Add stat event synthesize function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Introduce the perf_event__synthesize_stat function to synthesize a 'struct stat_event'.
--- tools/perf/tests/builtin-test.c | 4 ++++ tools/perf/tests/stat.c | 41 ++++++++++++++++++++++++++++++++++++----- tools/perf/tests/tests.h | 1 + tools/perf/util/event.c | 22 ++++++++++++++++++++++ tools/perf/util/event.h | 7 ++++++- 5 files changed, 69 insertions(+), 6 deletions(-)
tools/perf/tests/builtin-test.c +4 -0
@@ -192,6 +192,10 @@ static struct test generic_tests[] = { .func = test__synthesize_stat_config, }, { + .desc = "Test stat synthesize", + .func = test__synthesize_stat, + }, + { .func = NULL, }, };
tools/perf/tests/stat.c +36 -5
59 lines not on this page · raw message
tools/perf/tests/tests.h +1 -0
@@ -82,6 +82,7 @@ int test_session_topology(int subtest);int test__thread_map_synthesize (int subtest);int test__cpu_map_synthesize (int subtest);int test__synthesize_stat_config (int subtest); +int test__synthesize_stat (int subtest);#if defined(__arm__) || defined(__aarch64__)#ifdef HAVE_DWARF_UNWIND_SUPPORT
tools/perf/util/event.c +22 -0
@@ -910,6 +910,28 @@ int perf_event__synthesize_stat_config(struct perf_tool *tool,return err; } +int perf_event__synthesize_stat (struct perf_tool *tool, +u32 cpu,u32 thread,u64 id, +struct perf_counts_values *count, +perf_event__handler_t process, +struct machine *machine) +{ +struct stat_event event; + + event.header.type =PERF_RECORD_STAT ; + event.header.size =sizeof (event); + event.header.misc =0 ; + + event.id = id; + event.cpu = cpu; + event.thread = thread; + event.val = count->val; + event.ena = count->ena; + event.run = count->run; + +return process (tool, (union perf_event *) &event,NULL , machine); +} +void perf_event__read_stat_config (struct perf_stat_config *config,struct stat_config_event *event) {
tools/perf/util/event.h +6 -1
@@ -466,6 +466,7 @@ struct perf_tool;struct thread_map ;struct cpu_map ;struct perf_stat_config ; +struct perf_counts_values ; typedef int (*perf_event__handler_t)(struct perf_tool *tool, union perf_event *event,
@@ -498,7 +499,11 @@ int perf_event__synthesize_stat_config(struct perf_tool *tool, struct machine *machine);void perf_event__read_stat_config (struct perf_stat_config *config,struct stat_config_event *event); - +int perf_event__synthesize_stat (struct perf_tool *tool, +u32 cpu,u32 thread,u64 id, +struct perf_counts_values *count, +perf_event__handler_t process, +struct machine *machine);int perf_event__synthesize_modules (struct perf_tool *tool,perf_event__handler_t process,struct machine *machine);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 14/43 perf tools: Add stat event read function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Introducing the perf_event__process_stat_event function to process a 'struct perf_stat' data from a stat event.
--- tools/perf/util/stat.c | 23 +++++++++++++++++++++++ tools/perf/util/stat.h | 6 ++++++ 2 files changed, 29 insertions(+)
tools/perf/util/stat.c +23 -0
@@ -341,3 +341,26 @@ int perf_stat_process_counter(struct perf_stat_config *config,return 0 ; } + +int perf_event__process_stat_event (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_session *session) +{ +struct perf_counts_values count; +struct stat_event *st = &event->stat; +struct perf_evsel *counter; + + count.val = st->val; + count.ena = st->ena; + count.run = st->run; + + counter =perf_evlist__id2evsel (session->evlist, st->id); +if (!counter) { +pr_err ("Failed to resolve counter for stat event.\n" ); +return -EINVAL ; + } + + *perf_counts (counter->counts, st->cpu, st->thread) = count; + counter->supported = true; +return 0 ; +}
tools/perf/util/stat.h +6 -0
@@ -90,4 +90,10 @@ void perf_evlist__reset_stats(struct perf_evlist *evlist);int perf_stat_process_counter (struct perf_stat_config *config,struct perf_evsel *counter); +struct perf_tool ; +union perf_event ; +struct perf_session ; +int perf_event__process_stat_event (struct perf_tool *tool, +union perf_event *event, +struct perf_session *session);#endif
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 15/43 perf tools: Add stat round user level event
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding the stat round event to be stored after each stat interval round, so that report tools (report/script) gets notified and process interval data.
--- tools/perf/util/event.c | 1 + tools/perf/util/event.h | 13 +++++++++++++ tools/perf/util/session.c | 21 +++++++++++++++++++++ tools/perf/util/tool.h | 3 ++- 4 files changed, 37 insertions(+), 1 deletion(-)
tools/perf/util/event.c +1 -0
@@ -43,6 +43,7 @@ static const char *perf_event__names[] = { [PERF_RECORD_CPU_MAP] = "CPU_MAP", [PERF_RECORD_STAT_CONFIG] = "STAT_CONFIG", [PERF_RECORD_STAT] = "STAT", + [PERF_RECORD_STAT_ROUND] = "STAT_ROUND", };const char *perf_event__name (unsigned int id)
tools/perf/util/event.h +13 -0
@@ -230,6 +230,7 @@ enum perf_user_event_type { /* above any possible kernel type */PERF_RECORD_CPU_MAP =74 ,PERF_RECORD_STAT_CONFIG =75 ,PERF_RECORD_STAT =76 , +PERF_RECORD_STAT_ROUND =77 , PERF_RECORD_HEADER_MAX };
@@ -432,6 +433,17 @@ struct stat_event { }; }; +enum { +PERF_STAT_ROUND_TYPE__INTERVAL =0 , +PERF_STAT_ROUND_TYPE__FINAL =1 , +}; + +struct stat_round_event { +struct perf_event_header header; +u64 type; +u64 time; +}; +union perf_event {struct perf_event_header header;struct mmap_event mmap;
@@ -458,6 +470,7 @@ union perf_event {struct cpu_map_event cpu_map;struct stat_config_event stat_config;struct stat_event stat; +struct stat_round_event stat_round; };void perf_event__print_totals (void );
tools/perf/util/session.c +21 -0
@@ -333,6 +333,15 @@ static int process_stat_stub(struct perf_tool *tool __maybe_unused,return 0 ; } +static int process_stat_round_stub (struct perf_tool *tool__maybe_unused , +union perf_event *event__maybe_unused , +struct perf_session *perf_session +__maybe_unused ) +{ +dump_printf (": unhandled!\n" ); +return 0 ; +} +void perf_tool__fill_defaults (struct perf_tool *tool) {if (tool->sample ==NULL )
@@ -391,6 +400,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool) tool->stat_config = process_event_stat_config_stub;if (tool->stat ==NULL ) tool->stat = process_stat_stub; +if (tool->stat_round ==NULL ) + tool->stat_round = process_stat_round_stub; }static void swap_sample_id_all (union perf_event *event,void *data)
@@ -729,6 +740,13 @@ static void perf_event__stat_swap(union perf_event *event, event->stat.run =bswap_64 (event->stat.run); } +static void perf_event__stat_round_swap (union perf_event *event, +bool sample_id_all__maybe_unused ) +{ + event->stat_round.type =bswap_64 (event->stat_round.type); + event->stat_round.time =bswap_64 (event->stat_round.time); +} +typedef void (*perf_event__swap_op )(union perf_event *event,bool sample_id_all);
@@ -760,6 +778,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { [PERF_RECORD_CPU_MAP] = perf_event__cpu_map_swap, [PERF_RECORD_STAT_CONFIG] = perf_event__stat_config_swap, [PERF_RECORD_STAT] = perf_event__stat_swap, + [PERF_RECORD_STAT_ROUND] = perf_event__stat_round_swap, [PERF_RECORD_HEADER_MAX] = NULL, };
@@ -1304,6 +1323,8 @@ static s64 perf_session__process_user_event(struct perf_session *session,return tool->stat_config (tool, event, session);case PERF_RECORD_STAT :return tool->stat (tool, event, session); +case PERF_RECORD_STAT_ROUND : +return tool->stat_round (tool, event, session);default :return -EINVAL ; }
tools/perf/util/tool.h +2 -1
@@ -59,7 +59,8 @@ struct perf_tool { thread_map, cpu_map, stat_config, - stat; + stat, + stat_round;event_op3 auxtrace;bool ordered_events;bool ordering_requires_timestamps;
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 16/43 perf tools: Add stat round event synthesize function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Introduce the perf_event__synthesize_stat_round function to synthesize a 'struct stat_round_event'.
--- tools/perf/tests/builtin-test.c | 4 ++++ tools/perf/tests/stat.c | 21 +++++++++++++++++++++ tools/perf/tests/tests.h | 1 + tools/perf/util/event.c | 17 +++++++++++++++++ tools/perf/util/event.h | 4 ++++ 5 files changed, 47 insertions(+)
tools/perf/tests/builtin-test.c +4 -0
@@ -196,6 +196,10 @@ static struct test generic_tests[] = { .func = test__synthesize_stat, }, { + .desc = "Test stat round synthesize", + .func = test__synthesize_stat_round, + }, + { .func = NULL, }, };
tools/perf/tests/stat.c +21 -0
@@ -88,3 +88,24 @@ int test__synthesize_stat(int subtest __maybe_unused)return 0 ; } + +static int process_stat_round_event (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_sample *sample__maybe_unused , +struct machine *machine__maybe_unused ) +{ +struct stat_round_event *stat_round = &event->stat_round; + +TEST_ASSERT_VAL ("wrong time" , stat_round->time ==0xdeadbeef ); +TEST_ASSERT_VAL ("wrong type" , stat_round->type ==PERF_STAT_ROUND_TYPE__INTERVAL ); +return 0 ; +} + +int test__synthesize_stat_round (int subtest__maybe_unused ) +{ +TEST_ASSERT_VAL ("failed to synthesize stat_config" , + !perf_event__synthesize_stat_round (NULL ,0xdeadbeef ,PERF_STAT_ROUND_TYPE__INTERVAL , + process_stat_round_event,NULL )); + +return 0 ; +}
tools/perf/tests/tests.h +1 -0
@@ -83,6 +83,7 @@ int test__thread_map_synthesize(int subtest);int test__cpu_map_synthesize (int subtest);int test__synthesize_stat_config (int subtest);int test__synthesize_stat (int subtest); +int test__synthesize_stat_round (int subtest);#if defined(__arm__) || defined(__aarch64__)#ifdef HAVE_DWARF_UNWIND_SUPPORT
tools/perf/util/event.c +17 -0
@@ -933,6 +933,23 @@ int perf_event__synthesize_stat(struct perf_tool *tool,return process (tool, (union perf_event *) &event,NULL , machine); } +int perf_event__synthesize_stat_round (struct perf_tool *tool, +u64 evtime,u64 type, +perf_event__handler_t process, +struct machine *machine) +{ +struct stat_round_event event; + + event.header.type =PERF_RECORD_STAT_ROUND ; + event.header.size =sizeof (event); + event.header.misc =0 ; + + event.time = evtime; + event.type = type; + +return process (tool, (union perf_event *) &event,NULL , machine); +} +void perf_event__read_stat_config (struct perf_stat_config *config,struct stat_config_event *event) {
tools/perf/util/event.h +4 -0
@@ -517,6 +517,10 @@ int perf_event__synthesize_stat(struct perf_tool *tool,struct perf_counts_values *count, perf_event__handler_t process, struct machine *machine); +int perf_event__synthesize_stat_round (struct perf_tool *tool, +u64 time,u64 type, +perf_event__handler_t process, +struct machine *machine);int perf_event__synthesize_modules (struct perf_tool *tool,perf_event__handler_t process,struct machine *machine);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 17/43 perf tools: Add stat events fprintf functions
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Introducing the following functions to display the stat events for raw dump.
perf_event__fprintf_stat
perf_event__fprintf_stat_round
perf_event__fprintf_stat_config
--- tools/perf/util/stat.c | 39 +++++++++++++++++++++++++++++++++++++++ tools/perf/util/stat.h | 4 ++++ 2 files changed, 43 insertions(+)
tools/perf/util/stat.c +39 -0
@@ -364,3 +364,42 @@ int perf_event__process_stat_event(struct perf_tool *tool __maybe_unused, counter->supported = true;return 0 ; } + +size_t perf_event__fprintf_stat (union perf_event *event,FILE *fp) +{ +struct stat_event *st = (struct stat_event *) event; +size_t ret; + + ret =fprintf (fp,"\n... id %" PRIu64", cpu %d, thread %d\n" , + st->id, st->cpu, st->thread); + ret +=fprintf (fp,"... value %" PRIu64", enabled %" PRIu64", running %" PRIu64"\n" , + st->val, st->ena, st->run); + +return ret; +} + +size_t perf_event__fprintf_stat_round (union perf_event *event,FILE *fp) +{ +struct stat_round_event *rd = (struct stat_round_event *)event; +size_t ret; + + ret =fprintf (fp,"\n... time %" PRIu64", type %s\n" , rd->time, + rd->type ==PERF_STAT_ROUND_TYPE__FINAL ?"FINAL" :"INTERVAL" ); + +return ret; +} + +size_t perf_event__fprintf_stat_config (union perf_event *event,FILE *fp) +{ +struct perf_stat_config sc; +size_t ret; + +perf_event__read_stat_config (&sc, &event->stat_config); + + ret =fprintf (fp,"\n" ); + ret +=fprintf (fp,"... aggr_mode %d\n" , sc.aggr_mode); + ret +=fprintf (fp,"... scale %d\n" , sc.scale); + ret +=fprintf (fp,"... interval %u\n" , sc.interval); + +return ret; +}
tools/perf/util/stat.h +4 -0
@@ -96,4 +96,8 @@ struct perf_session;int perf_event__process_stat_event (struct perf_tool *tool,union perf_event *event,struct perf_session *session); + +size_t perf_event__fprintf_stat (union perf_event *event,FILE *fp); +size_t perf_event__fprintf_stat_round (union perf_event *event,FILE *fp); +size_t perf_event__fprintf_stat_config (union perf_event *event,FILE *fp);#endif
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 18/43 perf tools: Add event_update user level event
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
It'll serve as a base event for additional event attributes details, that are not part of the attr event.
At the moment this event is just a dummy one without any specific functionality. The type value will distinguish the update event details. It'll come in the following patches.
The idea for this event is to be extensible for any update that the event might need in the future.
--- tools/perf/util/event.c | 1 + tools/perf/util/event.h | 10 ++++++++++ tools/perf/util/header.c | 20 ++++++++++++++++++++ tools/perf/util/header.h | 3 +++ tools/perf/util/session.c | 21 +++++++++++++++++++++ tools/perf/util/tool.h | 1 + 6 files changed, 56 insertions(+)
tools/perf/util/event.c +1 -0
@@ -44,6 +44,7 @@ static const char *perf_event__names[] = { [PERF_RECORD_STAT_CONFIG] = "STAT_CONFIG", [PERF_RECORD_STAT] = "STAT", [PERF_RECORD_STAT_ROUND] = "STAT_ROUND", + [PERF_RECORD_EVENT_UPDATE] = "EVENT_UPDATE", };const char *perf_event__name (unsigned int id)
tools/perf/util/event.h +10 -0
@@ -231,6 +231,7 @@ enum perf_user_event_type { /* above any possible kernel type */PERF_RECORD_STAT_CONFIG =75 ,PERF_RECORD_STAT =76 ,PERF_RECORD_STAT_ROUND =77 , +PERF_RECORD_EVENT_UPDATE =78 , PERF_RECORD_HEADER_MAX };
@@ -307,6 +308,14 @@ struct attr_event {u64 id[]; }; +struct event_update_event { +struct perf_event_header header; +u64 type; +u64 id; + +char data[]; +}; +#define MAX_EVENT_NAME 64struct perf_trace_event_type {
@@ -456,6 +465,7 @@ union perf_event {struct throttle_event throttle;struct sample_event sample;struct attr_event attr; +struct event_update_event event_update;struct event_type_event event_type;struct tracing_data_event tracing_data;struct build_id_event build_id;
tools/perf/util/header.c +20 -0
@@ -2745,6 +2745,26 @@ int perf_event__process_attr(struct perf_tool *tool __maybe_unused,return 0 ; } +int perf_event__process_event_update (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_evlist **pevlist) +{ +struct event_update_event *ev = &event->event_update; +struct perf_evlist *evlist; +struct perf_evsel *evsel; + +if (!pevlist || *pevlist ==NULL ) +return -EINVAL ; + + evlist = *pevlist; + + evsel =perf_evlist__id2evsel (evlist, ev->id); +if (evsel ==NULL ) +return -EINVAL ; + +return 0 ; +} +int perf_event__synthesize_tracing_data (struct perf_tool *tool,int fd,struct perf_evlist *evlist,perf_event__handler_t process)
tools/perf/util/header.h +3 -0
@@ -107,6 +107,9 @@ int perf_event__synthesize_attrs(struct perf_tool *tool, perf_event__handler_t process);int perf_event__process_attr (struct perf_tool *tool,union perf_event *event,struct perf_evlist **pevlist); +int perf_event__process_event_update (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_evlist **pevlist); int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, struct perf_evlist *evlist,
tools/perf/util/session.c +21 -0
@@ -205,6 +205,15 @@ static int process_event_synth_attr_stub(struct perf_tool *tool __maybe_unused,return 0 ; } +static int process_event_synth_event_update_stub (struct perf_tool *tool__maybe_unused , +union perf_event *event__maybe_unused , +struct perf_evlist **pevlist +__maybe_unused ) +{ +dump_printf (": unhandled!\n" ); +return 0 ; +} + static int process_event_sample_stub(struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused,
@@ -374,6 +383,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool) tool->unthrottle = process_event_stub;if (tool->attr ==NULL ) tool->attr = process_event_synth_attr_stub; +if (tool->event_update ==NULL ) + tool->event_update = process_event_synth_event_update_stub;if (tool->tracing_data ==NULL ) tool->tracing_data = process_event_synth_tracing_data_stub;if (tool->build_id ==NULL )
@@ -625,6 +636,13 @@ static void perf_event__hdr_attr_swap(union perf_event *event,mem_bswap_64 (event->attr.id, size); } +static void perf_event__event_update_swap (union perf_event *event, +bool sample_id_all__maybe_unused ) +{ + event->event_update.type =bswap_64 (event->event_update.type); + event->event_update.id =bswap_64 (event->event_update.id); +} +static void perf_event__event_type_swap (union perf_event *event,bool sample_id_all__maybe_unused ) {
@@ -779,6 +797,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { [PERF_RECORD_STAT_CONFIG] = perf_event__stat_config_swap, [PERF_RECORD_STAT] = perf_event__stat_swap, [PERF_RECORD_STAT_ROUND] = perf_event__stat_round_swap, + [PERF_RECORD_EVENT_UPDATE] = perf_event__event_update_swap, [PERF_RECORD_HEADER_MAX] = NULL, };
@@ -1290,6 +1309,8 @@ static s64 perf_session__process_user_event(struct perf_session *session,perf_session__set_comm_exec (session); }return err; +case PERF_RECORD_EVENT_UPDATE : +return tool->event_update (tool, event, &session->evlist);case PERF_RECORD_HEADER_EVENT_TYPE :/* * Depreceated, but we need to handle it for sake
tools/perf/util/tool.h +1 -0
@@ -50,6 +50,7 @@ struct perf_tool { throttle, unthrottle;event_attr_op attr; +event_attr_op event_update;event_op2 tracing_data;event_oe finished_round; event_op2 build_id,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 19/43 perf tools: Add event_update event unit type
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding unit type 'event update' event, that stores/transfer events unit name. The unit name is part of the perf stat output data.
--- tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test.c | 4 ++++ tools/perf/tests/event_update.c | 42 +++++++++++++++++++++++++++++++++++++++ tools/perf/tests/tests.h | 1 + tools/perf/util/event.h | 4 ++++ tools/perf/util/header.c | 44 +++++++++++++++++++++++++++++++++++++++++ tools/perf/util/header.h | 3 +++ 7 files changed, 99 insertions(+) create mode 100644 tools/perf/tests/event_update.c
tools/perf/tests/Build +1 -0
@@ -36,6 +36,7 @@ perf-y += bpf.o perf-y += topology.o perf-y += cpumap.o perf-y += stat.o +perf-y += event_update.o $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build $(call rule_mkdir)
tools/perf/tests/builtin-test.c +4 -0
@@ -200,6 +200,10 @@ static struct test generic_tests[] = { .func = test__synthesize_stat_round, }, { + .desc = "Test attr update synthesize", + .func = test__event_update, + }, + { .func = NULL, }, };
tools/perf/tests/event_update.c new file +42 -0
42 lines not on this page · raw message
tools/perf/tests/tests.h +1 -0
@@ -84,6 +84,7 @@ int test__cpu_map_synthesize(int subtest);int test__synthesize_stat_config (int subtest);int test__synthesize_stat (int subtest);int test__synthesize_stat_round (int subtest); +int test__event_update (int subtest);#if defined(__arm__) || defined(__aarch64__)#ifdef HAVE_DWARF_UNWIND_SUPPORT
tools/perf/util/event.h +4 -0
@@ -308,6 +308,10 @@ struct attr_event {u64 id[]; }; +enum { +PERF_EVENT_UPDATE__UNIT =0 , +}; +struct event_update_event {struct perf_event_header header;u64 type;
tools/perf/util/header.c +44 -0
56 lines not on this page · raw message
tools/perf/util/header.h +3 -0
@@ -105,6 +105,9 @@ int perf_event__synthesize_attr(struct perf_tool *tool,int perf_event__synthesize_attrs (struct perf_tool *tool,struct perf_session *session,perf_event__handler_t process); +int perf_event__synthesize_event_update_unit (struct perf_tool *tool, +struct perf_evsel *evsel, +perf_event__handler_t process);int perf_event__process_attr (struct perf_tool *tool,union perf_event *event,struct perf_evlist **pevlist); int perf_event__process_event_update(struct perf_tool *tool __maybe_unused,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 20/43 perf tools: Add event_update event scale type
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
A__allocdding scale type 'event update' event, that stores/transfer events scale value. The PMU events can define the scale value which is used to multiply events data.
--- tools/perf/tests/event_update.c | 21 +++++++++++++++++++++ tools/perf/util/event.h | 5 +++++ tools/perf/util/header.c | 26 ++++++++++++++++++++++++++ tools/perf/util/header.h | 3 +++ 4 files changed, 55 insertions(+)
tools/perf/tests/event_update.c +21 -0
@@ -18,6 +18,22 @@ static int process_event_unit(struct perf_tool *tool __maybe_unused,return 0 ; } +static int process_event_scale (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_sample *sample__maybe_unused , +struct machine *machine__maybe_unused ) +{ +struct event_update_event *ev = (struct event_update_event *) event; +struct event_update_event_scale *ev_data; + + ev_data = (struct event_update_event_scale *) ev->data; + +TEST_ASSERT_VAL ("wrong id" , ev->id ==123 ); +TEST_ASSERT_VAL ("wrong id" , ev->type ==PERF_EVENT_UPDATE__SCALE ); +TEST_ASSERT_VAL ("wrong scale" , ev_data->scale =0.123 ); +return 0 ; +} +int test__event_update (int subtest__maybe_unused ) {struct perf_evlist *evlist;
@@ -38,5 +54,10 @@ int test__event_update(int subtest __maybe_unused)TEST_ASSERT_VAL ("failed to synthesize attr update unit" , !perf_event__synthesize_event_update_unit (NULL , evsel, process_event_unit)); + evsel->scale =0.123 ; + +TEST_ASSERT_VAL ("failed to synthesize attr update scale" , + !perf_event__synthesize_event_update_scale (NULL , evsel, process_event_scale)); +return 0 ; }
tools/perf/util/event.h +5 -0
@@ -310,6 +310,11 @@ struct attr_event {enum {PERF_EVENT_UPDATE__UNIT =0 , +PERF_EVENT_UPDATE__SCALE =1 , +}; + +struct event_update_event_scale { +double scale; };struct event_update_event {
tools/perf/util/header.c +26 -0
@@ -2723,6 +2723,27 @@ perf_event__synthesize_event_update_unit(struct perf_tool *tool,return err; } +int +perf_event__synthesize_event_update_scale (struct perf_tool *tool, +struct perf_evsel *evsel, +perf_event__handler_t process) +{ +struct event_update_event *ev; +struct event_update_event_scale *ev_data; +int err; + + ev =event_update_event__new (sizeof (*ev_data),PERF_EVENT_UPDATE__SCALE , evsel->id[0 ]); +if (ev ==NULL ) +return -ENOMEM ; + + ev_data = (struct event_update_event_scale *) ev->data; + ev_data->scale = evsel->scale; + err =process (tool, (union perf_event *) ev,NULL ,NULL ); +free (ev); +return err; +} + +int perf_event__synthesize_attrs (struct perf_tool *tool,struct perf_session *session,perf_event__handler_t process)
@@ -2787,6 +2808,7 @@ int perf_event__process_event_update(struct perf_tool *tool __maybe_unused, struct perf_evlist **pevlist) {struct event_update_event *ev = &event->event_update; +struct event_update_event_scale *ev_scale;struct perf_evlist *evlist;struct perf_evsel *evsel;
@@ -2802,6 +2824,10 @@ int perf_event__process_event_update(struct perf_tool *tool __maybe_unused,switch (ev->type) {case PERF_EVENT_UPDATE__UNIT : evsel->unit =strdup (ev->data); +break ; +case PERF_EVENT_UPDATE__SCALE : + ev_scale = (struct event_update_event_scale *) ev->data; + evsel->scale = ev_scale->scale;default :break ; }
tools/perf/util/header.h +3 -0
@@ -108,6 +108,9 @@ int perf_event__synthesize_attrs(struct perf_tool *tool,int perf_event__synthesize_event_update_unit (struct perf_tool *tool,struct perf_evsel *evsel,perf_event__handler_t process); +int perf_event__synthesize_event_update_scale (struct perf_tool *tool, +struct perf_evsel *evsel, +perf_event__handler_t process);int perf_event__process_attr (struct perf_tool *tool,union perf_event *event,struct perf_evlist **pevlist); int perf_event__process_event_update(struct perf_tool *tool __maybe_unused,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 21/43 perf tools: Add event_update event name type
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding name type 'event update' event, that stores/transfer events name. Event's name is stored within perf.data's EVENT_DESC feature, but we don't have it if we get the report data from pipe.
--- tools/perf/tests/event_update.c | 25 +++++++++++++++++++++++++ tools/perf/util/event.h | 1 + tools/perf/util/header.c | 21 +++++++++++++++++++++ tools/perf/util/header.h | 3 +++ 4 files changed, 50 insertions(+)
tools/perf/tests/event_update.c +25 -0
@@ -34,10 +34,30 @@ static int process_event_scale(struct perf_tool *tool __maybe_unused,return 0 ; } +struct event_name { +struct perf_tool tool; +const char *name; +}; + +static int process_event_name (struct perf_tool *tool, +union perf_event *event, +struct perf_sample *sample__maybe_unused , +struct machine *machine__maybe_unused ) +{ + struct event_name *tmp = container_of(tool, struct event_name, tool); +struct event_update_event *ev = (struct event_update_event *) event; + +TEST_ASSERT_VAL ("wrong id" , ev->id ==123 ); +TEST_ASSERT_VAL ("wrong id" , ev->type ==PERF_EVENT_UPDATE__NAME ); +TEST_ASSERT_VAL ("wrong name" , !strcmp (ev->data, tmp->name)); +return 0 ; +} +int test__event_update (int subtest__maybe_unused ) {struct perf_evlist *evlist;struct perf_evsel *evsel; +struct event_name tmp; evlist =perf_evlist__new_default ();TEST_ASSERT_VAL ("failed to get evlist" , evlist);
@@ -59,5 +79,10 @@ int test__event_update(int subtest __maybe_unused)TEST_ASSERT_VAL ("failed to synthesize attr update scale" , !perf_event__synthesize_event_update_scale (NULL , evsel, process_event_scale)); + tmp.name =perf_evsel__name (evsel); + +TEST_ASSERT_VAL ("failed to synthesize attr update name" , + !perf_event__synthesize_event_update_name (&tmp.tool, evsel, process_event_name)); +return 0 ; }
tools/perf/util/event.h +1 -0
@@ -311,6 +311,7 @@ struct attr_event {enum {PERF_EVENT_UPDATE__UNIT =0 ,PERF_EVENT_UPDATE__SCALE =1 , +PERF_EVENT_UPDATE__NAME =2 , };struct event_update_event_scale {
tools/perf/util/header.c +21 -0
@@ -2743,6 +2743,24 @@ perf_event__synthesize_event_update_scale(struct perf_tool *tool,return err; } +int +perf_event__synthesize_event_update_name (struct perf_tool *tool, +struct perf_evsel *evsel, +perf_event__handler_t process) +{ +struct event_update_event *ev; +size_t len =strlen (evsel->name); +int err; + + ev =event_update_event__new (len +1 ,PERF_EVENT_UPDATE__NAME , evsel->id[0 ]); +if (ev ==NULL ) +return -ENOMEM ; + +strncpy (ev->data, evsel->name, len); + err =process (tool, (union perf_event *) ev,NULL ,NULL ); +free (ev); +return err; +} int perf_event__synthesize_attrs(struct perf_tool *tool, struct perf_session *session,
@@ -2825,6 +2843,9 @@ int perf_event__process_event_update(struct perf_tool *tool __maybe_unused,case PERF_EVENT_UPDATE__UNIT : evsel->unit =strdup (ev->data);break ; +case PERF_EVENT_UPDATE__NAME : + evsel->name =strdup (ev->data); +break ;case PERF_EVENT_UPDATE__SCALE : ev_scale = (struct event_update_event_scale *) ev->data; evsel->scale = ev_scale->scale;
tools/perf/util/header.h +3 -0
@@ -111,6 +111,9 @@ int perf_event__synthesize_event_update_unit(struct perf_tool *tool,int perf_event__synthesize_event_update_scale (struct perf_tool *tool,struct perf_evsel *evsel,perf_event__handler_t process); +int perf_event__synthesize_event_update_name (struct perf_tool *tool, +struct perf_evsel *evsel, +perf_event__handler_t process);int perf_event__process_attr (struct perf_tool *tool,union perf_event *event,struct perf_evlist **pevlist); int perf_event__process_event_update(struct perf_tool *tool __maybe_unused,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 22/43 perf tools: Add event_update event cpus type
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding the cpumask 'event update' event, that stores/transfer the cpumask for a event.
--- tools/perf/tests/event_update.c | 29 ++++++++++++++++++++++++++++ tools/perf/util/event.h | 5 +++++ tools/perf/util/header.c | 42 +++++++++++++++++++++++++++++++++++++++++ tools/perf/util/header.h | 3 +++ 4 files changed, 79 insertions(+)
tools/perf/tests/event_update.c +29 -0
@@ -53,6 +53,29 @@ static int process_event_name(struct perf_tool *tool,return 0 ; } +static int process_event_cpus (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_sample *sample__maybe_unused , +struct machine *machine__maybe_unused ) +{ +struct event_update_event *ev = (struct event_update_event *) event; +struct event_update_event_cpus *ev_data; +struct cpu_map *map; + + ev_data = (struct event_update_event_cpus *) ev->data; + + map =cpu_map__new_data (&ev_data->cpus); + +TEST_ASSERT_VAL ("wrong id" , ev->id ==123 ); +TEST_ASSERT_VAL ("wrong type" , ev->type ==PERF_EVENT_UPDATE__CPUS ); +TEST_ASSERT_VAL ("wrong cpus" , map->nr ==3 ); +TEST_ASSERT_VAL ("wrong cpus" , map->map[0 ] ==1 ); +TEST_ASSERT_VAL ("wrong cpus" , map->map[1 ] ==2 ); +TEST_ASSERT_VAL ("wrong cpus" , map->map[2 ] ==3 ); +cpu_map__put (map); +return 0 ; +} +int test__event_update (int subtest__maybe_unused ) {struct perf_evlist *evlist;
@@ -84,5 +107,11 @@ int test__event_update(int subtest __maybe_unused)TEST_ASSERT_VAL ("failed to synthesize attr update name" , !perf_event__synthesize_event_update_name (&tmp.tool, evsel, process_event_name)); + evsel->own_cpus =cpu_map__new ("1,2,3" ); + +TEST_ASSERT_VAL ("failed to synthesize attr update cpus" , + !perf_event__synthesize_event_update_cpus (&tmp.tool, evsel, process_event_cpus)); + +cpu_map__put (evsel->own_cpus);return 0 ; }
tools/perf/util/event.h +5 -0
@@ -312,6 +312,11 @@ enum {PERF_EVENT_UPDATE__UNIT =0 ,PERF_EVENT_UPDATE__SCALE =1 ,PERF_EVENT_UPDATE__NAME =2 , + PERF_EVENT_UPDATE__CPUS = 3, +}; + +struct event_update_event_cpus { +struct cpu_map_data cpus; }; struct event_update_event_scale {
tools/perf/util/header.c +42 -0
62 lines not on this page · raw message
tools/perf/util/header.h +3 -0
@@ -114,6 +114,9 @@ int perf_event__synthesize_event_update_scale(struct perf_tool *tool,int perf_event__synthesize_event_update_name (struct perf_tool *tool,struct perf_evsel *evsel,perf_event__handler_t process); +int perf_event__synthesize_event_update_cpus (struct perf_tool *tool, +struct perf_evsel *evsel, +perf_event__handler_t process);int perf_event__process_attr (struct perf_tool *tool,union perf_event *event,struct perf_evlist **pevlist); int perf_event__process_event_update(struct perf_tool *tool __maybe_unused,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 23/43 perf tools: Add perf_event__fprintf_event_update function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
To display a 'event update' event for raw dump.
--- tools/perf/util/header.c | 38 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/header.h | 1 + 2 files changed, 39 insertions(+)
tools/perf/util/header.c +38 -0
@@ -2793,6 +2793,44 @@ perf_event__synthesize_event_update_cpus(struct perf_tool *tool,return err; } +size_t perf_event__fprintf_event_update (union perf_event *event,FILE *fp) +{ +struct event_update_event *ev = &event->event_update; +struct event_update_event_scale *ev_scale; +struct event_update_event_cpus *ev_cpus; +struct cpu_map *map; +size_t ret; + + ret =fprintf (fp,"\n... id: %" PRIu64"\n" , ev->id); + +switch (ev->type) { +case PERF_EVENT_UPDATE__SCALE : + ev_scale = (struct event_update_event_scale *) ev->data; + ret +=fprintf (fp,"... scale: %f\n" , ev_scale->scale); +break ; +case PERF_EVENT_UPDATE__UNIT : + ret +=fprintf (fp,"... unit: %s\n" , ev->data); +break ; +case PERF_EVENT_UPDATE__NAME : + ret +=fprintf (fp,"... name: %s\n" , ev->data); +break ; +case PERF_EVENT_UPDATE__CPUS : + ev_cpus = (struct event_update_event_cpus *) ev->data; + ret +=fprintf (fp,"... " ); + + map =cpu_map__new_data (&ev_cpus->cpus); +if (map) + ret +=cpu_map__fprintf (map, fp); +else + ret +=fprintf (fp,"failed to get cpus\n" ); +break ; +default : + ret +=fprintf (fp,"... unknown type\n" ); +break ; + } + +return ret; +} int perf_event__synthesize_attrs(struct perf_tool *tool, struct perf_session *session,
tools/perf/util/header.h +1 -0
@@ -122,6 +122,7 @@ int perf_event__process_attr(struct perf_tool *tool, union perf_event *event,int perf_event__process_event_update (struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_evlist **pevlist); +size_t perf_event__fprintf_event_update (union perf_event *event,FILE *fp); int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, struct perf_evlist *evlist,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 24/43 perf report: Display newly added events in raw dump
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
The 'perf report -D' command will now display detailed output for these newly added events:
event_update
thread_map
cpu_map
stat
stat_config
stat_round
--- tools/perf/util/session.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
tools/perf/util/session.c +19 -0
@@ -17,6 +17,7 @@#include "asm/bug.h" #include "auxtrace.h" #include "thread-stack.h" +#include "stat.h" static int perf_session__deliver_event(struct perf_session *session, union perf_event *event,
@@ -210,6 +211,9 @@ static int process_event_synth_event_update_stub(struct perf_tool *tool __maybe_struct perf_evlist **pevlist __maybe_unused) { +if (dump_trace) +perf_event__fprintf_event_update (event, stdout); +dump_printf (": unhandled!\n" );return 0 ; }
@@ -311,6 +315,9 @@ int process_event_thread_map_stub(struct perf_tool *tool __maybe_unused,union perf_event *event__maybe_unused , struct perf_session *session __maybe_unused) { + if (dump_trace) + perf_event__fprintf_thread_map(event, stdout); + dump_printf(": unhandled!\n");return 0 ; }
@@ -320,6 +327,9 @@ int process_event_cpu_map_stub(struct perf_tool *tool __maybe_unused,union perf_event *event__maybe_unused , struct perf_session *session __maybe_unused) { + if (dump_trace) + perf_event__fprintf_cpu_map(event, stdout); + dump_printf(": unhandled!\n");return 0 ; }
@@ -329,6 +339,9 @@ int process_event_stat_config_stub(struct perf_tool *tool __maybe_unused,union perf_event *event__maybe_unused , struct perf_session *session __maybe_unused) { + if (dump_trace) + perf_event__fprintf_stat_config(event, stdout); + dump_printf(": unhandled!\n");return 0 ; }
@@ -338,6 +351,9 @@ static int process_stat_stub(struct perf_tool *tool __maybe_unused,struct perf_session *perf_session __maybe_unused) { +if (dump_trace) +perf_event__fprintf_stat (event, stdout); +dump_printf (": unhandled!\n" );return 0 ; }
@@ -347,6 +363,9 @@ static int process_stat_round_stub(struct perf_tool *tool __maybe_unused,struct perf_session *perf_session __maybe_unused) { +if (dump_trace) +perf_event__fprintf_stat_round (event, stdout); +dump_printf (": unhandled!\n" );return 0 ; }
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 25/43 perf tools: Introduce stat perf.data header feature
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Introducing the 'stat' feature to mark a perf.data as created by the 'perf stat record' command. It contains no data.
It's needed so that the report tools (report/script) can differentiate sampling data from counting data, because they need to be treated in a different way.
In the future it might be used to store the version of the stat storage system used.
--- tools/perf/builtin-record.c | 2 ++ tools/perf/util/header.c | 14 ++++++++++++++ tools/perf/util/header.h | 1 + 3 files changed, 17 insertions(+)
tools/perf/builtin-record.c +2 -0
@@ -452,6 +452,8 @@ static void record__init_features(struct record *rec)if (!rec->opts.full_auxtrace)perf_header__clear_feat (&session->header,HEADER_AUXTRACE ); + +perf_header__clear_feat (&session->header,HEADER_STAT ); }static volatile int workload_exec_errno;
tools/perf/util/header.c +14 -0
@@ -868,6 +868,13 @@ static int write_auxtrace(int fd, struct perf_header *h,return err; } +static int write_stat (int fd__maybe_unused , +struct perf_header *h__maybe_unused , +struct perf_evlist *evlist__maybe_unused ) +{ +return 0 ; +} +static void print_hostname (struct perf_header *ph,int fd__maybe_unused ,FILE *fp) {
@@ -1159,6 +1166,12 @@ static void print_auxtrace(struct perf_header *ph __maybe_unused,fprintf (fp,"# contains AUX area data (e.g. instruction trace)\n" ); } +static void print_stat (struct perf_header *ph__maybe_unused , +int fd__maybe_unused ,FILE *fp) +{ +fprintf (fp,"# contains stat data\n" ); +} +static void print_pmu_mappings (struct perf_header *ph,int fd__maybe_unused ,FILE *fp) {
@@ -1948,6 +1961,7 @@ static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = {FEAT_OPP (HEADER_PMU_MAPPINGS , pmu_mappings),FEAT_OPP (HEADER_GROUP_DESC , group_desc),FEAT_OPP (HEADER_AUXTRACE , auxtrace), + FEAT_OPA(HEADER_STAT, stat), }; struct header_print_data {
tools/perf/util/header.h +1 -0
@@ -31,6 +31,7 @@ enum {HEADER_PMU_MAPPINGS ,HEADER_GROUP_DESC ,HEADER_AUXTRACE , +HEADER_STAT ,HEADER_LAST_FEATURE , HEADER_FEAT_BITS = 256, };
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 26/43 perf stat record: Add record command
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Add 'perf stat record' command support. It creates simple (header only) perf.data file ATM.
The record command could be specified anywhere among stat options. All stat command options are valid for stat record command with '-o' option exception. If specified for record command it denotes the perf data file name.
Committer note:
Set sample_type to PERF_SAMPLE_IDENTIFIER, which should be harmless while avoiding that older tools show confusing messages, for instance, with sample_type = 0, we get:
$ perf stat record usleep 1
Performance counter stats for 'usleep 1':
0.630237 task-clock (msec) # 0.528 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
52 page-faults # 0.083 M/sec
978,312 cycles # 1.552 GHz
671,931 stalled-cycles-frontend # 68.68% frontend cycles idle
<not supported> stalled-cycles-backend
646,379 instructions # 0.66 insns per cycle # 1.04 stalled cycles per insn
131,046 branches # 207.931 M/sec
7,073 branch-misses # 5.40% of all branches
0.001193240 seconds time elapsed
$ oldperf evlist WARNING: The perf.data file's data size field is 0 which is unexpected. Was the 'perf record' command properly terminated? non matching sample_type $
While with sample_type set to PERF_SAMPLE_IDENTIFIER, after we re-run 'perf stat record usleep' we get:
$ oldperf evlist WARNING: The perf.data file's data size field is 0 which is unexpected. Was the 'perf record' command properly terminated? task-clock context-switches cpu-migrations page-faults cycles stalled-cycles-frontend stalled-cycles-backend instructions branches branch-misses $
Which at least shows the names of the events in the perf.data file.
Additionally, such files, when passed to 'perf report' will produce:
$ oldperf report --stdio
WARNING: The perf.data file's data size field is 0 which is unexpected.
Was the 'perf record' command properly terminated?
Warning:
Kernel address maps (/proc/{kallsyms,modules}) were restricted. Check /proc/sys/kernel/kptr_restrict before running 'perf record'.
As no suitable kallsyms nor vmlinux was found, kernel samples can't be resolved.
Samples in kernel modules can't be resolved as well.
Error:
The perf.data file has no samples!
# To display the perf.data header info, please use --header/--header-only options. #
$
Which is confusing and can be solved by just adding the kernel mmap record, which will also remove that warning about the data size field being equal to zero, after generating the mmap record:
$ perf stat record usleep 1
Performance counter stats for 'usleep 1':
0.600796 task-clock (msec) # 0.478 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
54 page-faults # 0.090 M/sec
886,844 cycles # 1.476 GHz
582,169 stalled-cycles-frontend # 65.65% frontend cycles idle
<not supported> stalled-cycles-backend
638,344 instructions # 0.72 insns per cycle # 0.91 stalled cycles per insn
130,204 branches # 216.719 M/sec
7,500 branch-misses # 5.76% of all branches
0.001255897 seconds time elapsed
$ oldperf evlist task-clock context-switches cpu-migrations page-faults cycles stalled-cycles-frontend stalled-cycles-backend instructions branches branch-misses $ oldperf report --stdio Error: The perf.data file has no samples! # To display the perf.data header info, please use --header/--header-only options. # [acme@zoo linux]$
No warnings, sensible output about what are the events in the perf.data file and also a "file has no samples" message, which indeed it doesn't.
--- tools/perf/Documentation/perf-stat.txt | 12 ++++ tools/perf/builtin-stat.c | 120 +++++++++++++++++++++++++++++++-- 2 files changed, 128 insertions(+), 4 deletions(-)
tools/perf/Documentation/perf-stat.txt +12 -0
@@ -10,6 +10,7 @@ SYNOPSIS [verse] 'perf stat' [-e <EVENT> | --event=EVENT] [-a] <command> 'perf stat' [-e <EVENT> | --event=EVENT] [-a] -- <command> [<options>] +'perf stat' [-e <EVENT> | --event=EVENT] [-a] record [-o file] -- <command> [<options>] DESCRIPTION -----------
@@ -22,6 +23,8 @@ OPTIONS <command>...:: Any command you can specify in a shell. +record:: + See STAT RECORD. -e:: --event=::
@@ -159,6 +162,15 @@ filter out the startup phase of the program, which is often very different. Print statistics of transactional execution if supported. +STAT RECORD +----------- +Stores stat data into perf data file. + +-o file:: +--output file:: +Output file name. + + EXAMPLES --------
tools/perf/builtin-stat.c +116 -4
177 lines not on this page · raw message
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 27/43 perf stat record: Initialize record features
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Disabling all non stat related features.
Also as we now enable STAT feature in the data file, adding code to instruct session open to skip sample type checking for stat data files.
--- tools/perf/builtin-stat.c | 15 +++++++++++++++ tools/perf/util/session.c | 3 +++ 2 files changed, 18 insertions(+)
tools/perf/builtin-stat.c +15 -0
@@ -1310,6 +1310,19 @@ static const char * const recort_usage[] = { NULL, }; +static void init_features (struct perf_session *session) +{ +int feat; + +for (feat =HEADER_FIRST_FEATURE ; feat <HEADER_LAST_FEATURE ; feat++) +perf_header__set_feat (&session->header, feat); + +perf_header__clear_feat (&session->header,HEADER_BUILD_ID ); +perf_header__clear_feat (&session->header,HEADER_TRACING_DATA ); +perf_header__clear_feat (&session->header,HEADER_BRANCH_STACK ); +perf_header__clear_feat (&session->header,HEADER_AUXTRACE ); +} +static int __cmd_record (int argc,const char **argv) {struct perf_session *session;
@@ -1331,6 +1344,8 @@ static int __cmd_record(int argc, const char **argv)if (perf_stat.file.is_pipe)return -EINVAL ; +init_features (session); + session->evlist = evsel_list; perf_stat.session = session; perf_stat.record = true;
tools/perf/util/session.c +3 -0
@@ -37,6 +37,9 @@ static int perf_session__open(struct perf_session *session)if (perf_data_file__is_pipe (file))return 0 ; +if (perf_header__has_feat (&session->header,HEADER_STAT )) +return 0 ; +if (!perf_evlist__valid_sample_type (session->evlist)) {pr_err ("non matching sample_type\n" );return -1 ;
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 28/43 perf stat record: Synthesize stat record data
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Synthesizing needed stat record data for report/script:
- cpu/thread maps
- stat config
Committer note:
New records generated on a perf.data file with this patch:
$ perf report -D | grep PERF_RECORD_ 0x568 [0x28]: PERF_RECORD_THREAD_MAP nr: 1 thread: 29097 0x590 [0x12]: PERF_RECORD_CPU_MAP nr: 1 cpu: 65535 0x5a2 [0x40]: PERF_RECORD_STAT_CONFIG $
--- tools/perf/builtin-stat.c | 56 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 13 deletions(-)
tools/perf/builtin-stat.c +43 -13
@@ -217,26 +217,20 @@ static inline int nsec_counter(struct perf_evsel *evsel)return 0 ; } -static int perf_stat__write (struct perf_stat *stat,void *bf,size_t size) +static int process_synthesized_event (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_sample *sample__maybe_unused , +struct machine *machine__maybe_unused ) { -if (perf_data_file__write (stat->session->file, bf, size) <0 ) { +if (perf_data_file__write (&perf_stat.file, event, event->header.size) <0 ) {pr_err ("failed to write perf data, error: %m\n" );return -1 ; } - stat->bytes_written += size; + perf_stat.bytes_written += event->header.size;return 0 ; } -static int process_synthesized_event (struct perf_tool *tool, -union perf_event *event, -struct perf_sample *sample__maybe_unused , -struct machine *machine__maybe_unused ) -{ -struct perf_stat *stat = (void *)tool; -return perf_stat__write (stat, event, event->header.size); -} -/* * Read out the results of a single counter: * do not aggregate counts across CPUs in system-wide mode
@@ -323,6 +317,35 @@ static void workload_exec_failed_signal(int signo __maybe_unused, siginfo_t *inf workload_exec_errno = info->si_value.sival_int; } +static int perf_stat_synthesize_config (void ) +{ +int err; + + err =perf_event__synthesize_thread_map2 (NULL , evsel_list->threads, + process_synthesized_event, +NULL ); +if (err <0 ) { +pr_err ("Couldn't synthesize thread map.\n" ); +return err; + } + + err =perf_event__synthesize_cpu_map (NULL , evsel_list->cpus, + process_synthesized_event,NULL ); +if (err <0 ) { +pr_err ("Couldn't synthesize thread map.\n" ); +return err; + } + + err =perf_event__synthesize_stat_config (NULL , &stat_config, + process_synthesized_event,NULL ); +if (err <0 ) { +pr_err ("Couldn't synthesize config.\n" ); +return err; + } + +return 0 ; +} +static int __run_perf_stat (int argc,const char **argv) {int interval = stat_config.interval;
@@ -403,6 +426,10 @@ static int __run_perf_stat(int argc, const char **argv) fd, false);if (err <0 )return err; + + err =perf_stat_synthesize_config (); +if (err <0 ) +return err; }/*
@@ -1560,7 +1587,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)* a saner message about no samples being in the perf.data file. * * This also serves to suppress a warning about f_header.data.size == 0 -* in header.c. -acme +* in header.c at the moment 'perf stat record' gets introduced, which +* is not really needed once we start adding the stat specific PERF_RECORD_ +* records, but the need to suppress the kptr_restrict messages in older +* tools remain -acme */ int fd =perf_data_file__fd (&perf_stat.file); int err = perf_event__synthesize_kernel_mmap((void *)&perf_stat,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 29/43 perf evlist: Export id_add_fd()
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Will be used to storing the event IDs in evlist object so it get stored into perf.data file.
--- tools/perf/util/evlist.c | 6 +++--- tools/perf/util/evlist.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-)
tools/perf/util/evlist.c +3 -3
@@ -534,9 +534,9 @@ void perf_evlist__id_add(struct perf_evlist *evlist, struct perf_evsel *evsel, evsel->id[evsel->ids++] = id; } -static int perf_evlist__id_add_fd (struct perf_evlist *evlist, -struct perf_evsel *evsel, -int cpu,int thread,int fd) +int perf_evlist__id_add_fd (struct perf_evlist *evlist, +struct perf_evsel *evsel, +int cpu,int thread,int fd) {u64 read_data[4 ] = {0 , };int id_idx =1 ;/* The first entry is the counter value */
tools/perf/util/evlist.h +3 -0
@@ -97,6 +97,9 @@ perf_evlist__find_tracepoint_by_name(struct perf_evlist *evlist,void perf_evlist__id_add (struct perf_evlist *evlist,struct perf_evsel *evsel,int cpu,int thread,u64 id); +int perf_evlist__id_add_fd (struct perf_evlist *evlist, +struct perf_evsel *evsel, +int cpu,int thread,int fd);int perf_evlist__add_pollfd (struct perf_evlist *evlist,int fd);int perf_evlist__alloc_pollfd (struct perf_evlist *evlist);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 30/43 perf stat record: Store events IDs in perf data file
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Store event IDs in evlist object so it get stored into perf.data file.
--- tools/perf/builtin-stat.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
tools/perf/builtin-stat.c +35 -0
@@ -346,6 +346,38 @@ static int perf_stat_synthesize_config(void)return 0 ; } +#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) + +static int __store_counter_ids (struct perf_evsel *counter, +struct cpu_map *cpus, +struct thread_map *threads) +{ +int cpu, thread; + +for (cpu =0 ; cpu < cpus->nr; cpu++) { +for (thread =0 ; thread < threads->nr; thread++) { +int fd =FD (counter, cpu, thread); + +if (perf_evlist__id_add_fd (evsel_list, counter, + cpu, thread, fd) <0 ) +return -1 ; + } + } + +return 0 ; +} + +static int store_counter_ids (struct perf_evsel *counter) +{ +struct cpu_map *cpus = counter->cpus; +struct thread_map *threads = counter->threads; + +if (perf_evsel__alloc_id (counter, cpus->nr, threads->nr)) +return -ENOMEM ; + +return __store_counter_ids (counter, cpus, threads); +} +static int __run_perf_stat (int argc,const char **argv) {int interval = stat_config.interval;
@@ -410,6 +442,9 @@ static int __run_perf_stat(int argc, const char **argv) l =strlen (counter->unit);if (l > unit_width) unit_width = l; + +if (STAT_RECORD &&store_counter_ids (counter)) +return -1 ; }if (perf_evlist__apply_filters (evsel_list, &counter)) {
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 31/43 perf stat record: Add pipe support for record command
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Allowing storing stat record data into pipe, so report tools (report/script) could read data directly from record.
Committer note:
Before this patch:
$ perf stat record -o - usleep 1 | perf report -i - incompatible file format (rerun with -v to learn more) $ perf stat record -o - usleep 1 | perf script -i - incompatible file format (rerun with -v to learn more) $ ls -la perf.data ls: cannot access perf.data: No such file or directory $
After:
$ perf stat record -o - usleep 1 | perf report -i - # To display the perf.data header info, please use # --header/--header-only options. # Error: The - file has no samples! $ perf stat record -o - usleep 1 | perf script -i - Display of symbols requested but neither sample IP nor sample address is selected. Hence, no addresses to convert to symbols. 0 [0x80]: failed to process type: 64 $ ls -la perf.data ls: cannot access perf.data: No such file or directory $
--- tools/perf/builtin-stat.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-)
tools/perf/builtin-stat.c +28 -11
@@ -317,10 +317,19 @@ static void workload_exec_failed_signal(int signo __maybe_unused, siginfo_t *inf workload_exec_errno = info->si_value.sival_int; } -static int perf_stat_synthesize_config (void ) +static int perf_stat_synthesize_config (bool is_pipe) {int err; +if (is_pipe) { + err =perf_event__synthesize_attrs (NULL , perf_stat.session, + process_synthesized_event); +if (err <0 ) { +pr_err ("Couldn't synthesize attrs.\n" ); +return err; + } + } + err =perf_event__synthesize_thread_map2 (NULL , evsel_list->threads, process_synthesized_event,NULL );
@@ -388,6 +397,7 @@ static int __run_perf_stat(int argc, const char **argv)size_t l;int status =0 ;const bool forks = (argc >0 ); +bool is_pipe =STAT_RECORD ? perf_stat.file.is_pipe : false;if (interval) { ts.tv_sec = interval /1000 ;
@@ -398,7 +408,7 @@ static int __run_perf_stat(int argc, const char **argv) }if (forks) { -if (perf_evlist__prepare_workload (evsel_list, &target, argv, false, +if (perf_evlist__prepare_workload (evsel_list, &target, argv, is_pipe, workload_exec_failed_signal) <0 ) {perror ("failed to prepare workload" );return -1 ;
@@ -457,12 +467,17 @@ static int __run_perf_stat(int argc, const char **argv)if (STAT_RECORD ) {int err, fd =perf_data_file__fd (&perf_stat.file); - err =perf_session__write_header (perf_stat.session, evsel_list, - fd, false); +if (is_pipe) { + err =perf_header__write_pipe (perf_data_file__fd (&perf_stat.file)); + }else { + err =perf_session__write_header (perf_stat.session, evsel_list, + fd, false); + } +if (err <0 )return err; - err =perf_stat_synthesize_config (); + err =perf_stat_synthesize_config (is_pipe);if (err <0 )return err; }
@@ -970,6 +985,10 @@ static void print_counters(struct timespec *ts, int argc, const char **argv)struct perf_evsel *counter;char buf[64 ], *prefix =NULL ; +/* Do not print anything if we record to the pipe. */ +if (STAT_RECORD && perf_stat.file.is_pipe) +return ; +if (interval)print_interval (prefix = buf, ts);else
@@ -1402,10 +1421,6 @@ static int __cmd_record(int argc, const char **argv)return -1 ; } -/* No pipe support ATM */ -if (perf_stat.file.is_pipe) -return -EINVAL ; -init_features (session); session->evlist = evsel_list;
@@ -1636,8 +1651,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) "older tools may produce warnings about this file\n."); } - perf_stat.session->header.data_size += perf_stat.bytes_written; -perf_session__write_header (perf_stat.session, evsel_list, fd, true); +if (!perf_stat.file.is_pipe) { + perf_stat.session->header.data_size += perf_stat.bytes_written; +perf_session__write_header (perf_stat.session, evsel_list, fd, true); + }perf_session__delete (perf_stat.session); }
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 32/43 perf stat record: Write stat events on record
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Writing stat events on 'perf stat record' at the time we read counter values from kernel.
Committer note:
After the patch:
$ perf stat record usleep 1
Performance counter stats for 'usleep 1':
0.598006 task-clock (msec) # 0.484 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
52 page-faults # 0.087 M/sec
882,744 cycles # 1.476 GHz
581,416 stalled-cycles-frontend # 65.86% frontend cycles idle
<not supported> stalled-cycles-backend
636,479 instructions # 0.72 insns per cycle # 0.91 stalled cycles per insn
129,334 branches # 216.275 M/sec
7,512 branch-misses # 5.81% of all branches
0.001235157 seconds time elapsed
$ oldperf evlist task-clock context-switches cpu-migrations page-faults cycles stalled-cycles-frontend stalled-cycles-backend instructions branches branch-misses $ oldperf report --stdio Error: The perf.data file has no samples! # To display the perf.data header info, please use --header/--header-only options. # $ perf report -D | grep PERF_RECORD 0x5b0 [0x28]: PERF_RECORD_THREAD_MAP nr: 1 thread: 5504 0x5d8 [0x12]: PERF_RECORD_CPU_MAP nr: 1 cpu: 65535 0x5ea [0x40]: PERF_RECORD_STAT_CONFIG 0x62a [0x30]: PERF_RECORD_STAT 0x65a [0x30]: PERF_RECORD_STAT 0x68a [0x30]: PERF_RECORD_STAT 0x6ba [0x30]: PERF_RECORD_STAT 0x6ea [0x30]: PERF_RECORD_STAT 0x71a [0x30]: PERF_RECORD_STAT 0x74a [0x30]: PERF_RECORD_STAT 0x77a [0x30]: PERF_RECORD_STAT 0x7aa [0x30]: PERF_RECORD_STAT -1 -1 0x7da [0x40]: PERF_RECORD_MMAP -1/0: [0xffffffff81000000(0x1f000000) @ 0xffffffff81000000]: x [kernel.kallsyms]_text $
--- tools/perf/builtin-stat.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
tools/perf/builtin-stat.c +19 -0
@@ -231,6 +231,18 @@ static int process_synthesized_event(struct perf_tool *tool __maybe_unused,return 0 ; } +#define SID (e, x, y) xyarray__entry(e->sample_id, x, y) + +static int +perf_evsel__write_stat_event (struct perf_evsel *counter,u32 cpu,u32 thread, +struct perf_counts_values *count) +{ +struct perf_sample_id *sid =SID (counter, cpu, thread); + +return perf_event__synthesize_stat (NULL , cpu, thread, sid->id, count, + process_synthesized_event,NULL ); +} +/* * Read out the results of a single counter: * do not aggregate counts across CPUs in system-wide mode
@@ -254,6 +266,13 @@ static int read_counter(struct perf_evsel *counter) count =perf_counts (counter->counts, cpu, thread);if (perf_evsel__read (counter, cpu, thread, count))return -1 ; + +if (STAT_RECORD ) { +if (perf_evsel__write_stat_event (counter, cpu, thread, count)) { +pr_err ("failed to write stat event\n" ); +return -1 ; + } + } } }
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 33/43 perf stat record: Write stat round events on record
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Writing stat round events on 'perf stat record' for each interval round. In non interval mode we store round event after the last stat event.
Committer note:
After the patch:
$ perf report -D | grep PERF_RECORD | grep ROUND 0x852 [0x18]: PERF_RECORD_STAT_ROUND $
--- tools/perf/builtin-stat.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
tools/perf/builtin-stat.c +20 -0
@@ -231,6 +231,16 @@ static int process_synthesized_event(struct perf_tool *tool __maybe_unused,return 0 ; } +static int write_stat_round_event (u64 time,u64 type) +{ +return perf_event__synthesize_stat_round (NULL , time, type, + process_synthesized_event, +NULL ); +} + +#define WRITE_STAT_ROUND_EVENT (time, interval) \ + write_stat_round_event(time, PERF_STAT_ROUND_TYPE__ ## interval) +#define SID (e, x, y) xyarray__entry(e->sample_id, x, y) static int
@@ -306,6 +316,11 @@ static void process_interval(void)clock_gettime (CLOCK_MONOTONIC , &ts);diff_timespec (&rs, &ts, &ref_time); +if (STAT_RECORD ) { +if (WRITE_STAT_ROUND_EVENT (rs.tv_sec *NSECS_PER_SEC + rs.tv_nsec,INTERVAL )) +pr_err ("failed to write stat round event\n" ); + } +print_counters (&rs,0 ,NULL ); }
@@ -1670,6 +1685,11 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) "older tools may produce warnings about this file\n."); } +if (!interval) { +if (WRITE_STAT_ROUND_EVENT (walltime_nsecs_stats.max,FINAL )) +pr_err ("failed to write stat round event\n" ); + } +if (!perf_stat.file.is_pipe) { perf_stat.session->header.data_size += perf_stat.bytes_written;perf_session__write_header (perf_stat.session, evsel_list, fd, true);
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 34/43 perf stat record: Do not allow record with multiple runs mode
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
We currently don't support storing multiple session in perf.data, so we can't allow -r option in stat record.
$ perf stat -e cycles -r 2 record ls Cannot use -r option with perf stat record.
Committer note:
Before this patch we would a perf.data file such as:
$ perf stat -e cycles -r 2 record ls <SNIP>
Performance counter stats for 'ls' (2 runs):
3,935,236 cycles
0.002353261 seconds time elapsed ( +- 4.76% )
$ perf report -D | grep PERF_RECORD | grep ROUND 0xf0 [0]: failed to process type: 16 Error: failed to process sample $
--- tools/perf/builtin-stat.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/perf/builtin-stat.c +5 -0
@@ -1449,6 +1449,11 @@ static int __cmd_record(int argc, const char **argv)if (output_name) file->path = output_name; +if (run_count !=1 || forever) { +pr_err ("Cannot use -r option with perf stat record.\n" ); +return -1 ; + } + session =perf_session__new (file, false,NULL );if (session ==NULL ) {pr_err ("Perf session creation failed.\n" );
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 35/43 perf stat record: Synthesize event update events
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Synthesize other events stuff not carried within attr event - unit, scale, name.
--- tools/perf/builtin-stat.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
tools/perf/builtin-stat.c +59 -0
@@ -351,8 +351,19 @@ static void workload_exec_failed_signal(int signo __maybe_unused, siginfo_t *inf workload_exec_errno = info->si_value.sival_int; } +static bool has_unit (struct perf_evsel *counter) +{ +return counter->unit && *counter->unit; +} + +static bool has_scale (struct perf_evsel *counter) +{ +return counter->scale !=1 ; +} +static int perf_stat_synthesize_config (bool is_pipe) { +struct perf_evsel *counter;int err;if (is_pipe) {
@@ -364,6 +375,54 @@ static int perf_stat_synthesize_config(bool is_pipe) } } +/* +* Synthesize other events stuff not carried within +* attr event - unit, scale, name +*/ +evlist__for_each (evsel_list, counter) { +if (!counter->supported) +continue ; + +/* +* Synthesize unit and scale only if it's defined. +*/ +if (has_unit (counter)) { + err =perf_event__synthesize_event_update_unit (NULL , counter, process_synthesized_event); +if (err <0 ) { +pr_err ("Couldn't synthesize evsel unit.\n" ); +return err; + } + } + +if (has_scale (counter)) { + err =perf_event__synthesize_event_update_scale (NULL , counter, process_synthesized_event); +if (err <0 ) { +pr_err ("Couldn't synthesize evsel scale.\n" ); +return err; + } + } + +if (counter->own_cpus) { + err =perf_event__synthesize_event_update_cpus (NULL , counter, process_synthesized_event); +if (err <0 ) { +pr_err ("Couldn't synthesize evsel scale.\n" ); +return err; + } + } + +/* +* Name is needed only for pipe output, +* perf.data carries event names. +*/ +if (is_pipe) { + err =perf_event__synthesize_event_update_name (NULL , counter, process_synthesized_event); +if (err <0 ) { +pr_err ("Couldn't synthesize evsel name.\n" ); +return err; + } + } + } + err =perf_event__synthesize_thread_map2 (NULL , evsel_list->threads, process_synthesized_event,NULL );
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 36/43 perf stat report: Add report command
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding 'perf stat report' command support. ATM it only processes attr events and display nothing.
--- tools/perf/Documentation/perf-stat.txt | 12 +++++++ tools/perf/builtin-stat.c | 61 +++++++++++++++++++++++++++++++--- 2 files changed, 69 insertions(+), 4 deletions(-)
tools/perf/Documentation/perf-stat.txt +12 -0
@@ -11,6 +11,7 @@ SYNOPSIS 'perf stat' [-e <EVENT> | --event=EVENT] [-a] <command> 'perf stat' [-e <EVENT> | --event=EVENT] [-a] -- <command> [<options>] 'perf stat' [-e <EVENT> | --event=EVENT] [-a] record [-o file] -- <command> [<options>] +'perf stat' report [-i file] DESCRIPTION -----------
@@ -26,6 +27,9 @@ OPTIONS record:: See STAT RECORD. +report:: + See STAT REPORT. + -e:: --event=:: Select the PMU event. Selection can be:
@@ -170,6 +174,14 @@ Stores stat data into perf data file. --output file:: Output file name. +STAT REPORT +----------- +Reads and reports stat data from perf data file. + +-i file:: +--input file:: +Input file name. + EXAMPLES --------
tools/perf/builtin-stat.c +57 -4
97 lines not on this page · raw message
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 37/43 perf stat report: Process cpu/threads maps
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding processing of cpu/threads maps. Configuring session's evlist with these maps.
--- tools/perf/builtin-stat.c | 66 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-)
tools/perf/builtin-stat.c +64 -2
@@ -135,6 +135,9 @@ struct perf_stat {struct perf_session *session;u64 bytes_written;struct perf_tool tool; +bool maps_allocated; +struct cpu_map *cpus; +struct thread_map *threads; };static struct perf_stat perf_stat;
@@ -234,9 +237,9 @@ static int process_synthesized_event(struct perf_tool *tool __maybe_unused,return 0 ; } -static int write_stat_round_event (u64 time,u64 type) +static int write_stat_round_event (u64 tm,u64 type) { -return perf_event__synthesize_stat_round (NULL , time, type, +return perf_event__synthesize_stat_round (NULL , tm, type, process_synthesized_event,NULL ); }
@@ -1530,6 +1533,63 @@ static int __cmd_record(int argc, const char **argv)return argc; } +static int set_maps (struct perf_stat *st) +{ +if (!st->cpus || !st->threads) +return 0 ; + +if (WARN_ONCE (st->maps_allocated,"stats double allocation\n" )) +return -EINVAL ; + +perf_evlist__set_maps (evsel_list, st->cpus, st->threads); + +if (perf_evlist__alloc_stats (evsel_list, true)) +return -ENOMEM ; + + st->maps_allocated = true; +return 0 ; +} + +static +int process_thread_map_event (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_session *session__maybe_unused ) +{ + struct perf_stat *st = container_of(tool, struct perf_stat, tool); + +if (st->threads) { +pr_warning ("Extra thread map event, ignoring.\n" ); +return 0 ; + } + + st->threads =thread_map__new_event (&event->thread_map); +if (!st->threads) +return -ENOMEM ; + +return set_maps (st); +} + +static +int process_cpu_map_event (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_session *session__maybe_unused ) +{ + struct perf_stat *st = container_of(tool, struct perf_stat, tool); +struct cpu_map *cpus; + +if (st->cpus) { +pr_warning ("Extra cpu map event, ignoring.\n" ); +return 0 ; + } + + cpus =cpu_map__new_data (&event->cpu_map.data); +if (!cpus) +return -ENOMEM ; + + st->cpus = cpus; +return set_maps (st); +} +static const char *const report_usage[] = {"perf stat report [<options>]" ,NULL ,
@@ -1538,6 +1598,8 @@ static const char * const report_usage[] = {static struct perf_stat perf_stat = { .tool = { .attr = perf_event__process_attr, + .thread_map = process_thread_map_event, + .cpu_map = process_cpu_map_event, }, };
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 38/43 perf stat report: Process stat config event
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding processing of stat config event and initialize stat_config object.
--- tools/perf/builtin-stat.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
tools/perf/builtin-stat.c +10 -0
@@ -1533,6 +1533,15 @@ static int __cmd_record(int argc, const char **argv)return argc; } +static +int process_stat_config_event (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_session *session__maybe_unused ) +{ +perf_event__read_stat_config (&stat_config, &event->stat_config); +return 0 ; +} +static int set_maps (struct perf_stat *st) {if (!st->cpus || !st->threads)
@@ -1600,6 +1609,7 @@ static struct perf_stat perf_stat = { .attr = perf_event__process_attr, .thread_map = process_thread_map_event, .cpu_map = process_cpu_map_event, + .stat_config = process_stat_config_event, }, };
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 39/43 perf stat report: Add support to initialize aggr_map from file
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Using perf.data's perf_env data to initialize aggregate config.
--- tools/perf/builtin-stat.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+)
tools/perf/builtin-stat.c +103 -0
@@ -1326,6 +1326,101 @@ static void perf_stat__exit_aggr_mode(void) cpus_aggr_map =NULL ; } +static inline int perf_env__get_cpu (struct perf_env *env,struct cpu_map *map,int idx) +{ +int cpu; + +if (idx > map->nr) +return -1 ; + + cpu = map->map[idx]; + +if (cpu >= env->nr_cpus_online) +return -1 ; + +return cpu; +} + +static int perf_env__get_socket (struct cpu_map *map,int idx,void *data) +{ +struct perf_env *env = data; +int cpu =perf_env__get_cpu (env, map, idx); + +return cpu ==-1 ?-1 : env->cpu[cpu].socket_id; +} + +static int perf_env__get_core (struct cpu_map *map,int idx,void *data) +{ +struct perf_env *env = data; +int core =-1 , cpu =perf_env__get_cpu (env, map, idx); + +if (cpu !=-1 ) { +int socket_id = env->cpu[cpu].socket_id; + +/* +* Encode socket in upper 16 bits +* core_id is relative to socket, and +* we need a global id. So we combine +* socket + core id. +*/ + core = (socket_id <<16 ) | (env->cpu[cpu].core_id &0xffff ); + } + +return core; +} + +static int perf_env__build_socket_map (struct perf_env *env,struct cpu_map *cpus, +struct cpu_map **sockp) +{ +return cpu_map__build_map (cpus, sockp, perf_env__get_socket, env); +} + +static int perf_env__build_core_map (struct perf_env *env,struct cpu_map *cpus, +struct cpu_map **corep) +{ +return cpu_map__build_map (cpus, corep, perf_env__get_core, env); +} + +static int perf_stat__get_socket_file (struct cpu_map *map,int idx) +{ +return perf_env__get_socket (map, idx, &perf_stat.session->header.env); +} + +static int perf_stat__get_core_file (struct cpu_map *map,int idx) +{ +return perf_env__get_core (map, idx, &perf_stat.session->header.env); +} + +static int perf_stat_init_aggr_mode_file (struct perf_stat *st) +{ +struct perf_env *env = &st->session->header.env; + +switch (stat_config.aggr_mode) { +case AGGR_SOCKET : +if (perf_env__build_socket_map (env, evsel_list->cpus, &aggr_map)) { +perror ("cannot build socket map" ); +return -1 ; + } + aggr_get_id = perf_stat__get_socket_file; +break ; +case AGGR_CORE : +if (perf_env__build_core_map (env, evsel_list->cpus, &aggr_map)) { +perror ("cannot build core map" ); +return -1 ; + } + aggr_get_id = perf_stat__get_core_file; +break ; +case AGGR_NONE : +case AGGR_GLOBAL : +case AGGR_THREAD : +case AGGR_UNSET : +default : +break ; + } + +return 0 ; +} +/* * Add default attributes, if there were no attributes specified or * if -d/--detailed, -d -d or -d -d -d is used:
@@ -1538,7 +1633,15 @@ int process_stat_config_event(struct perf_tool *tool __maybe_unused,union perf_event *event, struct perf_session *session __maybe_unused) { + struct perf_stat *st = container_of(tool, struct perf_stat, tool); +perf_event__read_stat_config (&stat_config, &event->stat_config); + +if (perf_stat.file.is_pipe) +perf_stat_init_aggr_mode (); +else +perf_stat_init_aggr_mode_file (st); +return 0 ; }
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 40/43 perf stat report: Move csv_sep initialization before report command
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
So we have csv_sep properly initialized before report command leg.
--- tools/perf/builtin-stat.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
tools/perf/builtin-stat.c +7 -7
@@ -1776,6 +1776,13 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) (const char **) stat_usage, PARSE_OPT_STOP_AT_NON_OPTION); +if (csv_sep) { + csv_output = true; +if (!strcmp (csv_sep,"\\t" )) + csv_sep ="\t" ; + }else + csv_sep =DEFAULT_SEPARATOR ; +if (argc && !strncmp (argv[0 ],"rec" ,3 )) { argc =__cmd_record (argc, argv);if (argc <0 )
@@ -1826,13 +1833,6 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) stat_config.output = output; -if (csv_sep) { - csv_output = true; -if (!strcmp (csv_sep,"\\t" )) - csv_sep ="\t" ; - }else - csv_sep =DEFAULT_SEPARATOR ; -/* * let the spreadsheet do the pretty-printing */
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 41/43 perf stat report: Process stat and stat round events
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding processing of stat and stat round events.
The stat data com in stat events, using generic function process_stat_round_event to store data under perf_evsel object.
The stat-round events comes each interval or as last event in non interval mode. The function process_stat_round_event process stored data for each perf_evsel object and print it out.
Committer note:
After this patch:
$ perf stat record usleep 1
Performance counter stats for 'usleep 1':
0.498381 task-clock (msec) # 0.571 CPUs utilized
2 context-switches # 0.004 M/sec
0 cpu-migrations # 0.000 K/sec
149 page-faults # 0.299 M/sec
1,271,635 cycles # 2.552 GHz
928,712 stalled-cycles-frontend # 73.03% frontend cycles idle
663,286 stalled-cycles-backend # 52.16% backend cycles idle
792,614 instructions # 0.62 insns per cycle # 1.17 stalled cycles per insn
136,850 branches # 274.589 M/sec
<not counted> branch-misses (0.00%)
0.000873419 seconds time elapsed
$
$ perf stat report
Performance counter stats for '/home/acme/bin/perf stat record usleep 1':
0.498381 task-clock (msec) # 0.571 CPUs utilized
2 context-switches # 0.004 M/sec
0 cpu-migrations # 0.000 K/sec
149 page-faults # 0.299 M/sec
1,271,635 cycles # 2.552 GHz
928,712 stalled-cycles-frontend # 73.03% frontend cycles idle
663,286 stalled-cycles-backend # 52.16% backend cycles idle
792,614 instructions # 0.62 insns per cycle # 1.17 stalled cycles per insn
136,850 branches # 274.589 M/sec
<not counted> branch-misses (0.00%)
0.000873419 seconds time elapsed
$
--- tools/perf/builtin-stat.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
tools/perf/builtin-stat.c +28 -0
@@ -1628,6 +1628,32 @@ static int __cmd_record(int argc, const char **argv)return argc; } +static int process_stat_round_event (struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_session *session) +{ +struct stat_round_event *round = &event->stat_round; +struct perf_evsel *counter; +struct timespec tsh, *ts =NULL ; +const char **argv = session->header.env.cmdline_argv; +int argc = session->header.env.nr_cmdline; + +evlist__for_each (evsel_list, counter) +perf_stat_process_counter (&stat_config, counter); + +if (round->type ==PERF_STAT_ROUND_TYPE__FINAL ) +update_stats (&walltime_nsecs_stats, round->time); + +if (stat_config.interval && round->time) { + tsh.tv_sec = round->time /NSECS_PER_SEC ; + tsh.tv_nsec = round->time %NSECS_PER_SEC ; + ts = &tsh; + } + +print_counters (ts, argc, argv); +return 0 ; +} + static int process_stat_config_event(struct perf_tool *tool __maybe_unused, union perf_event *event,
@@ -1713,6 +1739,8 @@ static struct perf_stat perf_stat = { .thread_map = process_thread_map_event, .cpu_map = process_cpu_map_event, .stat_config = process_stat_config_event, + .stat = perf_event__process_stat_event, + .stat_round = process_stat_round_event, }, };
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 42/43 perf stat report: Process event update events
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding processing of event update events, so perf stat report can store additional info for events - unit,scale,name.
Committer note:
Before:
# perf stat record -e power/energy-cores/ -a ^C Performance counter stats for 'system wide':
77.41 Joules power/energy-cores/
1.597176695 seconds time elapsed
# perf stat report
Performance counter stats for '/home/acme/bin/perf stat record -e power/energy-cores/ -a':
332,488,114,176 power/energy-cores/
1.597176695 seconds time elapsed
#
After, using the same perf.data file generated in the "Before" case above:
# perf stat report
Performance counter stats for '/home/acme/bin/perf stat record -e power/energy-cores/ -a':
77.41 Joules power/energy-cores/
1.597176695 seconds time elapsed
#
--- tools/perf/builtin-stat.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/builtin-stat.c +1 -0
@@ -1736,6 +1736,7 @@ static const char * const report_usage[] = {static struct perf_stat perf_stat = { .tool = { .attr = perf_event__process_attr, + .event_update = perf_event__process_event_update, .thread_map = process_thread_map_event, .cpu_map = process_cpu_map_event, .stat_config = process_stat_config_event,
Signature · 1 line
2.1.0
Arnaldo Carvalho de Melo
maintainerPATCH 43/43 perf stat report: Allow to override aggr_mode
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Allowing to override record aggr_mode. It's possible to use perf stat like:
$ perf stat report -A $ perf stat report --per-core $ perf stat report --per-socket
To customize the recorded aggregate mode regardless what was used during the stat record command.
--- tools/perf/Documentation/perf-stat.txt | 10 ++++++++++ tools/perf/builtin-stat.c | 17 +++++++++++++++++ 2 files changed, 27 insertions(+)
tools/perf/Documentation/perf-stat.txt +10 -0
@@ -182,6 +182,16 @@ Reads and reports stat data from perf data file. --input file:: Input file name. +--per-socket:: +Aggregate counts per processor socket for system-wide mode measurements. + +--per-core:: +Aggregate counts per physical processor for system-wide mode measurements. + +-A:: +--no-aggr:: +Do not aggregate counts across all monitored CPUs. + EXAMPLES --------
tools/perf/builtin-stat.c +17 -0
@@ -138,6 +138,7 @@ struct perf_stat {bool maps_allocated;struct cpu_map *cpus;struct thread_map *threads; +enum aggr_mode aggr_mode; };static struct perf_stat perf_stat;
@@ -1663,6 +1664,15 @@ int process_stat_config_event(struct perf_tool *tool __maybe_unused,perf_event__read_stat_config (&stat_config, &event->stat_config); +if (cpu_map__empty (st->cpus)) { +if (st->aggr_mode !=AGGR_UNSET ) +pr_warning ("warning: processing task data, aggregation mode not set\n" ); +return 0 ; + } + +if (st->aggr_mode !=AGGR_UNSET ) + stat_config.aggr_mode = st->aggr_mode; +if (perf_stat.file.is_pipe)perf_stat_init_aggr_mode ();else
@@ -1743,6 +1753,7 @@ static struct perf_stat perf_stat = { .stat = perf_event__process_stat_event, .stat_round = process_stat_round_event, }, + .aggr_mode = AGGR_UNSET, };static int __cmd_report (int argc,const char **argv)
@@ -1750,6 +1761,12 @@ static int __cmd_report(int argc, const char **argv)struct perf_session *session;const struct option options[] = {OPT_STRING ('i' ,"input" , &input_name,"file" ,"input file name" ), +OPT_SET_UINT (0 ,"per-socket" , &perf_stat.aggr_mode, +"aggregate counts per processor socket" ,AGGR_SOCKET ), +OPT_SET_UINT (0 ,"per-core" , &perf_stat.aggr_mode, +"aggregate counts per physical processor core" ,AGGR_CORE ), +OPT_SET_UINT ('A' ,"no-aggr" , &perf_stat.aggr_mode, +"disable CPU count aggregation" ,AGGR_NONE ),OPT_END () };struct stat st;
Signature · 1 line
2.1.0
Quoted 60 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
Hi Ingo,
Please consider pulling, cool new feature! This is on top of the
perf-core-for-mingo-2.1 tag, with that RHEL6.7 bugfix, I had also to go over this one fixing stuff in many spots :-\- Arnaldo
The following changes since commit
1843b4e057b7717db21a3ad96fa16d6b4ee8f6c4:tools subcmd: Rename subcmd header include guards (2015-12-17 14:27:14 -0300)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingo-3for you to fetch changes up to
89af4e05c21d68f22e07fe66940ea675615a49ed:perf stat report: Allow to override
aggr_mode(2015-12-17 16:30:30 -0300)----------------------------------------------------------------
perf/core improvement.User visible:
- Generate perf.data files from 'perf stat', to tap into the scripting capabilities perf has instead of defining a 'perf stat' specific scripting support to calculate event ratios, etc. Simple example:
$ perf stat record -e cycles usleep 1Performance counter stats for 'usleep 1': 1,134,996 cycles 0.000670644 seconds time elapsed$ perf stat reportPerformance counter stats for '/home/acme/bin/perf stat record -e cycles usleep 1': 1,134,996 cycles 0.000670644 seconds time elapsed$
It generates
PERF_RECORD_userspace records to store the details:$ perf report -D | grep PERF_RECORD 0xf0 [0x28]: PERF_RECORD_THREAD_MAP nr: 1 thread: 27637 0x118 [0x12]: PERF_RECORD_CPU_MAP nr: 1 cpu: 65535 0x12a [0x40]: PERF_RECORD_STAT_CONFIG 0x16a [0x30]: PERF_RECORD_STAT -1 -1 0x19a [0x40]: PERF_RECORD_MMAP -1/0: [0xffffffff81000000(0x1f000000) @ 0xffffffff81000000]: x [kernel.kallsyms]_text 0x1da [0x18]: PERF_RECORD_STAT_ROUND [acme@ssdandy linux]$
Quoted 4 lines
An effort was made to make perf.data files generated like this to not generate cryptic messages when processed by older tools.
The 'perf script' bits need rebasing, will go up later.
Nice feature!
Quoted 96 lines
Jiri's cover letter for this series:
The initial attempt defined its own formula lang and allowed triggering user's script on the end of the stat command:
http://marc.info/?l=linux-kernel&m=136742146322273&w=2
This patchset abandons the idea of new formula language and rather adds support to:
- store stat data into perf.data file
- add python support to process stat eventsBasically it allows to store stat data into perf.data and post process it with python scripts in a similar way we do for sampling data.
The stat data are stored in new stat, stat-round, stat-config user events.
stat - stored for each read syscall of the counter
stat round - stored for each interval or end of the command invocation stat config - stores all the config information needed to process data
so report tool could restore the same output as recordThe python script can now define 'stat__<eventname>_<modifier>' functions to get stat events data and '
stat__interval' to get stat-round data.See CPI script example in
scripts/python/stat-cpi.py.Signed-off-by Arnaldo Carvalho de Melo <[email protected]>----------------------------------------------------------------
Jiri Olsa (43):
perfthread_map: Addthread_mapuser level event
perfthread_map: Addthread_mapevent sythesize function perfthread_map: Addthread_map__new_eventfunction perfthread_map: Addperf_event__fprintf_thread_mapfunction perfcpu_map: Addcpu_mapuser level event
perfcpu_map: Addcpu_mapevent synthesize function perfcpu_map: Addcpu_map__new_eventfunction
perfcpu_map: Addperf_event__fprintf_cpu_mapfunction perf tools: Add stat config user level event
perf tools: Add stat config event synthesize function perf tools: Add stat config event read function
perf tools: Add stat user level event
perf tools: Add stat event synthesize function
perf tools: Add stat event read function
perf tools: Add stat round user level event
perf tools: Add stat round event synthesize function perf tools: Add stat events fprintf functions
perf tools: Addevent_updateuser level event
perf tools: Addevent_updateevent unit type
perf tools: Addevent_updateevent scale type
perf tools: Addevent_updateevent name type
perf tools: Addevent_updateevent cpus type
perf tools: Addperf_event__fprintf_event_updatefunction perf report: Display newly added events in raw dump perf tools: Introduce stat perf.data header feature perf stat record: Add record command
perf stat record: Initialize record features
perf stat record: Synthesize stat record data
perf evlist: Exportid_add_fd()
perf stat record: Store events IDs in perf data file perf stat record: Add pipe support for record command perf stat record: Write stat events on record
perf stat record: Write stat round events on record perf stat record: Do not allow record with multiple runs mode perf stat record: Synthesize event update events
perf stat report: Add report command
perf stat report: Process cpu/threads maps
perf stat report: Process stat config event
perf stat report: Add support to initializeaggr_mapfrom file perf stat report: Movecsv_sepinitialization before report command perf stat report: Process stat and stat round events perf stat report: Process event update events
perf stat report: Allow to overrideaggr_modetools/perf/Documentation/perf-stat.txt | 34 ++ tools/perf/builtin-record.c | 2 + tools/perf/builtin-stat.c | 614 ++++++++++++++++++++++++++++++++- tools/perf/tests/Build | 3 + tools/perf/tests/builtin-test.c | 24 ++ tools/perf/tests/cpumap.c | 88 +++++ tools/perf/tests/event_update.c | 117 +++++++ tools/perf/tests/stat.c | 111 ++++++ tools/perf/tests/tests.h | 6 + tools/perf/tests/thread-map.c | 43 +++ tools/perf/util/cpumap.c | 42 +++ tools/perf/util/cpumap.h | 1 + tools/perf/util/event.c | 308 +++++++++++++++++ tools/perf/util/event.h | 150 +++++++- tools/perf/util/evlist.c | 6 +- tools/perf/util/evlist.h | 3 + tools/perf/util/header.c | 205 +++++++++++ tools/perf/util/header.h | 17 + tools/perf/util/session.c | 189 ++++++++++ tools/perf/util/stat.c | 62 ++++
Quoted 8 lines
tools/perf/util/stat.h | 10 + tools/perf/util/thread_map.c | 27 ++ tools/perf/util/thread_map.h | 3 + tools/perf/util/tool.h | 8 +- 24 files changed, 2054 insertions(+), 19 deletions(-) create mode 100644 tools/perf/tests/cpumap.c create mode 100644 tools/perf/tests/event_update.c create mode 100644 tools/perf/tests/stat.c
Pulled, thanks a lot Arnaldo!
Ingo
Quoted 63 lines · Ingo Molnar
Quoted 60 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
Hi Ingo,
Please consider pulling, cool new feature! This is on top of the
perf-core-for-mingo-2.1 tag, with that RHEL6.7 bugfix, I had also to go over this one fixing stuff in many spots :-\- Arnaldo
The following changes since commit
1843b4e057b7717db21a3ad96fa16d6b4ee8f6c4:tools subcmd: Rename subcmd header include guards (2015-12-17 14:27:14 -0300)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingo-3for you to fetch changes up to
89af4e05c21d68f22e07fe66940ea675615a49ed:perf stat report: Allow to override
aggr_mode(2015-12-17 16:30:30 -0300)----------------------------------------------------------------
perf/core improvement.User visible:
- Generate perf.data files from 'perf stat', to tap into the scripting capabilities perf has instead of defining a 'perf stat' specific scripting support to calculate event ratios, etc. Simple example:
$ perf stat record -e cycles usleep 1Performance counter stats for 'usleep 1': 1,134,996 cycles 0.000670644 seconds time elapsed$ perf stat reportPerformance counter stats for '/home/acme/bin/perf stat record -e cycles usleep 1': 1,134,996 cycles 0.000670644 seconds time elapsed$
It generates
PERF_RECORD_userspace records to store the details:$ perf report -D | grep PERF_RECORD 0xf0 [0x28]: PERF_RECORD_THREAD_MAP nr: 1 thread: 27637 0x118 [0x12]: PERF_RECORD_CPU_MAP nr: 1 cpu: 65535 0x12a [0x40]: PERF_RECORD_STAT_CONFIG 0x16a [0x30]: PERF_RECORD_STAT -1 -1 0x19a [0x40]: PERF_RECORD_MMAP -1/0: [0xffffffff81000000(0x1f000000) @ 0xffffffff81000000]: x [kernel.kallsyms]_text 0x1da [0x18]: PERF_RECORD_STAT_ROUND [acme@ssdandy linux]$
Quoted 6 lines
Quoted 4 lines
An effort was made to make perf.data files generated like this to not generate cryptic messages when processed by older tools.
The 'perf script' bits need rebasing, will go up later.
Nice feature!
I tried it out, and it works as expected, cool stuff!
Btw., a very small usability observation: maybe 'perf report' should be enhanced to recognize 'stat record' generated perf.data files, and display a matching message?
Right now if I do 'perf report' on such a perf.data then I'll get a "no samples" TUI message, which is technically correct but somewhat misleading.
It's no big deal - and maybe you guys can think of a better solution than displaying an error message: maybe 'perf report' should automatically switch to 'perf stat report'?
It would be a bit shorter to type as well and would continue to strengthen the very nice level of integration that the various subcommands already have today.
But maybe it would be confusing - don't know.
Thanks,
Ingo
On Fri, Dec 18, 2015 at 09:55:38AM +0100, Ingo Molnar wrote:
SNIP
Quoted 4 lines
Right now if I do 'perf report' on such a perf.data then I'll get a "no samples" TUI message, which is technically correct but somewhat misleading.
Quoted 8 lines
It's no big deal - and maybe you guys can think of a better solution than displaying an error message: maybe 'perf report' should automatically switch to 'perf stat report'?
It would be a bit shorter to type as well and would continue to strengthen the very nice level of integration that the various subcommands already have today.
But maybe it would be confusing - don't know.
let's see ;-) I'll try to send out rfc soon
thanks,
jirka