* [PATCH 0/3] perf tools minor fixes
@ 2010-05-09 16:14 Arnaldo Carvalho de Melo
2010-05-09 16:14 ` [PATCH 1/3] perf callchain: Move validate_callchain to callchain lib Arnaldo Carvalho de Melo
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-05-09 16:14 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo,
Frédéric Weisbecker, Mike Galbraith, Paul Mackerras,
Peter Zijlstra, Tom, Zanussi <tzanussi
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Hi Ingo,
Please pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 perf
Regards,
Arnaldo Carvalho de Melo (3):
perf callchain: Move validate_callchain to callchain lib
perf report: Fix leak of resolved callchains array on error path
perf hist: Simplify the insertion of new hist_entry instances
tools/perf/builtin-annotate.c | 9 ++-----
tools/perf/builtin-diff.c | 14 ++----------
tools/perf/builtin-report.c | 43 +++++++++-------------------------------
tools/perf/util/callchain.c | 7 ++++++
tools/perf/util/callchain.h | 3 ++
tools/perf/util/hist.c | 36 +++++++++++++++++++++------------
tools/perf/util/hist.h | 5 +---
7 files changed, 50 insertions(+), 67 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] perf callchain: Move validate_callchain to callchain lib
2010-05-09 16:14 [PATCH 0/3] perf tools minor fixes Arnaldo Carvalho de Melo
@ 2010-05-09 16:14 ` Arnaldo Carvalho de Melo
2010-05-09 16:14 ` [PATCH 2/3] perf report: Fix leak of resolved callchains array on error path Arnaldo Carvalho de Melo
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-05-09 16:14 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo,
Frédéric Weisbecker, Mike Galbraith, Paul Mackerras,
Peter Zijlstra, Tom Zanussi
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-report.c | 15 +--------------
tools/perf/util/callchain.c | 7 +++++++
tools/perf/util/callchain.h | 3 +++
3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 196473b..1cae877 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -123,19 +123,6 @@ static int perf_session__add_hist_entry(struct perf_session *self,
return 0;
}
-static int validate_chain(struct ip_callchain *chain, event_t *event)
-{
- unsigned int chain_size;
-
- chain_size = event->header.size;
- chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event;
-
- if (chain->nr*sizeof(u64) > chain_size)
- return -1;
-
- return 0;
-}
-
static int add_event_total(struct perf_session *session,
struct sample_data *data,
struct perf_event_attr *attr)
@@ -171,7 +158,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)
dump_printf("... chain: nr:%Lu\n", data.callchain->nr);
- if (validate_chain(data.callchain, event) < 0) {
+ if (!ip_callchain__valid(data.callchain, event)) {
pr_debug("call-chain problem with event, "
"skipping it.\n");
return 0;
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index db628af..ac14861 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -17,6 +17,13 @@
#include "callchain.h"
+bool ip_callchain__valid(struct ip_callchain *chain, event_t *event)
+{
+ unsigned int chain_size = event->header.size;
+ chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event;
+ return chain->nr * sizeof(u64) <= chain_size;
+}
+
#define chain_for_each_child(child, parent) \
list_for_each_entry(child, &parent->children, brothers)
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 8a7e8bb..0f4da09 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -4,6 +4,7 @@
#include "../perf.h"
#include <linux/list.h>
#include <linux/rbtree.h>
+#include "event.h"
#include "util.h"
#include "symbol.h"
@@ -58,4 +59,6 @@ static inline u64 cumul_hits(struct callchain_node *node)
int register_callchain_param(struct callchain_param *param);
int append_chain(struct callchain_node *root, struct ip_callchain *chain,
struct map_symbol *syms);
+
+bool ip_callchain__valid(struct ip_callchain *chain, event_t *event);
#endif /* __PERF_CALLCHAIN_H */
--
1.6.2.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] perf report: Fix leak of resolved callchains array on error path
2010-05-09 16:14 [PATCH 0/3] perf tools minor fixes Arnaldo Carvalho de Melo
2010-05-09 16:14 ` [PATCH 1/3] perf callchain: Move validate_callchain to callchain lib Arnaldo Carvalho de Melo
@ 2010-05-09 16:14 ` Arnaldo Carvalho de Melo
2010-05-09 16:14 ` [PATCH 3/3] perf hist: Simplify the insertion of new hist_entry instances Arnaldo Carvalho de Melo
2010-05-09 17:48 ` [PATCH 0/3] perf tools minor fixes Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-05-09 16:14 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo,
Frédéric Weisbecker, Mike Galbraith, Paul Mackerras,
Peter Zijlstra, Tom Zanussi
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-report.c | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 1cae877..3a70c58 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -83,7 +83,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,
struct map_symbol *syms = NULL;
struct symbol *parent = NULL;
bool hit;
- int err;
+ int err = -ENOMEM;
struct hist_entry *he;
struct event_stat_id *stats;
struct perf_event_attr *attr;
@@ -101,26 +101,24 @@ static int perf_session__add_hist_entry(struct perf_session *self,
else
stats = get_stats(self, data->id, 0, 0);
if (stats == NULL)
- return -ENOMEM;
+ goto out_free_syms;
he = __perf_session__add_hist_entry(&stats->hists, al, parent,
data->period, &hit);
if (he == NULL)
- return -ENOMEM;
+ goto out_free_syms;
if (hit)
__perf_session__add_count(he, al, data->period);
+ err = 0;
if (symbol_conf.use_callchain) {
if (!hit)
callchain_init(he->callchain);
err = append_chain(he->callchain, data->callchain, syms);
- free(syms);
-
- if (err)
- return err;
}
-
- return 0;
+out_free_syms:
+ free(syms);
+ return err;
}
static int add_event_total(struct perf_session *session,
--
1.6.2.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] perf hist: Simplify the insertion of new hist_entry instances
2010-05-09 16:14 [PATCH 0/3] perf tools minor fixes Arnaldo Carvalho de Melo
2010-05-09 16:14 ` [PATCH 1/3] perf callchain: Move validate_callchain to callchain lib Arnaldo Carvalho de Melo
2010-05-09 16:14 ` [PATCH 2/3] perf report: Fix leak of resolved callchains array on error path Arnaldo Carvalho de Melo
@ 2010-05-09 16:14 ` Arnaldo Carvalho de Melo
2010-05-09 17:48 ` [PATCH 0/3] perf tools minor fixes Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-05-09 16:14 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo,
Frédéric Weisbecker, Mike Galbraith, Paul Mackerras,
Peter Zijlstra, Tom Zanussi
From: Arnaldo Carvalho de Melo <acme@redhat.com>
And with that fix at least one bug:
The first hit for an entry, the one that calls malloc to create a new
instance in __perf_session__add_hist_entry, wasn't adding the count to
the per cpumode (PERF_RECORD_MISC_USER, etc) total variable.
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-annotate.c | 9 +++------
tools/perf/builtin-diff.c | 14 +++-----------
tools/perf/builtin-report.c | 12 ++----------
tools/perf/util/hist.c | 36 +++++++++++++++++++++++-------------
tools/perf/util/hist.h | 5 +----
5 files changed, 32 insertions(+), 44 deletions(-)
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index ee154b5..c7ac45a 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -72,8 +72,6 @@ static int annotate__hist_hit(struct hist_entry *he, u64 ip)
struct sym_priv *priv;
struct sym_hist *h;
- he->count++;
-
if (!sym || !he->ms.map)
return 0;
@@ -99,9 +97,8 @@ static int annotate__hist_hit(struct hist_entry *he, u64 ip)
}
static int perf_session__add_hist_entry(struct perf_session *self,
- struct addr_location *al, u64 count)
+ struct addr_location *al)
{
- bool hit;
struct hist_entry *he;
if (sym_hist_filter != NULL &&
@@ -115,7 +112,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,
return 0;
}
- he = __perf_session__add_hist_entry(&self->hists, al, NULL, count, &hit);
+ he = __perf_session__add_hist_entry(&self->hists, al, NULL, 1);
if (he == NULL)
return -ENOMEM;
@@ -135,7 +132,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)
return -1;
}
- if (!al.filtered && perf_session__add_hist_entry(session, &al, 1)) {
+ if (!al.filtered && perf_session__add_hist_entry(session, &al)) {
pr_warning("problem incrementing symbol count, "
"skipping event\n");
return -1;
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 4cce68f..613a5c4 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -25,17 +25,9 @@ static bool show_displacement;
static int perf_session__add_hist_entry(struct perf_session *self,
struct addr_location *al, u64 count)
{
- bool hit;
- struct hist_entry *he = __perf_session__add_hist_entry(&self->hists,
- al, NULL,
- count, &hit);
- if (he == NULL)
- return -ENOMEM;
-
- if (hit)
- __perf_session__add_count(he, al, count);
-
- return 0;
+ if (__perf_session__add_hist_entry(&self->hists, al, NULL, count) != NULL)
+ return 0;
+ return -ENOMEM;
}
static int diff__process_sample_event(event_t *event, struct perf_session *session)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 3a70c58..5e2f47f 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -82,7 +82,6 @@ static int perf_session__add_hist_entry(struct perf_session *self,
{
struct map_symbol *syms = NULL;
struct symbol *parent = NULL;
- bool hit;
int err = -ENOMEM;
struct hist_entry *he;
struct event_stat_id *stats;
@@ -103,19 +102,12 @@ static int perf_session__add_hist_entry(struct perf_session *self,
if (stats == NULL)
goto out_free_syms;
he = __perf_session__add_hist_entry(&stats->hists, al, parent,
- data->period, &hit);
+ data->period);
if (he == NULL)
goto out_free_syms;
-
- if (hit)
- __perf_session__add_count(he, al, data->period);
-
err = 0;
- if (symbol_conf.use_callchain) {
- if (!hit)
- callchain_init(he->callchain);
+ if (symbol_conf.use_callchain)
err = append_chain(he->callchain, data->callchain, syms);
- }
out_free_syms:
free(syms);
return err;
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index ad6b22d..e0c8a72 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -8,13 +8,10 @@ struct callchain_param callchain_param = {
.min_percent = 0.5
};
-void __perf_session__add_count(struct hist_entry *he,
- struct addr_location *al,
- u64 count)
+static void perf_session__add_cpumode_count(struct hist_entry *he,
+ unsigned int cpumode, u64 count)
{
- he->count += count;
-
- switch (al->cpumode) {
+ switch (cpumode) {
case PERF_RECORD_MISC_KERNEL:
he->count_sys += count;
break;
@@ -36,10 +33,24 @@ void __perf_session__add_count(struct hist_entry *he,
* histogram, sorted on item, collects counts
*/
+static struct hist_entry *hist_entry__new(struct hist_entry *template)
+{
+ size_t callchain_size = symbol_conf.use_callchain ? sizeof(struct callchain_node) : 0;
+ struct hist_entry *self = malloc(sizeof(*self) + callchain_size);
+
+ if (self != NULL) {
+ *self = *template;
+ if (symbol_conf.use_callchain)
+ callchain_init(self->callchain);
+ }
+
+ return self;
+}
+
struct hist_entry *__perf_session__add_hist_entry(struct rb_root *hists,
struct addr_location *al,
struct symbol *sym_parent,
- u64 count, bool *hit)
+ u64 count)
{
struct rb_node **p = &hists->rb_node;
struct rb_node *parent = NULL;
@@ -64,8 +75,8 @@ struct hist_entry *__perf_session__add_hist_entry(struct rb_root *hists,
cmp = hist_entry__cmp(&entry, he);
if (!cmp) {
- *hit = true;
- return he;
+ he->count += count;
+ goto out;
}
if (cmp < 0)
@@ -74,14 +85,13 @@ struct hist_entry *__perf_session__add_hist_entry(struct rb_root *hists,
p = &(*p)->rb_right;
}
- he = malloc(sizeof(*he) + (symbol_conf.use_callchain ?
- sizeof(struct callchain_node) : 0));
+ he = hist_entry__new(&entry);
if (!he)
return NULL;
- *he = entry;
rb_link_node(&he->rb_node, parent, p);
rb_insert_color(&he->rb_node, hists);
- *hit = false;
+out:
+ perf_session__add_cpumode_count(he, al->cpumode, count);
return he;
}
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 9df1c34..b49013a 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -12,13 +12,10 @@ struct addr_location;
struct symbol;
struct rb_root;
-void __perf_session__add_count(struct hist_entry *he,
- struct addr_location *al,
- u64 count);
struct hist_entry *__perf_session__add_hist_entry(struct rb_root *hists,
struct addr_location *al,
struct symbol *parent,
- u64 count, bool *hit);
+ u64 count);
extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *);
extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *);
int hist_entry__fprintf(struct hist_entry *self,
--
1.6.2.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] perf tools minor fixes
2010-05-09 16:14 [PATCH 0/3] perf tools minor fixes Arnaldo Carvalho de Melo
` (2 preceding siblings ...)
2010-05-09 16:14 ` [PATCH 3/3] perf hist: Simplify the insertion of new hist_entry instances Arnaldo Carvalho de Melo
@ 2010-05-09 17:48 ` Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2010-05-09 17:48 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Arnaldo Carvalho de Melo, Fr??d??ric Weisbecker,
Mike Galbraith, Paul Mackerras, Peter Zijlstra, Tom,
Zanussi <tzanussi
* Arnaldo Carvalho de Melo <acme@infradead.org> wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> Hi Ingo,
>
> Please pull from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 perf
>
> Regards,
>
> Arnaldo Carvalho de Melo (3):
> perf callchain: Move validate_callchain to callchain lib
> perf report: Fix leak of resolved callchains array on error path
> perf hist: Simplify the insertion of new hist_entry instances
>
> tools/perf/builtin-annotate.c | 9 ++-----
> tools/perf/builtin-diff.c | 14 ++----------
> tools/perf/builtin-report.c | 43 +++++++++-------------------------------
> tools/perf/util/callchain.c | 7 ++++++
> tools/perf/util/callchain.h | 3 ++
> tools/perf/util/hist.c | 36 +++++++++++++++++++++------------
> tools/perf/util/hist.h | 5 +---
> 7 files changed, 50 insertions(+), 67 deletions(-)
Pulled, thanks Arnaldo!
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-05-09 17:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-09 16:14 [PATCH 0/3] perf tools minor fixes Arnaldo Carvalho de Melo
2010-05-09 16:14 ` [PATCH 1/3] perf callchain: Move validate_callchain to callchain lib Arnaldo Carvalho de Melo
2010-05-09 16:14 ` [PATCH 2/3] perf report: Fix leak of resolved callchains array on error path Arnaldo Carvalho de Melo
2010-05-09 16:14 ` [PATCH 3/3] perf hist: Simplify the insertion of new hist_entry instances Arnaldo Carvalho de Melo
2010-05-09 17:48 ` [PATCH 0/3] perf tools minor fixes Ingo Molnar
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®