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

Commit 896cbb56 authored by David Ahern's avatar David Ahern Committed by Arnaldo Carvalho de Melo
Browse files

perf trace: Use new machine method to loop over threads



Use the new machine method that loops over threads to dump summary data.

Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1380395584-9025-3-git-send-email-dsahern@gmail.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 35feee19
Loading
Loading
Loading
Loading
+48 −28
Original line number Diff line number Diff line
@@ -1751,19 +1751,25 @@ static size_t trace__fprintf_threads_header(FILE *fp)
	return printed;
}

static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp)
{
	size_t printed = trace__fprintf_threads_header(fp);
	struct rb_node *nd;
/* struct used to pass data to per-thread function */
struct summary_data {
	FILE *fp;
	struct trace *trace;
	size_t printed;
};

	for (nd = rb_first(&trace->host->threads); nd; nd = rb_next(nd)) {
		struct thread *thread = rb_entry(nd, struct thread, rb_node);
static int trace__fprintf_one_thread(struct thread *thread, void *priv)
{
	struct summary_data *data = priv;
	FILE *fp = data->fp;
	size_t printed = data->printed;
	struct trace *trace = data->trace;
	struct thread_trace *ttrace = thread->priv;
	const char *color;
	double ratio;

	if (ttrace == NULL)
			continue;
		return 0;

	ratio = (double)ttrace->nr_events / trace->nr_events * 100.0;

@@ -1779,9 +1785,23 @@ static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp)
	printed += fprintf(fp, " - %-5d :%11lu   [", thread->tid, ttrace->nr_events);
	printed += color_fprintf(fp, color, "%5.1f%%", ratio);
	printed += fprintf(fp, " ] %10.3f ms\n", ttrace->runtime_ms);

	data->printed += printed;

	return 0;
}

	return printed;
static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp)
{
	struct summary_data data = {
		.fp = fp,
		.trace = trace
	};
	data.printed = trace__fprintf_threads_header(fp);

	machine__for_each_thread(trace->host, trace__fprintf_one_thread, &data);

	return data.printed;
}

static int trace__set_duration(const struct option *opt, const char *str,