From patchwork Wed Nov 9 05:17:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akshay Adiga X-Patchwork-Id: 9418497 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 AA7326048E for ; Wed, 9 Nov 2016 05:18:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B03528B0B for ; Wed, 9 Nov 2016 05:18:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F99429136; Wed, 9 Nov 2016 05:18:35 +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=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 8559929133 for ; Wed, 9 Nov 2016 05:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751542AbcKIFS3 (ORCPT ); Wed, 9 Nov 2016 00:18:29 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34271 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751884AbcKIFS0 (ORCPT ); Wed, 9 Nov 2016 00:18:26 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uA95DWZv126127 for ; Wed, 9 Nov 2016 00:18:26 -0500 Received: from e28smtp07.in.ibm.com (e28smtp07.in.ibm.com [125.16.236.7]) by mx0b-001b2d01.pphosted.com with ESMTP id 26kwax916r-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 09 Nov 2016 00:18:25 -0500 Received: from localhost by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 9 Nov 2016 10:48:21 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 9 Nov 2016 10:48:18 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 02A7DE005A; Wed, 9 Nov 2016 10:48:23 +0530 (IST) Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay03.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uA95IIAC38010970; Wed, 9 Nov 2016 10:48:18 +0530 Received: from d28av05.in.ibm.com (localhost [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id uA95ID0M010904; Wed, 9 Nov 2016 10:48:17 +0530 Received: from aksadiga.ibm ([9.79.254.52]) by d28av05.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id uA95I18L010639; Wed, 9 Nov 2016 10:48:02 +0530 From: Akshay Adiga To: trenn@suse.com, rafael.j.wysocki@intel.com, jtanenba@redhat.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Akshay Adiga Subject: [PATCH] cpupower: Warn if values are truncated in frequency-info Date: Wed, 9 Nov 2016 10:47:58 +0530 X-Mailer: git-send-email 2.5.5 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16110905-0024-0000-0000-0000033D962E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16110905-0025-0000-0000-00000FB6BE27 Message-Id: <1478668678-21556-1-git-send-email-akshay.adiga@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-09_02:, , 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-1609300000 definitions=main-1611090097 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 frequency-info currently rounds the frequnecy values to 2 decimal places while printing "available frequency steps". Hence frequencies with 3rd decimal place being greater than 5 will be rounded to next higher number like 2.227GHz will be rounded to 2.23Ghz. On setting this frequency, using "cpupower frequency-set -f " ,if the value does not match, then it will set to the next lowest frequency greater than provided frequency value (according to the userspace governor). Hence adding a warning if there are any cases where the displayed frequency cannot be used directly to set a perticular frequency, and insist the user to use the "-n" option. Simple usecase where it give counter intuitive results : bash# cpupower frequency-info ... available frequency steps: 2.43 GHz, 2.39 GHz, 2.36 GHz, 2.33 GHz, 2.29 GHz, 2.26 GHz, 2.23 GHz, 2.19 GHz, 2.16 GHz, 2.13 GHz bash# cpupower frequency-info -n ... available frequency steps: 2.427000 GHz, 2.394000 GHz, 2.360000 GHz, 2.327000 GHz, 2.294000 GHz, 2.261000 GHz, 2.227000 GHz, 2.194000 GHz, 2.161000 GHz, 2.128000 GHz bash# cpupower frequency-set -f 2.23Ghz bash# cpupower frequency-info ... current CPU frequency: 2.26 GHz (asserted by call to hardware) Signed-off-by: Akshay Adiga --- tools/power/cpupower/utils/cpufreq-info.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index 590d12a..4f13b06 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c @@ -85,6 +85,7 @@ static void proc_cpufreq_output(void) } static int no_rounding; +static int freq_info_truncated; static void print_speed(unsigned long speed) { unsigned long tmp; @@ -103,8 +104,10 @@ static void print_speed(unsigned long speed) } else { if (speed > 1000000) { tmp = speed%10000; - if (tmp >= 5000) + if (tmp >= 5000) { + freq_info_truncated = 1; speed += 10000; + } printf("%u.%02u GHz", ((unsigned int) speed/1000000), ((unsigned int) (speed%1000000)/10000)); } else if (speed > 100000) { @@ -243,6 +246,7 @@ static int get_boost_mode(unsigned int cpu) printf(_(" %.0f MHz max turbo 1 active cores\n"), ratio * bclk); } + return 0; } @@ -641,5 +645,12 @@ int cmd_freq_info(int argc, char **argv) return ret; printf("\n"); } + + if (freq_info_truncated) { + printf(" Warning! Frequency values shown are rounded off\n"); + printf(" To set frequency use frequency values provided\n"); + printf(" by \"cpupower frequency-info -n \"\n"); + } + return ret; }