aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/hist.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/hist.c')
-rw-r--r--tools/perf/util/hist.c49
1 files changed, 19 insertions, 30 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 822903eaa201..e4e6249b87d4 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1,4 +1,3 @@
1#include "annotate.h"
2#include "util.h" 1#include "util.h"
3#include "build-id.h" 2#include "build-id.h"
4#include "hist.h" 3#include "hist.h"
@@ -182,21 +181,21 @@ void hists__output_recalc_col_len(struct hists *hists, int max_rows)
182 } 181 }
183} 182}
184 183
185static void hist_entry__add_cpumode_period(struct hist_entry *he, 184static void he_stat__add_cpumode_period(struct he_stat *he_stat,
186 unsigned int cpumode, u64 period) 185 unsigned int cpumode, u64 period)
187{ 186{
188 switch (cpumode) { 187 switch (cpumode) {
189 case PERF_RECORD_MISC_KERNEL: 188 case PERF_RECORD_MISC_KERNEL:
190 he->stat.period_sys += period; 189 he_stat->period_sys += period;
191 break; 190 break;
192 case PERF_RECORD_MISC_USER: 191 case PERF_RECORD_MISC_USER:
193 he->stat.period_us += period; 192 he_stat->period_us += period;
194 break; 193 break;
195 case PERF_RECORD_MISC_GUEST_KERNEL: 194 case PERF_RECORD_MISC_GUEST_KERNEL:
196 he->stat.period_guest_sys += period; 195 he_stat->period_guest_sys += period;
197 break; 196 break;
198 case PERF_RECORD_MISC_GUEST_USER: 197 case PERF_RECORD_MISC_GUEST_USER:
199 he->stat.period_guest_us += period; 198 he_stat->period_guest_us += period;
200 break; 199 break;
201 default: 200 default:
202 break; 201 break;
@@ -223,10 +222,10 @@ static void he_stat__add_stat(struct he_stat *dest, struct he_stat *src)
223 dest->weight += src->weight; 222 dest->weight += src->weight;
224} 223}
225 224
226static void hist_entry__decay(struct hist_entry *he) 225static void he_stat__decay(struct he_stat *he_stat)
227{ 226{
228 he->stat.period = (he->stat.period * 7) / 8; 227 he_stat->period = (he_stat->period * 7) / 8;
229 he->stat.nr_events = (he->stat.nr_events * 7) / 8; 228 he_stat->nr_events = (he_stat->nr_events * 7) / 8;
230 /* XXX need decay for weight too? */ 229 /* XXX need decay for weight too? */
231} 230}
232 231
@@ -237,7 +236,7 @@ static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
237 if (prev_period == 0) 236 if (prev_period == 0)
238 return true; 237 return true;
239 238
240 hist_entry__decay(he); 239 he_stat__decay(&he->stat);
241 240
242 if (!he->filtered) 241 if (!he->filtered)
243 hists->stats.total_period -= prev_period - he->stat.period; 242 hists->stats.total_period -= prev_period - he->stat.period;
@@ -342,15 +341,15 @@ static u8 symbol__parent_filter(const struct symbol *parent)
342} 341}
343 342
344static struct hist_entry *add_hist_entry(struct hists *hists, 343static struct hist_entry *add_hist_entry(struct hists *hists,
345 struct hist_entry *entry, 344 struct hist_entry *entry,
346 struct addr_location *al, 345 struct addr_location *al)
347 u64 period,
348 u64 weight)
349{ 346{
350 struct rb_node **p; 347 struct rb_node **p;
351 struct rb_node *parent = NULL; 348 struct rb_node *parent = NULL;
352 struct hist_entry *he; 349 struct hist_entry *he;
353 int64_t cmp; 350 int64_t cmp;
351 u64 period = entry->stat.period;
352 u64 weight = entry->stat.weight;
354 353
355 p = &hists->entries_in->rb_node; 354 p = &hists->entries_in->rb_node;
356 355
@@ -373,7 +372,7 @@ static struct hist_entry *add_hist_entry(struct hists *hists,
373 * This mem info was allocated from machine__resolve_mem 372 * This mem info was allocated from machine__resolve_mem
374 * and will not be used anymore. 373 * and will not be used anymore.
375 */ 374 */
376 free(entry->mem_info); 375 zfree(&entry->mem_info);
377 376
378 /* If the map of an existing hist_entry has 377 /* If the map of an existing hist_entry has
379 * become out-of-date due to an exec() or 378 * become out-of-date due to an exec() or
@@ -403,7 +402,7 @@ static struct hist_entry *add_hist_entry(struct hists *hists,
403 rb_link_node(&he->rb_node_in, parent, p); 402 rb_link_node(&he->rb_node_in, parent, p);
404 rb_insert_color(&he->rb_node_in, hists->entries_in); 403 rb_insert_color(&he->rb_node_in, hists->entries_in);
405out: 404out:
406 hist_entry__add_cpumode_period(he, al->cpumode, period); 405 he_stat__add_cpumode_period(&he->stat, al->cpumode, period);
407 return he; 406 return he;
408} 407}
409 408
@@ -437,7 +436,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
437 .transaction = transaction, 436 .transaction = transaction,
438 }; 437 };
439 438
440 return add_hist_entry(hists, &entry, al, period, weight); 439 return add_hist_entry(hists, &entry, al);
441} 440}
442 441
443int64_t 442int64_t
@@ -476,8 +475,8 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
476 475
477void hist_entry__free(struct hist_entry *he) 476void hist_entry__free(struct hist_entry *he)
478{ 477{
479 free(he->branch_info); 478 zfree(&he->branch_info);
480 free(he->mem_info); 479 zfree(&he->mem_info);
481 free_srcline(he->srcline); 480 free_srcline(he->srcline);
482 free(he); 481 free(he);
483} 482}
@@ -807,16 +806,6 @@ void hists__filter_by_symbol(struct hists *hists)
807 } 806 }
808} 807}
809 808
810int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 ip)
811{
812 return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip);
813}
814
815int hist_entry__annotate(struct hist_entry *he, size_t privsize)
816{
817 return symbol__annotate(he->ms.sym, he->ms.map, privsize);
818}
819
820void events_stats__inc(struct events_stats *stats, u32 type) 809void events_stats__inc(struct events_stats *stats, u32 type)
821{ 810{
822 ++stats->nr_events[0]; 811 ++stats->nr_events[0];