perf callchain: Move validate_callchain to callchain lib
authorArnaldo Carvalho de Melo <acme@redhat.com>
Sun, 9 May 2010 14:47:13 +0000 (11:47 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sun, 9 May 2010 16:07:05 +0000 (13:07 -0300)
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
tools/perf/util/callchain.c
tools/perf/util/callchain.h

index 196473b51257544473885b1c3973fdaaffe9a0d3..1cae877137923464d0e4f74c7ce447761d333539 100644 (file)
@@ -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;
index db628af6d20dd5ab10fe5a188b0a6277bf49f518..ac148613afe820ab95499313b4283a3bbfc3277a 100644 (file)
 
 #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)
 
index 8a7e8bbd0fdacfc86fec1290f3502a56965d8d16..0f4da093cbd8580d301954031d47bdba9fff6143 100644 (file)
@@ -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 */