aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/hist.c
diff options
context:
space:
mode:
authorZhang, Yanmin <yanmin_zhang@linux.intel.com>2010-04-19 01:32:50 -0400
committerAvi Kivity <avi@redhat.com>2010-04-19 05:37:24 -0400
commita1645ce12adb6c9cc9e19d7695466204e3f017fe (patch)
tree5d31aaaf534997e6e9cebc07f38eca35f76986cf /tools/perf/util/hist.c
parentff9d07a0e7ce756a183e7c2e483aec452ee6b574 (diff)
perf: 'perf kvm' tool for monitoring guest performance from host
Here is the patch of userspace perf tool. Signed-off-by: Zhang Yanmin <yanmin_zhang@linux.intel.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'tools/perf/util/hist.c')
-rw-r--r--tools/perf/util/hist.c72
1 files changed, 71 insertions, 1 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 9c2b8743cef6..ad6b22dde27f 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -8,6 +8,30 @@ struct callchain_param callchain_param = {
8 .min_percent = 0.5 8 .min_percent = 0.5
9}; 9};
10 10
11void __perf_session__add_count(struct hist_entry *he,
12 struct addr_location *al,
13 u64 count)
14{
15 he->count += count;
16
17 switch (al->cpumode) {
18 case PERF_RECORD_MISC_KERNEL:
19 he->count_sys += count;
20 break;
21 case PERF_RECORD_MISC_USER:
22 he->count_us += count;
23 break;
24 case PERF_RECORD_MISC_GUEST_KERNEL:
25 he->count_guest_sys += count;
26 break;
27 case PERF_RECORD_MISC_GUEST_USER:
28 he->count_guest_us += count;
29 break;
30 default:
31 break;
32 }
33}
34
11/* 35/*
12 * histogram, sorted on item, collects counts 36 * histogram, sorted on item, collects counts
13 */ 37 */
@@ -464,7 +488,7 @@ int hist_entry__snprintf(struct hist_entry *self,
464 u64 session_total) 488 u64 session_total)
465{ 489{
466 struct sort_entry *se; 490 struct sort_entry *se;
467 u64 count, total; 491 u64 count, total, count_sys, count_us, count_guest_sys, count_guest_us;
468 const char *sep = symbol_conf.field_sep; 492 const char *sep = symbol_conf.field_sep;
469 int ret; 493 int ret;
470 494
@@ -474,9 +498,17 @@ int hist_entry__snprintf(struct hist_entry *self,
474 if (pair_session) { 498 if (pair_session) {
475 count = self->pair ? self->pair->count : 0; 499 count = self->pair ? self->pair->count : 0;
476 total = pair_session->events_stats.total; 500 total = pair_session->events_stats.total;
501 count_sys = self->pair ? self->pair->count_sys : 0;
502 count_us = self->pair ? self->pair->count_us : 0;
503 count_guest_sys = self->pair ? self->pair->count_guest_sys : 0;
504 count_guest_us = self->pair ? self->pair->count_guest_us : 0;
477 } else { 505 } else {
478 count = self->count; 506 count = self->count;
479 total = session_total; 507 total = session_total;
508 count_sys = self->count_sys;
509 count_us = self->count_us;
510 count_guest_sys = self->count_guest_sys;
511 count_guest_us = self->count_guest_us;
480 } 512 }
481 513
482 if (total) { 514 if (total) {
@@ -487,6 +519,26 @@ int hist_entry__snprintf(struct hist_entry *self,
487 else 519 else
488 ret = snprintf(s, size, sep ? "%.2f" : " %6.2f%%", 520 ret = snprintf(s, size, sep ? "%.2f" : " %6.2f%%",
489 (count * 100.0) / total); 521 (count * 100.0) / total);
522 if (symbol_conf.show_cpu_utilization) {
523 ret += percent_color_snprintf(s + ret, size - ret,
524 sep ? "%.2f" : " %6.2f%%",
525 (count_sys * 100.0) / total);
526 ret += percent_color_snprintf(s + ret, size - ret,
527 sep ? "%.2f" : " %6.2f%%",
528 (count_us * 100.0) / total);
529 if (perf_guest) {
530 ret += percent_color_snprintf(s + ret,
531 size - ret,
532 sep ? "%.2f" : " %6.2f%%",
533 (count_guest_sys * 100.0) /
534 total);
535 ret += percent_color_snprintf(s + ret,
536 size - ret,
537 sep ? "%.2f" : " %6.2f%%",
538 (count_guest_us * 100.0) /
539 total);
540 }
541 }
490 } else 542 } else
491 ret = snprintf(s, size, sep ? "%lld" : "%12lld ", count); 543 ret = snprintf(s, size, sep ? "%lld" : "%12lld ", count);
492 544
@@ -597,6 +649,24 @@ size_t perf_session__fprintf_hists(struct rb_root *hists,
597 fputs(" Samples ", fp); 649 fputs(" Samples ", fp);
598 } 650 }
599 651
652 if (symbol_conf.show_cpu_utilization) {
653 if (sep) {
654 ret += fprintf(fp, "%csys", *sep);
655 ret += fprintf(fp, "%cus", *sep);
656 if (perf_guest) {
657 ret += fprintf(fp, "%cguest sys", *sep);
658 ret += fprintf(fp, "%cguest us", *sep);
659 }
660 } else {
661 ret += fprintf(fp, " sys ");
662 ret += fprintf(fp, " us ");
663 if (perf_guest) {
664 ret += fprintf(fp, " guest sys ");
665 ret += fprintf(fp, " guest us ");
666 }
667 }
668 }
669
600 if (pair) { 670 if (pair) {
601 if (sep) 671 if (sep)
602 ret += fprintf(fp, "%cDelta", *sep); 672 ret += fprintf(fp, "%cDelta", *sep);