[PATCH 20/21] perf report: Add user data processing stats

Jiri Olsa
2018-01-24T11:52:36Z

Adding user data processing stats for to review the
processing. Adding following per-thread counters:

user_data_sample - nb of samples with with
PERF_RECORD_MISC_USER_DATA set
user_data_event - nb of user data events
user_data_match - nb of samples that matched user
data event
user_data_drop - nb of samples that did not match
any user data event and were drop

Link: http://lkml.kernel.org/n/tip-j4zh9fpntjbtjo993cjdn92b@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-report.c | 6 ++++++
tools/perf/util/thread.h | 8 ++++++++
2 files changed, 14 insertions(+)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index a1cd5fd793fc..82b2368d208a 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -314,6 +314,7 @@ perf_thread__add_user_data(struct thread *thread,
return -ENOMEM;
}

+ thread->stats.user_data_sample++;
list_add_tail(&entry->list, &thread->user_data_list);
return 0;
}
@@ -425,6 +426,8 @@ thread__flush_user_data(struct thread *thread,
struct user_data *entry, *p;
int ret = 0;

+ thread->stats.user_data_event++;
+
list_for_each_entry_safe(entry, p, &thread->user_data_list, list) {
/* different event, skip it */
if (entry->sample.id != sample->id)
@@ -439,6 +442,9 @@ thread__flush_user_data(struct thread *thread,
ret = user_data__process(entry, sample, event, rep);
if (ret)
pr_debug("problem adding hist entry, skipping event\n");
+ thread->stats.user_data_match++;
+ } else {
+ thread->stats.user_data_drop++;
}

list_del(&entry->list);
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index e78b295bbcdb..742bbf8cb285 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -22,6 +22,13 @@ struct user_data {
struct perf_evsel *evsel;
};

+struct thread_stats {
+ u64 user_data_sample;
+ u64 user_data_event;
+ u64 user_data_match;
+ u64 user_data_drop;
+};
+
struct thread {
union {
struct rb_node rb_node;
@@ -51,6 +58,7 @@ struct thread {
void *addr_space;
struct unwind_libunwind_ops *unwind_libunwind_ops;
#endif
+ struct thread_stats stats;
};

struct machine;
--
2.13.6