public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, mingo@kernel.org, jolsa@kernel.org,
	linux-kernel@vger.kernel.org, hpa@zytor.com, dsahern@gmail.com,
	namhyung@kernel.org, wangnan0@huawei.com, andi@firstfloor.org,
	acme@redhat.com, peterz@infradead.org, eranian@google.com
Subject: [tip:perf/core] perf hists: Return error from hists__collapse_resort()
Date: Sat, 20 Feb 2016 03:41:17 -0800	[thread overview]
Message-ID: <tip-bba58cdfaace2eb96d2b3cabc610d2ba033371c8@git.kernel.org> (raw)
In-Reply-To: <1455631723-17345-8-git-send-email-namhyung@kernel.org>

Commit-ID:  bba58cdfaace2eb96d2b3cabc610d2ba033371c8
Gitweb:     http://git.kernel.org/tip/bba58cdfaace2eb96d2b3cabc610d2ba033371c8
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Tue, 16 Feb 2016 23:08:25 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 19 Feb 2016 19:16:06 -0300

perf hists: Return error from hists__collapse_resort()

Currently hists__collapse_resort() and hists__collapse_insert_entry()
don't return an error code. Now that callchain_merge() can check for
errors, abort and pass the error to the user.  A later patch can add
more work which also can fail.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1455631723-17345-8-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/hist.c | 29 +++++++++++++++++++----------
 tools/perf/util/hist.h |  4 ++--
 2 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index a856617..827c6cb 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1046,8 +1046,8 @@ int hist_entry__snprintf_alignment(struct hist_entry *he, struct perf_hpp *hpp,
  * collapse the histogram
  */
 
-bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,
-				  struct rb_root *root, struct hist_entry *he)
+int hists__collapse_insert_entry(struct hists *hists, struct rb_root *root,
+				 struct hist_entry *he)
 {
 	struct rb_node **p = &root->rb_node;
 	struct rb_node *parent = NULL;
@@ -1061,18 +1061,21 @@ bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,
 		cmp = hist_entry__collapse(iter, he);
 
 		if (!cmp) {
+			int ret = 0;
+
 			he_stat__add_stat(&iter->stat, &he->stat);
 			if (symbol_conf.cumulate_callchain)
 				he_stat__add_stat(iter->stat_acc, he->stat_acc);
 
 			if (symbol_conf.use_callchain) {
 				callchain_cursor_reset(&callchain_cursor);
-				callchain_merge(&callchain_cursor,
-						iter->callchain,
-						he->callchain);
+				if (callchain_merge(&callchain_cursor,
+						    iter->callchain,
+						    he->callchain) < 0)
+					ret = -1;
 			}
 			hist_entry__delete(he);
-			return false;
+			return ret;
 		}
 
 		if (cmp < 0)
@@ -1084,7 +1087,7 @@ bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,
 
 	rb_link_node(&he->rb_node_in, parent, p);
 	rb_insert_color(&he->rb_node_in, root);
-	return true;
+	return 1;
 }
 
 struct rb_root *hists__get_rotate_entries_in(struct hists *hists)
@@ -1110,14 +1113,15 @@ static void hists__apply_filters(struct hists *hists, struct hist_entry *he)
 	hists__filter_entry_by_socket(hists, he);
 }
 
