linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	David Ahern <dsahern@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
	Namhyung Kim <namhyung@gmail.com>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephane Eranian <eranian@google.com>
Subject: [PATCH 10/21] perf hists: Introduce hists__link
Date: Fri,  9 Nov 2012 18:42:59 -0300	[thread overview]
Message-ID: <1352497390-17716-11-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1352497390-17716-1-git-send-email-acme@infradead.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

That given two hists will find the hist_entries (buckets) in the second
hists that are for the same bucket in the first and link them, then it
will look for all buckets in the second that don't have a counterpart in
the first and will create a dummy counterpart that will then be linked
to the entry in the second.

For multiple events this will be done pairing the leader with all the
other events in the group, so that in the end the leader will have all
the buckets in all the hists in a group, dummy or not while the other
hists will be left untouched.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-l9l9ieozqdhn9lieokd95okw@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/hist.c |   60 ++++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/hist.h |    1 +
 2 files changed, 61 insertions(+)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index c1de3b0..7c6e73b 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -717,6 +717,42 @@ void hists__inc_nr_events(struct hists *hists, u32 type)
 	++hists->stats.nr_events[type];
 }
 
+static struct hist_entry *hists__add_dummy_entry(struct hists *hists,
+						 struct hist_entry *pair)
+{
+	struct rb_node **p = &hists->entries.rb_node;
+	struct rb_node *parent = NULL;
+	struct hist_entry *he;
+	int cmp;
+
+	while (*p != NULL) {
+		parent = *p;
+		he = rb_entry(parent, struct hist_entry, rb_node);
+
+		cmp = hist_entry__cmp(pair, he);
+
+		if (!cmp)
+			goto out;
+
+		if (cmp < 0)
+			p = &(*p)->rb_left;
+		else
+			p = &(*p)->rb_right;
+	}
+
+	he = hist_entry__new(pair);
+	if (he) {
+		he->stat.nr_events = 0;
+		he->stat.period    = 0;
+		he->hists	   = hists;
+		rb_link_node(&he->rb_node, parent, p);
+		rb_insert_color(&he->rb_node, &hists->entries);
+		hists__inc_nr_entries(hists, he);
+	}
+out:
+	return he;
+}
+
 static struct hist_entry *hists__find_entry(struct hists *hists,
 					    struct hist_entry *he)
 {
@@ -753,3 +789,27 @@ void hists__match(struct hists *leader, struct hists *other)
 			hist__entry_add_pair(pos, pair);
 	}
 }
+
+/*
+ * Look for entries in the other hists that are not present in the leader, if
+ * we find them, just add a dummy entry on the leader hists, with period=0,
+ * nr_events=0, to serve as the list header.
+ */
+int hists__link(struct hists *leader, struct hists *other)
+{
+	struct rb_node *nd;
+	struct hist_entry *pos, *pair;
+
+	for (nd = rb_first(&other->entries); nd; nd = rb_next(nd)) {
+		pos = rb_entry(nd, struct hist_entry, rb_node);
+
+		if (!hist_entry__has_pairs(pos)) {
+			pair = hists__add_dummy_entry(leader, pos);
+			if (pair == NULL)
+				return -1;
+			hist__entry_add_pair(pair, pos);
+		}
+	}
+
+	return 0;
+}
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index ff1c396..1278c2c 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -116,6 +116,7 @@ void hists__reset_col_len(struct hists *hists);
 void hists__calc_col_len(struct hists *hists, struct hist_entry *he);
 
 void hists__match(struct hists *leader, struct hists *other);
+int hists__link(struct hists *leader, struct hists *other);
 
 struct perf_hpp {
 	char *buf;
-- 
1.7.9.2.358.g22243


  parent reply	other threads:[~2012-11-09 21:47 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-09 21:42 [GIT PULL 00/21] perf/core improvements and fixes Arnaldo Carvalho de Melo
2012-11-09 21:42 ` [PATCH 01/21] perf machine: Set kernel data mapping length Arnaldo Carvalho de Melo
2012-11-09 21:42 ` [PATCH 02/21] perf tools: Fix detection of stack area Arnaldo Carvalho de Melo
2012-11-09 21:42 ` [PATCH 03/21] perf hists: Free branch_info when freeing hist_entry Arnaldo Carvalho de Melo
2012-11-09 21:42 ` [PATCH 04/21] perf tests: Move attr.py temp dir cleanup into finally section Arnaldo Carvalho de Melo
2012-11-09 21:42 ` [PATCH 05/21] perf tools: Add LIBDW_DIR Makefile variable to for alternate libdw Arnaldo Carvalho de Melo
2012-11-09 21:42 ` [PATCH 06/21] perf tools: Add arbitary aliases and support names with - Arnaldo Carvalho de Melo
2012-11-09 21:42 ` [PATCH 07/21] perf tools: Don't try to lookup objdump for live mode Arnaldo Carvalho de Melo
2012-11-09 21:42 ` [PATCH 08/21] perf diff: Start moving to support matching more than two hists Arnaldo Carvalho de Melo
2012-11-09 21:42 ` [PATCH 09/21] perf diff: Move hists__match to the hists lib Arnaldo Carvalho de Melo
2012-11-09 21:42 ` Arnaldo Carvalho de Melo [this message]
2012-11-12  2:40   ` [PATCH 10/21] perf hists: Introduce hists__link Namhyung Kim
2012-11-12 16:04     ` Arnaldo Carvalho de Melo
2012-11-09 21:43 ` [PATCH 11/21] perf diff: Use hists__link when not pairing just with baseline Arnaldo Carvalho de Melo
2012-11-09 21:43 ` [PATCH 12/21] perf machine: Move more methods to machine.[ch] Arnaldo Carvalho de Melo
2012-11-09 21:43 ` [PATCH 13/21] perf test: fix a build error on builtin-test Arnaldo Carvalho de Melo
2012-11-09 21:43 ` [PATCH 14/21] perf annotate: Whitespace fixups Arnaldo Carvalho de Melo
2012-11-09 21:43 ` [PATCH 15/21] perf annotate: Don't try to follow jump target on PLT symbols Arnaldo Carvalho de Melo
2012-11-09 21:43 ` [PATCH 16/21] perf annotate: Merge same lines in summary view Arnaldo Carvalho de Melo
2012-11-09 21:43 ` [PATCH 17/21] tools lib traceevent: Add __maybe_unused to unused parameters Arnaldo Carvalho de Melo
2012-11-09 21:43 ` [PATCH 18/21] tools lib traceevent: Avoid comparisions between signed/unsigned Arnaldo Carvalho de Melo
2012-11-09 21:43 ` [PATCH 19/21] tools lib traceevent: No need to check for < 0 on an unsigned enum Arnaldo Carvalho de Melo
2012-11-09 21:43 ` [PATCH 20/21] tools lib traceevent: Handle INVALID_ARG_TYPE errno in pevent_strerror Arnaldo Carvalho de Melo
2012-11-09 21:43 ` [PATCH 21/21] tools lib traceevent: Use 'const' in variables pointing to const strings Arnaldo Carvalho de Melo
2012-11-12  2:10 ` [GIT PULL 00/21] perf/core improvements and fixes Namhyung Kim
2012-11-12 13:55   ` Jiri Olsa
2012-11-12 16:01     ` Arnaldo Carvalho de Melo
2012-11-13  1:20       ` Namhyung Kim
2012-11-13 18:11 ` Ingo Molnar

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=1352497390-17716-11-git-send-email-acme@infradead.org \
    --to=acme@infradead.org \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).