From patchwork Wed Mar 1 05:27:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Len Brown X-Patchwork-Id: 9598031 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 12BA560453 for ; Wed, 1 Mar 2017 10:13:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 073FF2853C for ; Wed, 1 Mar 2017 10:13:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F058D28541; Wed, 1 Mar 2017 10:13:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 680732853C for ; Wed, 1 Mar 2017 10:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751529AbdCAKNI (ORCPT ); Wed, 1 Mar 2017 05:13:08 -0500 Received: from mail-qk0-f193.google.com ([209.85.220.193]:35640 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751880AbdCAKNH (ORCPT ); Wed, 1 Mar 2017 05:13:07 -0500 Received: by mail-qk0-f193.google.com with SMTP id n127so9349861qkf.2 for ; Wed, 01 Mar 2017 02:11:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references:reply-to:organization; bh=9LiPiPWO5IKWXJUalLCQLcN6j67kZg0zYfFLWsnPZ1E=; b=chGT88qAe8GLgIOv3jrGMiolzj3e7eL2yI463VpLA4eCEesFyXS//cBUeajhPj2ouR XuWaxhyD9bMeh0dyXRcBh/yvV382Re7MSNnANNSWQd2dNlhYvFcEFp5Ne1Yy6Ns3u9+9 z8hC7PWA8JPlFR5M/W4GgQjrpygiL4rx0u+Ve+AAsE3XyuPlGJMFl2jZ21BbS6sdpdm3 8Bw2E8k+/rftD9tKEco9tu73n3bFyCgwIClnlUbz1hs090de2ZdfHkHV6OVb6wy4dFyt ZF/LwThIqKubgarJL3MtPdam37gwSATI/gnUqm+AxRidIV/26+mg+57SYAzXwYtQTBv4 IKUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references:reply-to:organization; bh=9LiPiPWO5IKWXJUalLCQLcN6j67kZg0zYfFLWsnPZ1E=; b=mDUAksikJEwmvVAz0W7DVvGbI1fp92M1+ONzQa9Z/nohExVNbBTR8ovEAcuxbwZZjB yyYlHFsclUhC2cpuqWzQmjxQVIiJclUrG56nPcAPSvGAD7ZILbKRxuBUl42X4Pa92n+e ug3LvimMGjkeeNdaxuTz3A9ruVni3TJ8U11WuJ7rSv2e5SxTOTPLq/o3s0c4YbB1Pbhq L9LdtRdaPgbBZ8D4rjNL7DwtfqHw8kDldRpnmC2K2pPnWleaFdubzHgfMYPMqniZSPzT Aw28esZ/SDtDe0MAun8L5NhsQUH2JuNQdR8SZUbWqfHteDSSqVdIhVJlydyHCXlcyM9Q FoUw== X-Gm-Message-State: AMke39nZQP0QLxvY2QnedoT99Zl++lCT6uPaCa6Purnf6YXx/FiGk1KmdmR0G0ioadHiZw== X-Received: by 10.55.144.6 with SMTP id s6mr8107718qkd.140.1488346132156; Tue, 28 Feb 2017 21:28:52 -0800 (PST) Received: from z87.localdomain (pool-96-230-116-151.bstnma.fios.verizon.net. [96.230.116.151]) by smtp.gmail.com with ESMTPSA id c141sm2530517qkb.10.2017.02.28.21.28.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Feb 2017 21:28:51 -0800 (PST) From: Len Brown To: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Len Brown Subject: [PATCH 43/44] tools/power turbostat: bugfix: --add u32 was printed as u64 Date: Wed, 1 Mar 2017 00:27:47 -0500 Message-Id: <5f3aea57773dc7f788e374994636ffc0234a355f.1488345270.git.len.brown@intel.com> X-Mailer: git-send-email 2.11.0.161.g6610af872 In-Reply-To: <20170301052748.27810-1-lenb@kernel.org> References: <20170301052748.27810-1-lenb@kernel.org> In-Reply-To: <678a3bd1b3de6d2ebf604e7d708bc8150bb667e9.1488345270.git.len.brown@intel.com> References: <678a3bd1b3de6d2ebf604e7d708bc8150bb667e9.1488345270.git.len.brown@intel.com> Reply-To: Len Brown Organization: Intel Open Source Technology Center Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Len Brown 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 --- tools/power/x86/turbostat/turbostat.c | 26 +++++++------------------- 1 file 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, for (i = 0, mp = sys.tp; mp; i++, mp = mp->next) { if (mp->format == FORMAT_RAW) { if (mp->width == 32) - outp += sprintf(outp, "%s0x%08lx", (printed++ ? delim : ""), (unsigned long) t->counter[i]); + outp += sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int) t->counter[i]); else outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), t->counter[i]); } else if (mp->format == FORMAT_DELTA) { @@ -876,7 +876,7 @@ int format_counters(struct thread_data *t, struct core_data *c, for (i = 0, mp = sys.cp; mp; i++, mp = mp->next) { if (mp->format == FORMAT_RAW) { if (mp->width == 32) - outp += sprintf(outp, "%s0x%08lx", (printed++ ? delim : ""), (unsigned long) c->counter[i]); + outp += sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int) c->counter[i]); else outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), c->counter[i]); } else if (mp->format == FORMAT_DELTA) { @@ -967,7 +967,7 @@ int format_counters(struct thread_data *t, struct core_data *c, for (i = 0, mp = sys.pp; mp; i++, mp = mp->next) { if (mp->format == FORMAT_RAW) { if (mp->width == 32) - outp += sprintf(outp, "%s0x%08lx", (printed++ ? delim : ""), (unsigned long) p->counter[i]); + outp += sprintf(outp, "%s0x%08x", (printed++ ? delim : ""), (unsigned int) p->counter[i]); else outp += sprintf(outp, "%s0x%016llx", (printed++ ? delim : ""), p->counter[i]); } else if (mp->format == FORMAT_DELTA) { @@ -4732,22 +4732,10 @@ void parse_add_command(char *add_command) /* generate default column header */ if (*name_buffer == '\0') { - if (format == FORMAT_RAW) { - if (width == 32) - sprintf(name_buffer, "msr%d", msr_num); - else - sprintf(name_buffer, "MSR%d", msr_num); - } else if (format == FORMAT_DELTA) { - if (width == 32) - sprintf(name_buffer, "cnt%d", msr_num); - else - sprintf(name_buffer, "CNT%d", msr_num); - } else if (format == FORMAT_PERCENT) { - if (width == 32) - sprintf(name_buffer, "msr%d%%", msr_num); - else - sprintf(name_buffer, "MSR%d%%", msr_num); - } + if (width == 32) + sprintf(name_buffer, "M0x%x%s", msr_num, format == FORMAT_PERCENT ? "%" : ""); + else + sprintf(name_buffer, "M0X%x%s", msr_num, format == FORMAT_PERCENT ? "%" : ""); } if (add_counter(msr_num, path, name_buffer, width, scope, type, format, 0))