diff options
-rw-r--r-- | tools/power/x86/turbostat/turbostat.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 6867557596af..bbdf9ba9d41b 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c | |||
@@ -680,7 +680,7 @@ int dump_counters(struct thread_data *t, struct core_data *c, | |||
680 | int format_counters(struct thread_data *t, struct core_data *c, | 680 | int format_counters(struct thread_data *t, struct core_data *c, |
681 | struct pkg_data *p) | 681 | struct pkg_data *p) |
682 | { | 682 | { |
683 | double interval_float; | 683 | double interval_float, tsc; |
684 | char *fmt8; | 684 | char *fmt8; |
685 | int i; | 685 | int i; |
686 | struct msr_counter *mp; | 686 | struct msr_counter *mp; |
@@ -695,6 +695,8 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
695 | 695 | ||
696 | interval_float = tv_delta.tv_sec + tv_delta.tv_usec/1000000.0; | 696 | interval_float = tv_delta.tv_sec + tv_delta.tv_usec/1000000.0; |
697 | 697 | ||
698 | tsc = t->tsc * tsc_tweak; | ||
699 | |||
698 | /* topo columns, print blanks on 1st (average) line */ | 700 | /* topo columns, print blanks on 1st (average) line */ |
699 | if (t == &average.threads) { | 701 | if (t == &average.threads) { |
700 | if (DO_BIC(BIC_Package)) | 702 | if (DO_BIC(BIC_Package)) |
@@ -725,14 +727,14 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
725 | 1.0 / units * t->aperf / interval_float); | 727 | 1.0 / units * t->aperf / interval_float); |
726 | 728 | ||
727 | if (DO_BIC(BIC_Busy)) | 729 | if (DO_BIC(BIC_Busy)) |
728 | outp += sprintf(outp, "\t%.2f", 100.0 * t->mperf/t->tsc/tsc_tweak); | 730 | outp += sprintf(outp, "\t%.2f", 100.0 * t->mperf/tsc); |
729 | 731 | ||
730 | if (DO_BIC(BIC_Bzy_MHz)) { | 732 | if (DO_BIC(BIC_Bzy_MHz)) { |
731 | if (has_base_hz) | 733 | if (has_base_hz) |
732 | outp += sprintf(outp, "\t%.0f", base_hz / units * t->aperf / t->mperf); | 734 | outp += sprintf(outp, "\t%.0f", base_hz / units * t->aperf / t->mperf); |
733 | else | 735 | else |
734 | outp += sprintf(outp, "\t%.0f", | 736 | outp += sprintf(outp, "\t%.0f", |
735 | 1.0 * t->tsc / units * t->aperf / t->mperf / interval_float); | 737 | tsc / units * t->aperf / t->mperf / interval_float); |
736 | } | 738 | } |
737 | 739 | ||
738 | if (DO_BIC(BIC_TSC_MHz)) | 740 | if (DO_BIC(BIC_TSC_MHz)) |
@@ -748,7 +750,7 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
748 | 750 | ||
749 | /* C1 */ | 751 | /* C1 */ |
750 | if (DO_BIC(BIC_CPU_c1)) | 752 | if (DO_BIC(BIC_CPU_c1)) |
751 | outp += sprintf(outp, "\t%.2f", 100.0 * t->c1/t->tsc); | 753 | outp += sprintf(outp, "\t%.2f", 100.0 * t->c1/tsc); |
752 | 754 | ||
753 | /* Added counters */ | 755 | /* Added counters */ |
754 | for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { | 756 | for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { |
@@ -760,7 +762,7 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
760 | } else if (mp->format == FORMAT_DELTA) { | 762 | } else if (mp->format == FORMAT_DELTA) { |
761 | outp += sprintf(outp, "\t%lld", t->counter[i]); | 763 | outp += sprintf(outp, "\t%lld", t->counter[i]); |
762 | } else if (mp->format == FORMAT_PERCENT) { | 764 | } else if (mp->format == FORMAT_PERCENT) { |
763 | outp += sprintf(outp, "\t%.2f", 100.0 * t->counter[i]/t->tsc); | 765 | outp += sprintf(outp, "\t%.2f", 100.0 * t->counter[i]/tsc); |
764 | } | 766 | } |
765 | } | 767 | } |
766 | 768 | ||
@@ -769,15 +771,15 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
769 | goto done; | 771 | goto done; |
770 | 772 | ||
771 | if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates) | 773 | if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates) |
772 | outp += sprintf(outp, "\t%.2f", 100.0 * c->c3/t->tsc); | 774 | outp += sprintf(outp, "\t%.2f", 100.0 * c->c3/tsc); |
773 | if (DO_BIC(BIC_CPU_c6)) | 775 | if (DO_BIC(BIC_CPU_c6)) |
774 | outp += sprintf(outp, "\t%.2f", 100.0 * c->c6/t->tsc); | 776 | outp += sprintf(outp, "\t%.2f", 100.0 * c->c6/tsc); |
775 | if (DO_BIC(BIC_CPU_c7)) | 777 | if (DO_BIC(BIC_CPU_c7)) |
776 | outp += sprintf(outp, "\t%.2f", 100.0 * c->c7/t->tsc); | 778 | outp += sprintf(outp, "\t%.2f", 100.0 * c->c7/tsc); |
777 | 779 | ||
778 | /* Mod%c6 */ | 780 | /* Mod%c6 */ |
779 | if (DO_BIC(BIC_Mod_c6)) | 781 | if (DO_BIC(BIC_Mod_c6)) |
780 | outp += sprintf(outp, "\t%.2f", 100.0 * c->mc6_us / t->tsc); | 782 | outp += sprintf(outp, "\t%.2f", 100.0 * c->mc6_us / tsc); |
781 | 783 | ||
782 | if (DO_BIC(BIC_CoreTmp)) | 784 | if (DO_BIC(BIC_CoreTmp)) |
783 | outp += sprintf(outp, "\t%d", c->core_temp_c); | 785 | outp += sprintf(outp, "\t%d", c->core_temp_c); |
@@ -791,7 +793,7 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
791 | } else if (mp->format == FORMAT_DELTA) { | 793 | } else if (mp->format == FORMAT_DELTA) { |
792 | outp += sprintf(outp, "\t%lld", c->counter[i]); | 794 | outp += sprintf(outp, "\t%lld", c->counter[i]); |
793 | } else if (mp->format == FORMAT_PERCENT) { | 795 | } else if (mp->format == FORMAT_PERCENT) { |
794 | outp += sprintf(outp, "\t%.2f", 100.0 * c->counter[i]/t->tsc); | 796 | outp += sprintf(outp, "\t%.2f", 100.0 * c->counter[i]/tsc); |
795 | } | 797 | } |
796 | } | 798 | } |
797 | 799 | ||
@@ -819,24 +821,24 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
819 | 821 | ||
820 | /* Totl%C0, Any%C0 GFX%C0 CPUGFX% */ | 822 | /* Totl%C0, Any%C0 GFX%C0 CPUGFX% */ |
821 | if (do_skl_residency) { | 823 | if (do_skl_residency) { |
822 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pkg_wtd_core_c0/t->tsc); | 824 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pkg_wtd_core_c0/tsc); |
823 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pkg_any_core_c0/t->tsc); | 825 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pkg_any_core_c0/tsc); |
824 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pkg_any_gfxe_c0/t->tsc); | 826 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pkg_any_gfxe_c0/tsc); |
825 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pkg_both_core_gfxe_c0/t->tsc); | 827 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pkg_both_core_gfxe_c0/tsc); |
826 | } | 828 | } |
827 | 829 | ||
828 | if (do_pc2) | 830 | if (do_pc2) |
829 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc2/t->tsc); | 831 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc2/tsc); |
830 | if (do_pc3) | 832 | if (do_pc3) |
831 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc3/t->tsc); | 833 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc3/tsc); |
832 | if (do_pc6) | 834 | if (do_pc6) |
833 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc6/t->tsc); | 835 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc6/tsc); |
834 | if (do_pc7) | 836 | if (do_pc7) |
835 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc7/t->tsc); | 837 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc7/tsc); |
836 | if (do_c8_c9_c10) { | 838 | if (do_c8_c9_c10) { |
837 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc8/t->tsc); | 839 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc8/tsc); |
838 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc9/t->tsc); | 840 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc9/tsc); |
839 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc10/t->tsc); | 841 | outp += sprintf(outp, "\t%.2f", 100.0 * p->pc10/tsc); |
840 | } | 842 | } |
841 | 843 | ||
842 | /* | 844 | /* |
@@ -878,7 +880,7 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
878 | } else if (mp->format == FORMAT_DELTA) { | 880 | } else if (mp->format == FORMAT_DELTA) { |
879 | outp += sprintf(outp, "\t%lld", p->counter[i]); | 881 | outp += sprintf(outp, "\t%lld", p->counter[i]); |
880 | } else if (mp->format == FORMAT_PERCENT) { | 882 | } else if (mp->format == FORMAT_PERCENT) { |
881 | outp += sprintf(outp, "\t%.2f", 100.0 * p->counter[i]/t->tsc); | 883 | outp += sprintf(outp, "\t%.2f", 100.0 * p->counter[i]/tsc); |
882 | } | 884 | } |
883 | } | 885 | } |
884 | 886 | ||
@@ -1048,7 +1050,7 @@ delta_thread(struct thread_data *new, struct thread_data *old, | |||
1048 | old->c1 = 0; | 1050 | old->c1 = 0; |
1049 | else { | 1051 | else { |
1050 | /* normal case, derive c1 */ | 1052 | /* normal case, derive c1 */ |
1051 | old->c1 = old->tsc - old->mperf - core_delta->c3 | 1053 | old->c1 = (old->tsc * tsc_tweak) - old->mperf - core_delta->c3 |
1052 | - core_delta->c6 - core_delta->c7; | 1054 | - core_delta->c6 - core_delta->c7; |
1053 | } | 1055 | } |
1054 | } | 1056 | } |