]> Pileus Git - ~andy/linux/commitdiff
perf hists: Consolidate __hists__add_*entry()
authorNamhyung Kim <namhyung.kim@lge.com>
Thu, 31 Oct 2013 06:56:03 +0000 (15:56 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 4 Nov 2013 23:59:09 +0000 (20:59 -0300)
The __hists__add_{branch,mem}_entry() does almost the same thing that
__hists__add_entry() does.  Consolidate them into one.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Rodrigo Campos <rodrigo@sdfg.com.ar>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1383202576-28141-2-git-send-email-namhyung@kernel.org
[ Fixup clash with new COMM infrastructure ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-annotate.c
tools/perf/builtin-diff.c
tools/perf/builtin-report.c
tools/perf/builtin-top.c
tools/perf/tests/hists_link.c
tools/perf/util/hist.c
tools/perf/util/hist.h

index 6c5ae57831f6e15ea919b91d7f88e0405a825ef3..4087ab19823c2f843c50e18d7b8e5042a079032f 100644 (file)
@@ -65,7 +65,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
                return 0;
        }
 
-       he = __hists__add_entry(&evsel->hists, al, NULL, 1, 1, 0);
+       he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, 1, 1, 0);
        if (he == NULL)
                return -ENOMEM;
 
index b605009e803f0bf5845f96d7bca6390fdefdfc2a..3b67ea2444bd4abf8314ef5c40c7d4b3e731c455 100644 (file)
@@ -307,7 +307,8 @@ static int hists__add_entry(struct hists *hists,
                            struct addr_location *al, u64 period,
                            u64 weight, u64 transaction)
 {
-       if (__hists__add_entry(hists, al, NULL, period, weight, transaction) != NULL)
+       if (__hists__add_entry(hists, al, NULL, NULL, NULL, period, weight,
+                              transaction) != NULL)
                return 0;
        return -ENOMEM;
 }
index 25f83d5d66fdfdc6b0c404c871a431662833953a..8cf8e66ba594156fc85a1ddca5b0b0305544ae23 100644 (file)
@@ -115,7 +115,8 @@ static int perf_report__add_mem_hist_entry(struct perf_tool *tool,
         * and this is indirectly achieved by passing period=weight here
         * and the he_stat__add_period() function.
         */
-       he = __hists__add_mem_entry(&evsel->hists, al, parent, mi, cost, cost);
+       he = __hists__add_entry(&evsel->hists, al, parent, NULL, mi,
+                               cost, cost, 0);
        if (!he)
                return -ENOMEM;
 
@@ -200,12 +201,16 @@ static int perf_report__add_branch_hist_entry(struct perf_tool *tool,
 
                err = -ENOMEM;
 
+               /* overwrite the 'al' to branch-to info */
+               al->map = bi[i].to.map;
+               al->sym = bi[i].to.sym;
+               al->addr = bi[i].to.addr;
                /*
                 * The report shows the percentage of total branches captured
                 * and not events sampled. Thus we use a pseudo period of 1.
                 */
-               he = __hists__add_branch_entry(&evsel->hists, al, parent,
-                               &bi[i], 1, 1);
+               he = __hists__add_entry(&evsel->hists, al, parent, &bi[i], NULL,
+                                       1, 1, 0);
                if (he) {
                        struct annotation *notes;
                        bx = he->branch_info;
@@ -266,8 +271,9 @@ static int perf_evsel__add_hist_entry(struct perf_tool *tool,
                        return err;
        }
 
-       he = __hists__add_entry(&evsel->hists, al, parent, sample->period,
-                               sample->weight, sample->transaction);
+       he = __hists__add_entry(&evsel->hists, al, parent, NULL, NULL,
+                               sample->period, sample->weight,
+                               sample->transaction);
        if (he == NULL)
                return -ENOMEM;
 
index ca5ca37980fb42e2f5e0b09f9501ff26ad80c596..21897f0ffcd377506e6579b1d0bea21d45be40cc 100644 (file)
@@ -246,8 +246,9 @@ static struct hist_entry *perf_evsel__add_hist_entry(struct perf_evsel *evsel,
        struct hist_entry *he;
 
        pthread_mutex_lock(&evsel->hists.lock);
-       he = __hists__add_entry(&evsel->hists, al, NULL, sample->period,
-                               sample->weight, sample->transaction);
+       he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL,
+                               sample->period, sample->weight,
+                               sample->transaction);
        pthread_mutex_unlock(&evsel->hists.lock);
        if (he == NULL)
                return NULL;
index 6c337e6535408981ad2d6a12aa5f94623765b387..173bf42cc03e73e8291e4a6a7cf99f5d8d6d3107 100644 (file)
@@ -223,7 +223,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
                                goto out;
 
                        he = __hists__add_entry(&evsel->hists, &al, NULL,
-                                               1, 1, 0);
+                                               NULL, NULL, 1, 1, 0);
                        if (he == NULL)
                                goto out;
 
@@ -245,8 +245,8 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
                                                          &sample) < 0)
                                goto out;
 
