perf hists: Update hists' total period when adding entries
authorNamhyung Kim <[email protected]>
Wed, 27 Jan 2016 15:40:49 +0000 (00:40 +0900)
committerArnaldo Carvalho de Melo <[email protected]>
Mon, 1 Feb 2016 19:45:44 +0000 (16:45 -0300)
Currently the hist entry addition path doesn't update total_period of
hists and it's calculated during 'resort' path.  But the resort path
needs to know the total period before doing its job because it's used
for calculating percent limit of callchains in hist entries.

So this patch update the total period during the addition path.  It
makes the percent limit of callchains working (again).

Signed-off-by: Namhyung Kim <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Wang Nan <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/util/hist.c

index b96194676c91502a7749b20e15bfbd7225fd5a8e..098310bc44893c16a8dcea649c0560a40d099d5e 100644 (file)
@@ -432,8 +432,12 @@ static struct hist_entry *hists__findnew_entry(struct hists *hists,
                cmp = hist_entry__cmp(he, entry);
 
                if (!cmp) {
-                       if (sample_self)
+                       if (sample_self) {
                                he_stat__add_period(&he->stat, period, weight);
+                               hists->stats.total_period += period;
+                               if (!he->filtered)
+                                       hists->stats.total_non_filtered_period += period;
+                       }
                        if (symbol_conf.cumulate_callchain)
                                he_stat__add_period(he->stat_acc, period, weight);
 
@@ -466,7 +470,10 @@ static struct hist_entry *hists__findnew_entry(struct hists *hists,
        if (!he)
                return NULL;
 
-       hists->nr_entries++;
+       if (sample_self)
+               hists__inc_stats(hists, he);
+       else
+               hists->nr_entries++;
 
        rb_link_node(&he->rb_node_in, parent, p);
        rb_insert_color(&he->rb_node_in, hists->entries_in);