Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf hists: Consolidate __hists__add_*entry()

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>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
41a4e6e2 87968f94

+30 -95
+1 -1
tools/perf/builtin-annotate.c
··· 65 65 return 0; 66 66 } 67 67 68 - he = __hists__add_entry(&evsel->hists, al, NULL, 1, 1, 0); 68 + he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, 1, 1, 0); 69 69 if (he == NULL) 70 70 return -ENOMEM; 71 71
+2 -1
tools/perf/builtin-diff.c
··· 307 307 struct addr_location *al, u64 period, 308 308 u64 weight, u64 transaction) 309 309 { 310 - if (__hists__add_entry(hists, al, NULL, period, weight, transaction) != NULL) 310 + if (__hists__add_entry(hists, al, NULL, NULL, NULL, period, weight, 311 + transaction) != NULL) 311 312 return 0; 312 313 return -ENOMEM; 313 314 }
+11 -5
tools/perf/builtin-report.c
··· 115 115 * and this is indirectly achieved by passing period=weight here 116 116 * and the he_stat__add_period() function. 117 117 */ 118 - he = __hists__add_mem_entry(&evsel->hists, al, parent, mi, cost, cost); 118 + he = __hists__add_entry(&evsel->hists, al, parent, NULL, mi, 119 + cost, cost, 0); 119 120 if (!he) 120 121 return -ENOMEM; 121 122 ··· 201 200 202 201 err = -ENOMEM; 203 202 203 + /* overwrite the 'al' to branch-to info */ 204 + al->map = bi[i].to.map; 205 + al->sym = bi[i].to.sym; 206 + al->addr = bi[i].to.addr; 204 207 /* 205 208 * The report shows the percentage of total branches captured 206 209 * and not events sampled. Thus we use a pseudo period of 1. 207 210 */ 208 - he = __hists__add_branch_entry(&evsel->hists, al, parent, 209 - &bi[i], 1, 1); 211 + he = __hists__add_entry(&evsel->hists, al, parent, &bi[i], NULL, 212 + 1, 1, 0); 210 213 if (he) { 211 214 struct annotation *notes; 212 215 bx = he->branch_info; ··· 271 266 return err; 272 267 } 273 268 274 - he = __hists__add_entry(&evsel->hists, al, parent, sample->period, 275 - sample->weight, sample->transaction); 269 + he = __hists__add_entry(&evsel->hists, al, parent, NULL, NULL, 270 + sample->period, sample->weight, 271 + sample->transaction); 276 272 if (he == NULL) 277 273 return -ENOMEM; 278 274
+3 -2
tools/perf/builtin-top.c
··· 246 246 struct hist_entry *he; 247 247 248 248 pthread_mutex_lock(&evsel->hists.lock); 249 - he = __hists__add_entry(&evsel->hists, al, NULL, sample->period, 250 - sample->weight, sample->transaction); 249 + he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, 250 + sample->period, sample->weight, 251 + sample->transaction); 251 252 pthread_mutex_unlock(&evsel->hists.lock); 252 253 if (he == NULL) 253 254 return NULL;
+3 -3
tools/perf/tests/hists_link.c
··· 223 223 goto out; 224 224 225 225 he = __hists__add_entry(&evsel->hists, &al, NULL, 226 - 1, 1, 0); 226 + NULL, NULL, 1, 1, 0); 227 227 if (he == NULL) 228 228 goto out; 229 229 ··· 245 245 &sample) < 0) 246 246 goto out; 247 247 248 - he = __hists__add_entry(&evsel->hists, &al, NULL, 1, 1, 249 - 0); 248 + he = __hists__add_entry(&evsel->hists, &al, NULL, 249 + NULL, NULL, 1, 1, 0); 250 250 if (he == NULL) 251 251 goto out; 252 252
+7 -68
tools/perf/util/hist.c
··· 407 407 return he; 408 408 } 409 409 410 - struct hist_entry *__hists__add_mem_entry(struct hists *hists, 411 - struct addr_location *al, 412 - struct symbol *sym_parent, 413 - struct mem_info *mi, 414 - u64 period, 415 - u64 weight) 416 - { 417 - struct hist_entry entry = { 418 - .thread = al->thread, 419 - .comm = thread__comm(al->thread), 420 - .ms = { 421 - .map = al->map, 422 - .sym = al->sym, 423 - }, 424 - .stat = { 425 - .period = period, 426 - .weight = weight, 427 - .nr_events = 1, 428 - }, 429 - .cpu = al->cpu, 430 - .ip = al->addr, 431 - .level = al->level, 432 - .parent = sym_parent, 433 - .filtered = symbol__parent_filter(sym_parent), 434 - .hists = hists, 435 - .mem_info = mi, 436 - .branch_info = NULL, 437 - }; 438 - return add_hist_entry(hists, &entry, al, period, weight); 439 - } 440 - 441 - struct hist_entry *__hists__add_branch_entry(struct hists *hists, 442 - struct addr_location *al, 443 - struct symbol *sym_parent, 444 - struct branch_info *bi, 445 - u64 period, 446 - u64 weight) 447 - { 448 - struct hist_entry entry = { 449 - .thread = al->thread, 450 - .comm = thread__comm(al->thread), 451 - .ms = { 452 - .map = bi->to.map, 453 - .sym = bi->to.sym, 454 - }, 455 - .cpu = al->cpu, 456 - .ip = bi->to.addr, 457 - .level = al->level, 458 - .stat = { 459 - .period = period, 460 - .nr_events = 1, 461 - .weight = weight, 462 - }, 463 - .parent = sym_parent, 464 - .filtered = symbol__parent_filter(sym_parent), 465 - .branch_info = bi, 466 - .hists = hists, 467 - .mem_info = NULL, 468 - }; 469 - 470 - return add_hist_entry(hists, &entry, al, period, weight); 471 - } 472 - 473 410 struct hist_entry *__hists__add_entry(struct hists *hists, 474 411 struct addr_location *al, 475 - struct symbol *sym_parent, u64 period, 476 - u64 weight, u64 transaction) 412 + struct symbol *sym_parent, 413 + struct branch_info *bi, 414 + struct mem_info *mi, 415 + u64 period, u64 weight, u64 transaction) 477 416 { 478 417 struct hist_entry entry = { 479 418 .thread = al->thread, ··· 425 486 .ip = al->addr, 426 487 .level = al->level, 427 488 .stat = { 428 - .period = period, 429 489 .nr_events = 1, 490 + .period = period, 430 491 .weight = weight, 431 492 }, 432 493 .parent = sym_parent, 433 494 .filtered = symbol__parent_filter(sym_parent), 434 495 .hists = hists, 435 - .branch_info = NULL, 436 - .mem_info = NULL, 496 + .branch_info = bi, 497 + .mem_info = mi, 437 498 .transaction = transaction, 438 499 }; 439 500
+3 -15
tools/perf/util/hist.h
··· 86 86 87 87 struct hist_entry *__hists__add_entry(struct hists *self, 88 88 struct addr_location *al, 89 - struct symbol *parent, u64 period, 89 + struct symbol *parent, 90 + struct branch_info *bi, 91 + struct mem_info *mi, u64 period, 90 92 u64 weight, u64 transaction); 91 93 int64_t hist_entry__cmp(struct hist_entry *left, struct hist_entry *right); 92 94 int64_t hist_entry__collapse(struct hist_entry *left, struct hist_entry *right); ··· 96 94 int hist_entry__sort_snprintf(struct hist_entry *self, char *bf, size_t size, 97 95 struct hists *hists); 98 96 void hist_entry__free(struct hist_entry *); 99 - 100 - struct hist_entry *__hists__add_branch_entry(struct hists *self, 101 - struct addr_location *al, 102 - struct symbol *sym_parent, 103 - struct branch_info *bi, 104 - u64 period, 105 - u64 weight); 106 - 107 - struct hist_entry *__hists__add_mem_entry(struct hists *self, 108 - struct addr_location *al, 109 - struct symbol *sym_parent, 110 - struct mem_info *mi, 111 - u64 period, 112 - u64 weight); 113 97 114 98 void hists__output_resort(struct hists *self); 115 99 void hists__collapse_resort(struct hists *self, struct ui_progress *prog);