mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Stephane Eranian <eranian@google.com>,
	Jiri Olsa <jolsa@redhat.com>, Ulrich Drepper <drepper@gmail.com>,
	Andi Kleen <andi@firstfloor.org>
Subject: [PATCH 02/12] perf hist: Convert to struct he_stat
Date: Tue, 24 Jul 2012 18:01:23 +0900	[thread overview]
Message-ID: <1343120493-23059-3-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1343120493-23059-1-git-send-email-namhyung@kernel.org>

As we have struct he_stat, convert hist_entry's fields to he_stat.
It'll make it easy to deal with group stats.

This is a mechinical change and should not have any functional changes.

Cc: Stephane Eranian <eranian@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/browsers/hists.c |    8 ++++----
 tools/perf/ui/gtk/browser.c    |    2 +-
 tools/perf/ui/hist.c           |   30 +++++++++++++--------------
 tools/perf/util/hist.c         |   44 ++++++++++++++++++++++------------------
 tools/perf/util/sort.h         |    7 +------
 5 files changed, 45 insertions(+), 46 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index c261804f467c..69584d79097e 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -557,7 +557,7 @@ static int hist_browser__show_callchain(struct hist_browser *browser,
 static int hist_browser__hpp_color_ ## _name(struct hist_print_context *ctx,	\
 					     struct hist_entry *he)		\
 {										\
-	double percent = 100.0 * he->_field / ctx->total_period;		\
+	double percent = 100.0 * he->stat._field / ctx->total_period;		\
 	*(double *)ctx->ptr = percent;						\
 	return scnprintf(ctx->s, ctx->size, "%5.2f%%", percent);		\
 }
