Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1324157 > unrolled thread
| Started by | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| First post | 2016-02-02 15:50 +0100 |
| Last post | 2016-02-02 18:00 +0100 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 06/21] perf hists: Return error from hists__collapse_resort() Namhyung Kim <namhyung@kernel.org> - 2016-02-02 15:50 +0100
Re: [PATCH 06/21] perf hists: Return error from hists__collapse_resort() Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-02 18:00 +0100
Re: [PATCH 06/21] perf hists: Return error from hists__collapse_resort() Namhyung Kim <namhyung@kernel.org> - 2016-02-03 15:20 +0100
Re: [PATCH 06/21] perf hists: Return error from hists__collapse_resort() Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-02 18:00 +0100
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2016-02-02 15:50 +0100 |
| Subject | [PATCH 06/21] perf hists: Return error from hists__collapse_resort() |
| Message-ID | <qXKrh-4kd-47@gated-at.bofh.it> |
Currently hists__collapse_resort() and hists__collapse_insert_entry()
don't return error code. Now callchain_merge() can check error case,
abort and pass the error to the user. Later patch can add more work
which can be failed too.
Acked-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/hist.c | 27 +++++++++++++++++----------
tools/perf/util/hist.h | 4 ++--
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 098310bc4489..b476b599e415 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1016,8 +1016,8 @@ void hist_entry__delete(struct hist_entry *he)
* 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;
@@ -1037,12 +1037,13 @@ bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,
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)
+ return -1;
}
hist_entry__delete(he);
- return false;
+ return 0;
}
if (cmp < 0)
@@ -1054,7 +1055,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)
@@ -1080,14 +1081,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;
@@ -1102,7 +1104,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
@@ -1113,6 +1119,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 d4ec4822a103..9c72f8331d1c 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -129,7 +129,7 @@ int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size,
void hist_entry__delete(struct hist_entry *he);
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);
@@ -188,7 +188,7 @@ int hists__init(void);
int __hists__init(struct hists *hists);
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 {
--
2.6.4
[toc] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-02-02 18:00 +0100 |
| Subject | Re: [PATCH 06/21] perf hists: Return error from hists__collapse_resort() |
| Message-ID | <qXMt5-5Rl-13@gated-at.bofh.it> |
| In reply to | #1324157 |
Em Tue, Feb 02, 2016 at 01:52:05PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Tue, Feb 02, 2016 at 11:39:48PM +0900, Namhyung Kim escreveu:
> > Currently hists__collapse_resort() and hists__collapse_insert_entry()
> > don't return error code. Now callchain_merge() can check error case,
> > abort and pass the error to the user. Later patch can add more work
> > which can be failed too.
> >
> > Acked-by: Jiri Olsa <jolsa@kernel.org>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> > tools/perf/util/hist.c | 27 +++++++++++++++++----------
> > tools/perf/util/hist.h | 4 ++--
> > 2 files changed, 19 insertions(+), 12 deletions(-)
> >
> > diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
> > index 098310bc4489..b476b599e415 100644
> > --- a/tools/perf/util/hist.c
> > +++ b/tools/perf/util/hist.c
> > @@ -1016,8 +1016,8 @@ void hist_entry__delete(struct hist_entry *he)
> > * 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;
> > @@ -1037,12 +1037,13 @@ bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,
> >
> > 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)
> > + return -1;
>
> So now we're exiting on error here, whereas before we would
> unconditionally call hist_entry__delete() right after this branch... Is
> that right?
> > }
> > hist_entry__delete(he);
> > - return false;
> > + return 0;
> > }
>
> Looking at it...
Below it does:
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;
So, we remove it from the rb tree it is in, and previously we expected
that hists__collapse_insert_entry would hist_entry__delete(n), while
now, if callchain_merge() fails, we leak it, no?
- Arnaldo
> >
> > if (cmp < 0)
> > @@ -1054,7 +1055,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)
> > @@ -1080,14 +1081,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;
> >
> > @@ -1102,7 +1104,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
> > @@ -1113,6 +1119,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 d4ec4822a103..9c72f8331d1c 100644
> > --- a/tools/perf/util/hist.h
> > +++ b/tools/perf/util/hist.h
> > @@ -129,7 +129,7 @@ int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size,
> > void hist_entry__delete(struct hist_entry *he);
> >
> > 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);
> > @@ -188,7 +188,7 @@ int hists__init(void);
> > int __hists__init(struct hists *hists);
> >
> > 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 {
> > --
> > 2.6.4
[toc] | [prev] | [next] | [standalone]
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2016-02-03 15:20 +0100 |
| Subject | Re: [PATCH 06/21] perf hists: Return error from hists__collapse_resort() |
| Message-ID | <qY6rL-31V-5@gated-at.bofh.it> |
| In reply to | #1324280 |
Hi Arnaldo,
On Tue, Feb 02, 2016 at 01:56:34PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Feb 02, 2016 at 01:52:05PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Tue, Feb 02, 2016 at 11:39:48PM +0900, Namhyung Kim escreveu:
> > > Currently hists__collapse_resort() and hists__collapse_insert_entry()
> > > don't return error code. Now callchain_merge() can check error case,
> > > abort and pass the error to the user. Later patch can add more work
> > > which can be failed too.
> > >
> > > Acked-by: Jiri Olsa <jolsa@kernel.org>
> > > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > > ---
> > > tools/perf/util/hist.c | 27 +++++++++++++++++----------
> > > tools/perf/util/hist.h | 4 ++--
> > > 2 files changed, 19 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
> > > index 098310bc4489..b476b599e415 100644
> > > --- a/tools/perf/util/hist.c
> > > +++ b/tools/perf/util/hist.c
> > > @@ -1016,8 +1016,8 @@ void hist_entry__delete(struct hist_entry *he)
> > > * 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;
> > > @@ -1037,12 +1037,13 @@ bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,
> > >
> > > 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)
> > > + return -1;
> >
> > So now we're exiting on error here, whereas before we would
> > unconditionally call hist_entry__delete() right after this branch... Is
> > that right?
>
> > > }
> > > hist_entry__delete(he);
> > > - return false;
> > > + return 0;
> > > }
> >
>
> > Looking at it...
>
> Below it does:
>
> 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;
>
> So, we remove it from the rb tree it is in, and previously we expected
> that hists__collapse_insert_entry would hist_entry__delete(n), while
> now, if callchain_merge() fails, we leak it, no?
You're right, will fix..
Thanks,
Namhyung
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-02-02 18:00 +0100 |
| Subject | Re: [PATCH 06/21] perf hists: Return error from hists__collapse_resort() |
| Message-ID | <qXMt5-5Rl-15@gated-at.bofh.it> |
| In reply to | #1324157 |
Em Tue, Feb 02, 2016 at 11:39:48PM +0900, Namhyung Kim escreveu:
> Currently hists__collapse_resort() and hists__collapse_insert_entry()
> don't return error code. Now callchain_merge() can check error case,
> abort and pass the error to the user. Later patch can add more work
> which can be failed too.
>
> Acked-by: Jiri Olsa <jolsa@kernel.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/util/hist.c | 27 +++++++++++++++++----------
> tools/perf/util/hist.h | 4 ++--
> 2 files changed, 19 insertions(+), 12 deletions(-)
>
> diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
> index 098310bc4489..b476b599e415 100644
> --- a/tools/perf/util/hist.c
> +++ b/tools/perf/util/hist.c
> @@ -1016,8 +1016,8 @@ void hist_entry__delete(struct hist_entry *he)
> * 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;
> @@ -1037,12 +1037,13 @@ bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,
>
> 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)
> + return -1;
So now we're exiting on error here, whereas before we would
unconditionally call hist_entry__delete() right after this branch... Is
that right?
Looking at it...
> }
> hist_entry__delete(he);
> - return false;
> + return 0;
> }
>
> if (cmp < 0)
> @@ -1054,7 +1055,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)
> @@ -1080,14 +1081,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;
>
> @@ -1102,7 +1104,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
> @@ -1113,6 +1119,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 d4ec4822a103..9c72f8331d1c 100644
> --- a/tools/perf/util/hist.h
> +++ b/tools/perf/util/hist.h
> @@ -129,7 +129,7 @@ int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size,
> void hist_entry__delete(struct hist_entry *he);
>
> 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);
> @@ -188,7 +188,7 @@ int hists__init(void);
> int __hists__init(struct hists *hists);
>
> 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 {
> --
> 2.6.4
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web