-                       he = __hists__add_entry(&evsel->hists, &al, NULL, 1, 1,
-                                               0);
+                       he = __hists__add_entry(&evsel->hists, &al, NULL,
+                                               NULL, NULL, 1, 1, 0);
                        if (he == NULL)
                                goto out;
 
index 30793f98c8bb4e47d98f0cb697a35d999bfb4f22..822903eaa201f3ec81648206eaf3c2f3ae2710c0 100644 (file)
@@ -407,73 +407,12 @@ out:
        return he;
 }
 
-struct hist_entry *__hists__add_mem_entry(struct hists *hists,
-                                         struct addr_location *al,
-                                         struct symbol *sym_parent,
-                                         struct mem_info *mi,
-                                         u64 period,
-                                         u64 weight)
-{
-       struct hist_entry entry = {
-               .thread = al->thread,
-               .comm = thread__comm(al->thread),
-               .ms = {
-                       .map    = al->map,
-                       .sym    = al->sym,
-               },
-               .stat = {
-                       .period = period,
-                       .weight = weight,
-                       .nr_events = 1,
-               },
-               .cpu    = al->cpu,
-               .ip     = al->addr,
-               .level  = al->level,
-               .parent = sym_parent,
-               .filtered = symbol__parent_filter(sym_parent),
-               .hists = hists,
-               .mem_info = mi,
-               .branch_info = NULL,
-       };
-       return add_hist_entry(hists, &entry, al, period, weight);
-}
-
-struct hist_entry *__hists__add_branch_entry(struct hists *hists,
-                                            struct addr_location *al,
-                                            struct symbol *sym_parent,
-                                            struct branch_info *bi,
-                                            u64 period,
-                                            u64 weight)
-{
-       struct hist_entry entry = {
-               .thread = al->thread,
-               .comm = thread__comm(al->thread),
-               .ms = {
-                       .map    = bi->to.map,
-                       .sym    = bi->to.sym,
-               },
-               .cpu    = al->cpu,
-               .ip     = bi->to.addr,
-               .level  = al->level,
-               .stat = {
-                       .period = period,
-                       .nr_events = 1,
-                       .weight = weight,
-               },
-               .parent = sym_parent,
-               .filtered = symbol__parent_filter(sym_parent),
-               .branch_info = bi,
-               .hists  = hists,
-               .mem_info = NULL,
-       };
-
-       return add_hist_entry(hists, &entry, al, period, weight);
-}
-
 struct hist_entry *__hists__add_entry(struct hists *hists,
                                      struct addr_location *al,
-                                     struct symbol *sym_parent, u64 period,
-                                     u64 weight, u64 transaction)
+                                     struct symbol *sym_parent,
+                                     struct branch_info *bi,
+                                     struct mem_info *mi,
+                                     u64 period, u64 weight, u64 transaction)
 {
        struct hist_entry entry = {
                .thread = al->thread,
@@ -486,15 +425,15 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
                .ip     = al->addr,
                .level  = al->level,
                .stat = {
-                       .period = period,
                        .nr_events = 1,
+                       .period = period,
                        .weight = weight,
                },
                .parent = sym_parent,
                .filtered = symbol__parent_filter(sym_parent),
                .hists  = hists,
-               .branch_info = NULL,
-               .mem_info = NULL,
+               .branch_info = bi,
+               .mem_info = mi,
                .transaction = transaction,
        };
 
index 9d2d022cdb79f205f39678fe0a0397578e4f3a5c..307f1c7425633bd5894072ad0507920e2094ced2 100644 (file)
@@ -86,7 +86,9 @@ struct hists {
 
 struct hist_entry *__hists__add_entry(struct hists *self,
                                      struct addr_location *al,
-                                     struct symbol *parent, u64 period,
+                                     struct symbol *parent,
+                                     struct branch_info *bi,
+                                     struct mem_info *mi, u64 period,
                                      u64 weight, u64 transaction);
 int64_t hist_entry__cmp(struct hist_entry *left, struct hist_entry *right);
 int64_t hist_entry__collapse(struct hist_entry *left, struct hist_entry *right);
@@ -95,20 +97,6 @@ int hist_entry__sort_snprintf(struct hist_entry *self, char *bf, size_t size,
                              struct hists *hists);
 void hist_entry__free(struct hist_entry *);
 
-struct hist_entry *__hists__add_branch_entry(struct hists *self,
-                                            struct addr_location *al,
-                                            struct symbol *sym_parent,
-                                            struct branch_info *bi,
-                                            u64 period,
-                                            u64 weight);
-
-struct hist_entry *__hists__add_mem_entry(struct hists *self,
-                                         struct addr_location *al,
-                                         struct symbol *sym_parent,
-                                         struct mem_info *mi,
-                                         u64 period,
-                                         u64 weight);
-
 void hists__output_resort(struct hists *self);
 void hists__collapse_resort(struct hists *self, struct ui_progress *prog);