diff options
author | Len Brown <len.brown@intel.com> | 2017-05-28 00:06:55 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2017-06-23 23:52:23 -0400 |
commit | f4fdf2b474606580b95eed95d06c762d4fd3f57b (patch) | |
tree | cb1473158388d580a32e0591faa9132fd22fe7a0 /tools | |
parent | a99d87306f83d2a97c8c7e854b6583c4037ecf75 (diff) |
tools/power turbostat: if --debug, print sampling overhead
The --debug option now pre-pends each row with
the number of micro-seconds [usec] to collect
the finishing snapshot for that row.
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/power/x86/turbostat/turbostat.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 2b25727bd3d7..6f7c64acee23 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c | |||
@@ -150,6 +150,8 @@ size_t cpu_present_setsize, cpu_affinity_setsize, cpu_subset_size; | |||
150 | #define MAX_ADDED_COUNTERS 16 | 150 | #define MAX_ADDED_COUNTERS 16 |
151 | 151 | ||
152 | struct thread_data { | 152 | struct thread_data { |
153 | struct timeval tv_begin; | ||
154 | struct timeval tv_end; | ||
153 | unsigned long long tsc; | 155 | unsigned long long tsc; |
154 | unsigned long long aperf; | 156 | unsigned long long aperf; |
155 | unsigned long long mperf; | 157 | unsigned long long mperf; |
@@ -530,6 +532,8 @@ void print_header(char *delim) | |||
530 | struct msr_counter *mp; | 532 | struct msr_counter *mp; |
531 | int printed = 0; | 533 | int printed = 0; |
532 | 534 | ||
535 | if (debug) | ||
536 | outp += sprintf(outp, "usec %s", delim); | ||
533 | if (DO_BIC(BIC_Package)) | 537 | if (DO_BIC(BIC_Package)) |
534 | outp += sprintf(outp, "%sPackage", (printed++ ? delim : "")); | 538 | outp += sprintf(outp, "%sPackage", (printed++ ? delim : "")); |
535 | if (DO_BIC(BIC_Core)) | 539 | if (DO_BIC(BIC_Core)) |
@@ -782,6 +786,14 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
782 | (cpu_subset && !CPU_ISSET_S(t->cpu_id, cpu_subset_size, cpu_subset))) | 786 | (cpu_subset && !CPU_ISSET_S(t->cpu_id, cpu_subset_size, cpu_subset))) |
783 | return 0; | 787 | return 0; |
784 | 788 | ||
789 | if (debug) { | ||
790 | /* on each row, print how many usec each timestamp took to gather */ | ||
791 | struct timeval tv; | ||
792 | |||
793 | timersub(&t->tv_end, &t->tv_begin, &tv); | ||
794 | outp += sprintf(outp, "%5ld\t", tv.tv_sec * 1000000 + tv.tv_usec); | ||
795 | } | ||
796 | |||
785 | interval_float = tv_delta.tv_sec + tv_delta.tv_usec/1000000.0; | 797 | interval_float = tv_delta.tv_sec + tv_delta.tv_usec/1000000.0; |
786 | 798 | ||
787 | tsc = t->tsc * tsc_tweak; | 799 | tsc = t->tsc * tsc_tweak; |
@@ -1503,6 +1515,9 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |||
1503 | struct msr_counter *mp; | 1515 | struct msr_counter *mp; |
1504 | int i; | 1516 | int i; |
1505 | 1517 | ||
1518 | |||
1519 | gettimeofday(&t->tv_begin, (struct timezone *)NULL); | ||
1520 | |||
1506 | if (cpu_migrate(cpu)) { | 1521 | if (cpu_migrate(cpu)) { |
1507 | fprintf(outf, "Could not migrate to CPU %d\n", cpu); | 1522 | fprintf(outf, "Could not migrate to CPU %d\n", cpu); |
1508 | return -1; | 1523 | return -1; |
@@ -1586,7 +1601,7 @@ retry: | |||
1586 | 1601 | ||
1587 | /* collect core counters only for 1st thread in core */ | 1602 | /* collect core counters only for 1st thread in core */ |
1588 | if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) | 1603 | if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) |
1589 | return 0; | 1604 | goto done; |
1590 | 1605 | ||
1591 | if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates) { | 1606 | if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates) { |
1592 | if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3)) | 1607 | if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3)) |
@@ -1622,7 +1637,7 @@ retry: | |||
1622 | 1637 | ||
1623 | /* collect package counters only for 1st core in package */ | 1638 | /* collect package counters only for 1st core in package */ |
1624 | if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) | 1639 | if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) |
1625 | return 0; | 1640 | goto done; |
1626 | 1641 | ||
1627 | if (DO_BIC(BIC_Totl_c0)) { | 1642 | if (DO_BIC(BIC_Totl_c0)) { |
1628 | if (get_msr(cpu, MSR_PKG_WEIGHTED_CORE_C0_RES, &p->pkg_wtd_core_c0)) | 1643 | if (get_msr(cpu, MSR_PKG_WEIGHTED_CORE_C0_RES, &p->pkg_wtd_core_c0)) |
@@ -1715,6 +1730,8 @@ retry: | |||
1715 | if (get_mp(cpu, mp, &p->counter[i])) | 1730 | if (get_mp(cpu, mp, &p->counter[i])) |
1716 | return -10; | 1731 | return -10; |
1717 | } | 1732 | } |
1733 | done: | ||
1734 | gettimeofday(&t->tv_end, (struct timezone *)NULL); | ||
1718 | 1735 | ||
1719 | return 0; | 1736 | return 0; |
1720 | } | 1737 | } |