-void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
+int hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
 {
 	struct rb_root *root;
 	struct rb_node *next;
 	struct hist_entry *n;
+	int ret;
 
 	if (!sort__need_collapse)
-		return;
+		return 0;
 
 	hists->nr_entries = 0;
 
@@ -1132,7 +1136,11 @@ void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
 		next = rb_next(&n->rb_node_in);
 
 		rb_erase(&n->rb_node_in, root);
-		if (hists__collapse_insert_entry(hists, &hists->entries_collapsed, n)) {
+		ret = hists__collapse_insert_entry(hists, &hists->entries_collapsed, n);
+		if (ret < 0)
+			return -1;
+
+		if (ret) {
 			/*
 			 * If it wasn't combined with one of the entries already
 			 * collapsed, we need to apply the filters that may have
@@ -1143,6 +1151,7 @@ void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
 		if (prog)
 			ui_progress__update(prog, 1);
 	}
+	return 0;
 }
 
 static int hist_entry__sort(struct hist_entry *a, struct hist_entry *b)
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 045a9e7..97baa1d 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -138,7 +138,7 @@ void hist_entry__delete(struct hist_entry *he);
 
 void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *prog);
 void hists__output_resort(struct hists *hists, struct ui_progress *prog);
-void hists__collapse_resort(struct hists *hists, struct ui_progress *prog);
+int hists__collapse_resort(struct hists *hists, struct ui_progress *prog);
 
 void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel);
 void hists__delete_entries(struct hists *hists);
@@ -197,7 +197,7 @@ int hists__init(void);
 int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list);
 
 struct rb_root *hists__get_rotate_entries_in(struct hists *hists);
-bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,
+int hists__collapse_insert_entry(struct hists *hists,
 				  struct rb_root *root, struct hist_entry *he);
 
 struct perf_hpp {

  reply	other threads:[~2016-02-20 11:42 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 14:08 [PATCHSET 00/25] perf tools: Add support for hierachy view (v6) Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 01/25] perf hists browser: Fix percentage update on key press Namhyung Kim
2016-02-16 20:06   ` Arnaldo Carvalho de Melo
2016-02-16 20:53     ` Arnaldo Carvalho de Melo
2016-02-16 23:39       ` Namhyung Kim
2016-02-17 13:41         ` Arnaldo Carvalho de Melo
2016-02-20 11:39   ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 02/25] perf callchain: Check return value of add_child() Namhyung Kim
2016-02-20 11:39   ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 03/25] perf callchain: Check return value of fill_node() Namhyung Kim
2016-02-20 11:39   ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 04/25] perf callchain: Add enum match_result for match_chain() Namhyung Kim
2016-02-20 11:40   ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 05/25] perf callchain: Check return value of split_add_child() Namhyung Kim
2016-02-20 11:40   ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 06/25] perf callchain: Check return value of append_chain_children() Namhyung Kim
2016-02-20 11:40   ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 07/25] perf hists: Return error from hists__collapse_resort() Namhyung Kim
2016-02-20 11:41   ` tip-bot for Namhyung Kim [this message]
2016-02-16 14:08 ` [PATCH v6 08/25] perf report: Check error during report__collapse_hists() Namhyung Kim
2016-02-20 11:41   ` [tip:perf/core] " tip-bot for Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 09/25] perf hists: Basic support of hierarchical report view Namhyung Kim
2016-02-20 23:18   ` Jiri Olsa
2016-02-21  8:32     ` Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 10/25] perf hists: Resort hist entries with hierarchy Namhyung Kim
2016-02-20 23:19   ` Jiri Olsa
2016-02-21  8:36     ` Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 11/25] perf hists: Add helper functions for hierarchy mode Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 12/25] perf hists: Introduce hist_entry__filter() Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 13/25] perf hists: Support filtering in hierarchy mode Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 14/25] perf hists: Resort after filtering hierarchy Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 15/25] perf hists: Count number of sort keys Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 16/25] perf ui/stdio: Implement hierarchy output mode Namhyung Kim
2016-02-20 23:18   ` Jiri Olsa
2016-02-21  8:43     ` Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 17/25] perf ui/stdio: Align column header for hierarchy output Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 18/25] perf hists browser: Count number of hierarchy entries Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 19/25] perf hists browser: Support collapsing/expanding whole entries in hierarchy Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 20/25] perf hists browser: Implement hierarchy output Namhyung Kim
2016-02-20 23:19   ` Jiri Olsa
2016-02-16 14:08 ` [PATCH v6 21/25] perf hists browser: Align column header in hierarchy mode Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 22/25] perf ui/gtk: Implement hierarchy output mode Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 23/25] perf report: Add --hierarchy option Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 24/25] perf hists: Support decaying in hierarchy mode Namhyung Kim
2016-02-16 14:08 ` [PATCH v6 25/25] perf top: Add --hierarchy option Namhyung Kim
2016-02-20 23:19   ` Jiri Olsa
2016-02-21  9:19     ` Namhyung Kim

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=tip-bba58cdfaace2eb96d2b3cabc610d2ba033371c8@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=wangnan0@huawei.com \
    /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