From patchwork Thu Jul 6 07:14:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: seeteena X-Patchwork-Id: 9827537 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 48D3060361 for ; Thu, 6 Jul 2017 07:14:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 338E1285D5 for ; Thu, 6 Jul 2017 07:14:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28441285E9; Thu, 6 Jul 2017 07:14:37 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham 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 BA539285D5 for ; Thu, 6 Jul 2017 07:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752772AbdGFHOg (ORCPT ); Thu, 6 Jul 2017 03:14:36 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51133 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752610AbdGFHOf (ORCPT ); Thu, 6 Jul 2017 03:14:35 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v667DcMc066460 for ; Thu, 6 Jul 2017 03:14:34 -0400 Received: from e23smtp02.au.ibm.com (e23smtp02.au.ibm.com [202.81.31.144]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bh38m5jnn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 06 Jul 2017 03:14:34 -0400 Received: from localhost by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Jul 2017 17:14:32 +1000 Received: from d23relay08.au.ibm.com (202.81.31.227) by e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 6 Jul 2017 17:14:29 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v667ETo410092862; Thu, 6 Jul 2017 17:14:29 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v667ESno029392; Thu, 6 Jul 2017 17:14:28 +1000 Received: from oc1548405160.in.ibm.com ([9.109.223.62]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v667EO0B029311 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 6 Jul 2017 17:14:26 +1000 From: Seeteena Thoufeek To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, trenn@suse.com Cc: s1seetee@linux.vnet.ibm.com Subject: [PATCH] Fix header-name to read full state name and adjust column width Date: Thu, 6 Jul 2017 12:44:24 +0530 X-Mailer: git-send-email 1.8.3.1 X-TM-AS-MML: disable x-cbid: 17070607-0004-0000-0000-0000022449B3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070607-0005-0000-0000-00005E0879D7 Message-Id: <1499325264-15521-1-git-send-email-s1seetee@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-06_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1707060124 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 ---Steps to Reproduce--- 1.Execute the cpupower monitor command to fetch all the Idle_Stats values. root:~# cpupower monitor |Idle_Stats PKG |CORE|CPU | snoo | stop | stop 0| 8| 0| 0.00| 0.00| 2.79 0| 8| 1| 0.00| 0.00| 70.68 User interpret it as 2 columns for stop Idle_stats. root:/sys/devices/system/cpu/cpu8/cpuidle# cat */name snooze stop0_lite stop1_lite cpupower monitor now shows full state name and adjust colomn width. root:~/linux/tools/power/cpupower# cpupower monitor |Idle_Stats PKG |CORE|CPU |snooze|stop0_lite|stop1_lite 0| 8| 0| 0.00| 0.00| 99.83 0| 8| 1| 0.00| 0.00| 43.82 0| 8| 2| 0.00| 0.00| 102.1 0| 8| 3| 0.00| 0.00| 96.56 tested on x86 as well. Signed-off-by: Seeteena Thoufeek Reviewed-by: Gautham R. Shenoy --- .../cpupower/utils/idle_monitor/cpupower-monitor.c | 25 ++++++++++++++-------- .../cpupower/utils/idle_monitor/cpupower-monitor.h | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c index 05f953f..5e708d5 100644 --- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c +++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c @@ -88,7 +88,7 @@ void print_header(int topology_depth) int state, need_len; cstate_t s; char buf[128] = ""; - int percent_width = 4; + unsigned int percent_width = 6; fill_string_with_spaces(buf, topology_depth * 5 - 1); printf("%s|", buf); @@ -116,17 +116,18 @@ void print_header(int topology_depth) for (mon = 0; mon < avail_monitors; mon++) { if (mon != 0) printf("|| "); - else - printf(" "); for (state = 0; state < monitors[mon]->hw_states_num; state++) { if (state != 0) - printf(" | "); + printf("|"); s = monitors[mon]->hw_states[state]; sprintf(buf, "%s", s.name); - fill_string_with_spaces(buf, percent_width); + if (strlen(s.name) > percent_width) + fill_string_with_spaces(buf, strlen(s.name)); + else + fill_string_with_spaces(buf, percent_width); + printf("%s", buf); - } - printf(" "); + } } printf("\n"); } @@ -139,7 +140,9 @@ void print_results(int topology_depth, int cpu) double percent; unsigned long long result; cstate_t s; - + char buf[128] = ""; + unsigned int percent_width = 6; + unsigned int width; /* Be careful CPUs may got resorted for pkg value do not just use cpu */ if (!bitmask_isbitset(cpus_chosen, cpu_top.core_info[cpu].cpu)) return; @@ -163,7 +166,11 @@ void print_results(int topology_depth, int cpu) printf("|"); s = monitors[mon]->hw_states[state]; - + if (strlen(s.name) > percent_width) { + width = strlen(s.name) - percent_width; + fill_string_with_spaces(buf, width); + printf("%s", buf); + } if (s.get_count_percent) { ret = s.get_count_percent(s.id, &percent, cpu_top.core_info[cpu].cpu); diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h index 9e43f33..c9179c6 100644 --- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h +++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h @@ -15,7 +15,7 @@ #define MONITORS_MAX 20 #define MONITOR_NAME_LEN 20 -#define CSTATE_NAME_LEN 5 +#define CSTATE_NAME_LEN 16 #define CSTATE_DESC_LEN 60 int cpu_count;