Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8446b9b authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf hist: Make event__totals per hists



This is one more thing that started global but are more useful per hist
or per session.

Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 5d2be7cb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -365,7 +365,7 @@ static int __cmd_annotate(void)
		goto out_delete;

	if (dump_trace) {
		event__print_totals();
		perf_session__fprintf_nr_events(session, stdout);
		goto out_delete;
	}

+7 −1
Original line number Diff line number Diff line
@@ -139,6 +139,12 @@ static int add_event_total(struct perf_session *session,
		return -ENOMEM;

	hists->stats.total += data->period;
	/*
	 * FIXME: add_event_total should be moved from here to
	 * perf_session__process_event so that the proper hist is passed to
	 * the event_op methods.
	 */
	hists__inc_nr_events(hists, PERF_RECORD_SAMPLE);
	session->hists.stats.total += data->period;
	return 0;
}
@@ -293,7 +299,7 @@ static int __cmd_report(void)
		goto out_delete;

	if (dump_trace) {
		event__print_totals();
		perf_session__fprintf_nr_events(session, stdout);
		goto out_delete;
	}

+17 −0
Original line number Diff line number Diff line
@@ -7,6 +7,23 @@
#include "strlist.h"
#include "thread.h"

const char *event__name[] = {
	[0]			 = "TOTAL",
	[PERF_RECORD_MMAP]	 = "MMAP",
	[PERF_RECORD_LOST]	 = "LOST",
	[PERF_RECORD_COMM]	 = "COMM",
	[PERF_RECORD_EXIT]	 = "EXIT",
	[PERF_RECORD_THROTTLE]	 = "THROTTLE",
	[PERF_RECORD_UNTHROTTLE] = "UNTHROTTLE",
	[PERF_RECORD_FORK]	 = "FORK",
	[PERF_RECORD_READ]	 = "READ",
	[PERF_RECORD_SAMPLE]	 = "SAMPLE",
	[PERF_RECORD_HEADER_ATTR]	 = "ATTR",
	[PERF_RECORD_HEADER_EVENT_TYPE]	 = "EVENT_TYPE",
	[PERF_RECORD_HEADER_TRACING_DATA]	 = "TRACING_DATA",
	[PERF_RECORD_HEADER_BUILD_ID]	 = "BUILD_ID",
};

static pid_t event__synthesize_comm(pid_t pid, int full,
				    event__handler_t process,
				    struct perf_session *session)
+2 −0
Original line number Diff line number Diff line
@@ -160,4 +160,6 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session,
			     struct addr_location *al, symbol_filter_t filter);
int event__parse_sample(event_t *event, u64 type, struct sample_data *data);

extern const char *event__name[];

#endif /* __PERF_RECORD_H */
+21 −0
Original line number Diff line number Diff line
@@ -1028,3 +1028,24 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head)
	pclose(file);
	return 0;
}

void hists__inc_nr_events(struct hists *self, u32 type)
{
	++self->hists.stats.nr_events[0];
	++self->hists.stats.nr_events[type];
}

size_t hists__fprintf_nr_events(struct hists *self, FILE *fp)
{
	int i;
	size_t ret = 0;

	for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) {
		if (!event__name[i])
			continue;
		ret += fprintf(fp, "%10s events: %10d\n",
			       event__name[i], self->stats.nr_events[i]);
	}

	return ret;
}
Loading