From: Namhyung Kim <namhyung....@lge.com>

Change the add_hist_entry() to make a template based on given @al.
It makes the callchain cumulation code simpler.

Cc: Arun Sharma <asha...@fb.com>
Cc: Frederic Weisbecker <fweis...@gmail.com>
Signed-off-by: Namhyung Kim <namhy...@kernel.org>
---
 tools/perf/util/hist.c | 50 +++++++++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 46433a0830dd..f96298f59e49 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -299,10 +299,10 @@ static u8 symbol__parent_filter(const struct symbol 
*parent)
        return 0;
 }
 
-static struct hist_entry *add_hist_entry(struct hists *hists,
-                                     struct hist_entry *entry,
-                                     struct addr_location *al,
-                                     u64 period, bool sample_self)
+static struct hist_entry *__add_hist_entry(struct hists *hists,
+                                          struct hist_entry *entry,
+                                          struct addr_location *al,
+                                          u64 period, bool sample_self)
 {
        struct rb_node **p;
        struct rb_node *parent = NULL;
@@ -362,20 +362,19 @@ out_unlock:
        return he;
 }
 
-struct hist_entry *__hists__add_branch_entry(struct hists *self,
-                                            struct addr_location *al,
-                                            struct symbol *sym_parent,
-                                            struct branch_info *bi,
-                                            u64 period)
+static struct hist_entry *add_hist_entry(struct hists *hists,
+                                        struct addr_location *al,
+                                        struct symbol *sym_parent,
+                                        u64 period, bool sample_self)
 {
        struct hist_entry entry = {
                .thread = al->thread,
                .ms = {
-                       .map    = bi->to.map,
-                       .sym    = bi->to.sym,
+                       .map    = al->map,
+                       .sym    = al->sym,
                },
                .cpu    = al->cpu,
-               .ip     = bi->to.addr,
+               .ip     = al->addr,
                .level  = al->level,
                .stat = {
                        .period = period,
@@ -383,24 +382,25 @@ struct hist_entry *__hists__add_branch_entry(struct hists 
*self,
                },
                .parent = sym_parent,
                .filtered = symbol__parent_filter(sym_parent),
-               .branch_info = bi,
        };
 
-       return add_hist_entry(self, &entry, al, period, true);
+       return __add_hist_entry(hists, &entry, al, period, sample_self);
 }
 
-struct hist_entry *__hists__add_entry(struct hists *self,
-                                     struct addr_location *al,
-                                     struct symbol *sym_parent, u64 period)
+struct hist_entry *__hists__add_branch_entry(struct hists *self,
+                                            struct addr_location *al,
+                                            struct symbol *sym_parent,
+                                            struct branch_info *bi,
+                                            u64 period)
 {
        struct hist_entry entry = {
                .thread = al->thread,
                .ms = {
-                       .map    = al->map,
-                       .sym    = al->sym,
+                       .map    = bi->to.map,
+                       .sym    = bi->to.sym,
                },
                .cpu    = al->cpu,
-               .ip     = al->addr,
+               .ip     = bi->to.addr,
                .level  = al->level,
                .stat = {
                        .period = period,
@@ -408,9 +408,17 @@ struct hist_entry *__hists__add_entry(struct hists *self,
                },
                .parent = sym_parent,
                .filtered = symbol__parent_filter(sym_parent),
+               .branch_info = bi,
        };
 
-       return add_hist_entry(self, &entry, al, period, true);
+       return __add_hist_entry(self, &entry, al, period, true);
+}
+
+struct hist_entry *__hists__add_entry(struct hists *self,
+                                     struct addr_location *al,
+                                     struct symbol *sym_parent, u64 period)
+{
+       return add_hist_entry(self, al, sym_parent, period, true);
 }
 
 int64_t
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to