aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2017-02-23 18:10:27 -0500
committerLen Brown <len.brown@intel.com>2017-03-01 00:14:26 -0500
commit5f3aea57773dc7f788e374994636ffc0234a355f (patch)
tree156d9a9144e8ffa4e227334b66d7fe902a35ba6c /tools
parent0815a3d09baf2cd330f75020bdaad0f1adac0ecb (diff)
tools/power turbostat: bugfix: --add u32 was printed as u64
When the "u32" keyword is used with --add, it means that the output should be truncated to 32-bits. This was not happening and all 64-bits were printed. Also, when no column name was used for an added MSR, The default column name was in deximal, eg. MSR16. Users report that they tend to use hex MSR numbers, so print them in hex. To always fit into the columns, use the syntax M0x10. Note that the user can always supply any column header that they want. eg --add msr0x10,MY_TSC Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/power/x86/turbostat/turbostat.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 2d758abecd56..5216549957f4 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -834,7 +834,7 @@ int format_counters(struct thread_data *t, struct core_data *c,
834 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { 834 for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) {
835 if (mp->format == FORMAT_RAW) { 835 if (mp->format == FORMAT_RAW) {
836 if (mp->width == 32) 836 if (mp->width == 32)
837 outp += sprintf(outp, "%s0x%08lx", (printed++ ? delim : ""), (unsigned long) t->counter[i]); 837 outp += sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int) t->counter[i]);
838 else 838 else
839 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), t->counter[i]); 839 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), t->counter[i]);
840 } else if (mp->format == FORMAT_DELTA) { 840 } else if (mp->format == FORMAT_DELTA) {
@@ -876,7 +876,7 @@ int format_counters(struct thread_data *t, struct core_data *c,
876 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { 876 for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) {
877 if (mp->format == FORMAT_RAW) { 877 if (mp->format == FORMAT_RAW) {
878 if (mp->width == 32) 878 if (mp->width == 32)
879 outp += sprintf(outp, "%s0x%08lx", (printed++ ? delim : ""), (unsigned long) c->counter[i]); 879 outp += sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int) c->counter[i]);
880 else 880 else
881 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), c->counter[i]); 881 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), c->counter[i]);
882 } else if (mp->format == FORMAT_DELTA) { 882 } else if (mp->format == FORMAT_DELTA) {
@@ -967,7 +967,7 @@ int format_counters(struct thread_data *t, struct core_data *c,
967 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { 967 for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) {
968 if (mp->format == FORMAT_RAW) { 968 if (mp->format == FORMAT_RAW) {
969 if (mp->width == 32) 969 if (mp->width == 32)
970 outp += sprintf(outp, "%s0x%08lx", (printed++ ? delim : ""), (unsigned long) p->counter[i]); 970 outp += sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int) p->counter[i]);
971 else 971 else
972 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), p->counter[i]); 972 outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), p->counter[i]);
973 } else if (mp->format == FORMAT_DELTA) { 973 } else if (mp->format == FORMAT_DELTA) {
@@ -4732,22 +4732,10 @@ next:
4732 4732
4733 /* generate default column header */ 4733 /* generate default column header */
4734 if (*name_buffer == '\0') { 4734 if (*name_buffer == '\0') {
4735 if (format == FORMAT_RAW) { 4735 if (width == 32)
4736 if (width == 32) 4736 sprintf(name_buffer, "M0x%x%s", msr_num, format == FORMAT_PERCENT ? "%" : "");
4737 sprintf(name_buffer, "msr%d", msr_num); 4737 else
4738 else 4738 sprintf(name_buffer, "M0X%x%s", msr_num, format == FORMAT_PERCENT ? "%" : "");
4739 sprintf(name_buffer, "MSR%d", msr_num);
4740 } else if (format == FORMAT_DELTA) {
4741 if (width == 32)
4742 sprintf(name_buffer, "cnt%d", msr_num);
4743 else
4744 sprintf(name_buffer, "CNT%d", msr_num);
4745 } else if (format == FORMAT_PERCENT) {
4746 if (width == 32)
4747 sprintf(name_buffer, "msr%d%%", msr_num);
4748 else
4749 sprintf(name_buffer, "MSR%d%%", msr_num);
4750 }
4751 } 4739 }
4752 4740
4753 if (add_counter(msr_num, path, name_buffer, width, scope, type, format, 0)) 4741 if (add_counter(msr_num, path, name_buffer, width, scope, type, format, 0))