@@ -976,7 +976,7 @@ static int hist_browser__fprintf_entry(struct hist_browser *browser,
 		folded_sign = hist_entry__folded(he);
 
 	hist_entry__sort_snprintf(he, s, sizeof(s), browser->hists);
-	percent = (he->period * 100.0) / browser->hists->stats.total_period;
+	percent = (he->stat.period * 100.0) / browser->hists->stats.total_period;
 
 	if (symbol_conf.use_callchain)
 		printed += fprintf(fp, "%c ", folded_sign);
@@ -984,10 +984,10 @@ static int hist_browser__fprintf_entry(struct hist_browser *browser,
 	printed += fprintf(fp, " %5.2f%%", percent);
 
 	if (symbol_conf.show_nr_samples)
-		printed += fprintf(fp, " %11u", he->nr_events);
+		printed += fprintf(fp, " %11u", he->stat.nr_events);
 
 	if (symbol_conf.show_total_period)
-		printed += fprintf(fp, " %12" PRIu64, he->period);
+		printed += fprintf(fp, " %12" PRIu64, he->stat.period);
 
 	printed += fprintf(fp, "%s\n", rtrim(s));
 
diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c
index 1e06d6a0ba34..91e11f7bffbf 100644
--- a/tools/perf/ui/gtk/browser.c
+++ b/tools/perf/ui/gtk/browser.c
@@ -48,7 +48,7 @@ static const char *perf_gtk__get_percent_color(double percent)
 static int perf_gtk__hpp_color_ ## _name(struct hist_print_context *ctx,	\
 					 struct hist_entry *he)			\
 {										\
-	double percent = 100.0 * he->_field / ctx->total_period;		\
+	double percent = 100.0 * he->stat._field / ctx->total_period;		\
 	const char *markup;							\
 	int ret = 0;								\
 										\
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 7e3a5d67764a..8092a621bbec 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -21,14 +21,14 @@ static int hpp_width_overhead(struct hist_print_context *ctx __used)
 static int hpp_color_overhead(struct hist_print_context *ctx,
 			      struct hist_entry *he)
 {
-	double percent = 100.0 * he->period / ctx->total_period;
+	double percent = 100.0 * he->stat.period / ctx->total_period;
 	return percent_color_snprintf(ctx->s, ctx->size, "  %5.2f%%", percent);
 }
 
 static int hpp_entry_overhead(struct hist_print_context *ctx,
 			      struct hist_entry *he)
 {
-	double percent = 100.0 * he->period / ctx->total_period;
+	double percent = 100.0 * he->stat.period / ctx->total_period;
 	return scnprintf(ctx->s, ctx->size, "  %5.2f%%", percent);
 }
 
@@ -45,14 +45,14 @@ static int hpp_width_overhead_sys(struct hist_print_context *ctx __used)
 static int hpp_color_overhead_sys(struct hist_print_context *ctx,
 				  struct hist_entry *he)
 {
-	double percent = 100.0 * he->period_sys / ctx->total_period;
+	double percent = 100.0 * he->stat.period_sys / ctx->total_period;
 	return percent_color_snprintf(ctx->s, ctx->size, "%5.2f%%", percent);
 }
 
 static int hpp_entry_overhead_sys(struct hist_print_context *ctx,
 				  struct hist_entry *he)
 {
-	double percent = 100.0 * he->period_sys / ctx->total_period;
+	double percent = 100.0 * he->stat.period_sys / ctx->total_period;
 	return scnprintf(ctx->s, ctx->size, "%5.2f%%", percent);
 }
 
@@ -69,14 +69,14 @@ static int hpp_width_overhead_us(struct hist_print_context *ctx __used)
 static int hpp_color_overhead_us(struct hist_print_context *ctx,
 				 struct hist_entry *he)
 {
-	double percent = 100.0 * he->period_us / ctx->total_period;
+	double percent = 100.0 * he->stat.period_us / ctx->total_period;
 	return percent_color_snprintf(ctx->s, ctx->size, "%5.2f%%", percent);
 }
 
 static int hpp_entry_overhead_us(struct hist_print_context *ctx,
 				 struct hist_entry *he)
 {
-	double percent = 100.0 * he->period_us / ctx->total_period;
+	double percent = 100.0 * he->stat.period_us / ctx->total_period;
 	return scnprintf(ctx->s, ctx->size, "%5.2f%%", percent);
 }
 
@@ -93,14 +93,14 @@ static int hpp_width_overhead_guest_sys(struct hist_print_context *ctx __used)
 static int hpp_color_overhead_guest_sys(struct hist_print_context *ctx,
 					struct hist_entry *he)
 {
-	double percent = 100.0 * he->period_guest_sys / ctx->total_period;
+	double percent = 100.0 * he->stat.period_guest_sys / ctx->total_period;
 	return percent_color_snprintf(ctx->s, ctx->size, "  %5.2f%% ", percent);
 }
 
 static int hpp_entry_overhead_guest_sys(struct hist_print_context *ctx,
 					struct hist_entry *he)
 {
-	double percent = 100.0 * he->period_guest_sys / ctx->total_period;
+	double percent = 100.0 * he->stat.period_guest_sys / ctx->total_period;
 	return scnprintf(ctx->s, ctx->size, "  %5.2f%% ", percent);
 }
 
@@ -117,14 +117,14 @@ static int hpp_width_overhead_guest_us(struct hist_print_context *ctx __used)
 static int hpp_color_overhead_guest_us(struct hist_print_context *ctx,
 				       struct hist_entry *he)
 {
-	double percent = 100.0 * he->period_guest_us / ctx->total_period;
+	double percent = 100.0 * he->stat.period_guest_us / ctx->total_period;
 	return percent_color_snprintf(ctx->s, ctx->size, "  %5.2f%% ", percent);
 }
 
 static int hpp_entry_overhead_guest_us(struct hist_print_context *ctx,
 				       struct hist_entry *he)
 {
-	double percent = 100.0 * he->period_guest_us / ctx->total_period;
+	double percent = 100.0 * he->stat.period_guest_us / ctx->total_period;
 	return scnprintf(ctx->s, ctx->size, "  %5.2f%% ", percent);
 }
 
@@ -141,7 +141,7 @@ static int hpp_width_samples(struct hist_print_context *ctx __used)
 static int hpp_entry_samples(struct hist_print_context *ctx,
 			     struct hist_entry *he)
 {
-	return scnprintf(ctx->s, ctx->size, "%11" PRIu64, he->nr_events);
+	return scnprintf(ctx->s, ctx->size, "%11" PRIu64, he->stat.nr_events);
 }
 
 static int hpp_header_period(struct hist_print_context *ctx)
@@ -157,7 +157,7 @@ static int hpp_width_period(struct hist_print_context *ctx __used)
 static int hpp_entry_period(struct hist_print_context *ctx,
 			    struct hist_entry *he)
 {
-	return scnprintf(ctx->s, ctx->size, "%12" PRIu64, he->period);
+	return scnprintf(ctx->s, ctx->size, "%12" PRIu64, he->stat.period);
 }
 
 static int hpp_header_delta(struct hist_print_context *ctx)
@@ -180,11 +180,11 @@ static int hpp_entry_delta(struct hist_print_context *ctx,
 
 	old_total = pair_hists->stats.total_period;
 	if (old_total > 0)
-		old_percent = 100.0 * he->pair->period / old_total;
+		old_percent = 100.0 * he->pair->stat.period / old_total;
 
 	new_total = ctx->total_period;
 	if (new_total > 0)
-		new_percent = 100.0 * he->period / new_total;
+		new_percent = 100.0 * he->stat.period / new_total;
 
 	diff = new_percent - old_percent;
 	if (fabs(diff) < 0.01)
@@ -535,7 +535,7 @@ static size_t callchain__fprintf(struct hist_entry *he,
 {
 	switch (callchain_param.mode) {
 	case CHAIN_GRAPH_REL:
-		return callchain__fprintf_graph(fp, &he->sorted_chain, he->period,
+		return callchain__fprintf_graph(fp, &he->sorted_chain, he->stat.period,
 						left_margin);
 		break;
 	case CHAIN_GRAPH_ABS:
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 84b577560d5e..d2a76d379f87 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -135,16 +135,16 @@ static void hist_entry__add_cpumode_period(struct hist_entry *he,
 {
 	switch (cpumode) {
 	case PERF_RECORD_MISC_KERNEL:
-		he->period_sys += period;
+		he->stat.period_sys += period;
 		break;
 	case PERF_RECORD_MISC_USER:
-		he->period_us += period;
+		he->stat.period_us += period;
 		break;
 	case PERF_RECORD_MISC_GUEST_KERNEL:
-		he->period_guest_sys += period;
+		he->stat.period_guest_sys += period;
 		break;
 	case PERF_RECORD_MISC_GUEST_USER:
-		he->period_guest_us += period;
+		he->stat.period_guest_us += period;
 		break;
 	default:
 		break;
@@ -153,13 +153,13 @@ static void hist_entry__add_cpumode_period(struct hist_entry *he,
 
 static void hist_entry__decay(struct hist_entry *he)
 {
-	he->period = (he->period * 7) / 8;
-	he->nr_events = (he->nr_events * 7) / 8;
+	he->stat.period = (he->stat.period * 7) / 8;
+	he->stat.nr_events = (he->stat.nr_events * 7) / 8;
 }
 
 static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
 {
-	u64 prev_period = he->period;
+	u64 prev_period = he->stat.period;
 
 	if (prev_period == 0)
 		return true;
@@ -167,9 +167,9 @@ static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
 	hist_entry__decay(he);
 
 	if (!he->filtered)
-		hists->stats.total_period -= prev_period - he->period;
+		hists->stats.total_period -= prev_period - he->stat.period;
 
-	return he->period == 0;
+	return he->stat.period == 0;
 }
 
 static void __hists__decay_entries(struct hists *hists, bool zap_user,
@@ -223,7 +223,7 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template)
 
 	if (he != NULL) {
 		*he = *template;
-		he->nr_events = 1;
+		he->stat.nr_events = 1;
 		if (he->ms.map)
 			he->ms.map->referenced = true;
 		if (symbol_conf.use_callchain)
@@ -238,7 +238,7 @@ static void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h)
 	if (!h->filtered) {
 		hists__calc_col_len(hists, h);
 		++hists->nr_entries;
-		hists->stats.total_period += h->period;
+		hists->stats.total_period += h->stat.period;
 	}
 }
 
@@ -270,8 +270,8 @@ static struct hist_entry *add_hist_entry(struct hists *hists,
 		cmp = hist_entry__cmp(entry, he);
 
 		if (!cmp) {
-			he->period += period;
-			++he->nr_events;
+			he->stat.period += period;
+			++he->stat.nr_events;
 
 			/* If the map of an existing hist_entry has
 			 * become out-of-date due to an exec() or
@@ -321,7 +321,9 @@ struct hist_entry *__hists__add_branch_entry(struct hists *self,
 		.cpu	= al->cpu,
 		.ip	= bi->to.addr,
 		.level	= al->level,
-		.period	= period,
+		.stat = {
+			.period	= period,
+		},
 		.parent = sym_parent,
 		.filtered = symbol__parent_filter(sym_parent),
 		.branch_info = bi,
@@ -343,7 +345,9 @@ struct hist_entry *__hists__add_entry(struct hists *self,
 		.cpu	= al->cpu,
 		.ip	= al->addr,
 		.level	= al->level,
-		.period	= period,
+		.stat = {
+			.period	= period,
+		},
 		.parent = sym_parent,
 		.filtered = symbol__parent_filter(sym_parent),
 	};
@@ -410,8 +414,8 @@ static bool hists__collapse_insert_entry(struct hists *hists __used,
 		cmp = hist_entry__collapse(iter, he);
 
 		if (!cmp) {
-			iter->period += he->period;
-			iter->nr_events += he->nr_events;
+			iter->stat.period += he->stat.period;
+			iter->stat.nr_events += he->stat.nr_events;
 			if (symbol_conf.use_callchain) {
 				callchain_cursor_reset(&callchain_cursor);
 				callchain_merge(&callchain_cursor,
@@ -513,7 +517,7 @@ static void __hists__insert_output_entry(struct rb_root *entries,
 		parent = *p;
 		iter = rb_entry(parent, struct hist_entry, rb_node);
 
-		if (he->period > iter->period)
+		if (he->stat.period > iter->stat.period)
 			p = &(*p)->rb_left;
 		else
 			p = &(*p)->rb_right;
@@ -574,8 +578,8 @@ static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h
 	if (h->ms.unfolded)
 		hists->nr_entries += h->nr_rows;
 	h->row_offset = 0;
-	hists->stats.total_period += h->period;
-	hists->stats.nr_events[PERF_RECORD_SAMPLE] += h->nr_events;
+	hists->stats.total_period += h->stat.period;
+	hists->stats.nr_events[PERF_RECORD_SAMPLE] += h->stat.nr_events;
 
 	hists__calc_col_len(hists, h);
 }
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 9fdd5039339f..f7b05e0b41c7 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -61,17 +61,12 @@ struct he_stat {
 struct hist_entry {
 	struct rb_node		rb_node_in;
 	struct rb_node		rb_node;
-	u64			period;
-	u64			period_sys;
-	u64			period_us;
-	u64			period_guest_sys;
-	u64			period_guest_us;
+	struct he_stat		stat;
 	struct he_stat		*group_stats;
 	struct map_symbol	ms;
 	struct thread		*thread;
 	u64			ip;
 	s32			cpu;
-	u32			nr_events;
 
 	/* XXX These two should move to some tree widget lib */
 	u16			row_offset;
-- 
1.7.10.4


  parent reply	other threads:[~2012-07-24  9:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-24  9:01 [RFC/PATCHSET 00/12] perf report: Add support to event group viewing (v1) Namhyung Kim
2012-07-24  9:01 ` [PATCH 01/12] perf tools: Add a couple of helper routines to handle groups Namhyung Kim
2012-07-24  9:01 ` Namhyung Kim [this message]
2012-07-24  9:01 ` [PATCH 03/12] perf hist: Collapse group hist_entries to a leader Namhyung Kim
2012-07-24  9:01 ` [PATCH 04/12] perf hist: Maintain total periods of group members in the leader Namhyung Kim
2012-07-24  9:01 ` [PATCH 05/12] perf report: Make another loop for output resorting Namhyung Kim
2012-07-24  9:01 ` [PATCH 06/12] perf header: Reconstruct group relationship by parsing cmdline Namhyung Kim
2012-07-25 15:39   ` Jiri Olsa
2012-07-25 15:52     ` Namhyung Kim
2012-07-24  9:01 ` [PATCH 07/12] perf ui/hist: Add support to group viewing Namhyung Kim
2012-07-24  9:01 ` [PATCH 08/12] perf ui/browser: " Namhyung Kim
2012-07-24  9:01 ` [PATCH 09/12] perf ui/gtk: " Namhyung Kim
2012-07-24  9:01 ` [PATCH 10/12] perf report: Show leader events only when event group is enabled Namhyung Kim
2012-07-24  9:01 ` [PATCH 11/12] perf report: Show group description " Namhyung Kim
2012-07-24  9:01 ` [PATCH 12/12] perf report: Add --group option Namhyung Kim
2012-07-24  9:13 ` [RFC/PATCHSET 00/12] perf report: Add support to event group viewing (v1) Namhyung Kim
2012-07-24 21:17 ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343120493-23059-3-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=andi@firstfloor.org \
    --cc=drepper@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®