From patchwork Thu Sep 6 13:15:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prarit Bhargava X-Patchwork-Id: 10590599 X-Patchwork-Delegate: shuah@kernel.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 229D2920 for ; Thu, 6 Sep 2018 13:15:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 147D22A94D for ; Thu, 6 Sep 2018 13:15:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08AEA2AA60; Thu, 6 Sep 2018 13:15:18 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 8B6D22A94D for ; Thu, 6 Sep 2018 13:15:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727782AbeIFRuo (ORCPT ); Thu, 6 Sep 2018 13:50:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43554 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727650AbeIFRuo (ORCPT ); Thu, 6 Sep 2018 13:50:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1BBAB40241DA; Thu, 6 Sep 2018 13:15:15 +0000 (UTC) Received: from prarit.bos.redhat.com (prarit-guest.khw.lab.eng.bos.redhat.com [10.16.186.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD5EE23141; Thu, 6 Sep 2018 13:15:14 +0000 (UTC) From: Prarit Bhargava To: linux-pm@vger.kernel.org Cc: Prarit Bhargava , Thomas Renninger , Shuah Khan , Stafford Horne Subject: [PATCH] cpupower: Add better frequency-info failure messaging Date: Thu, 6 Sep 2018 09:15:13 -0400 Message-Id: <20180906131513.24862-1-prarit@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 06 Sep 2018 13:15:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 06 Sep 2018 13:15:15 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'prarit@redhat.com' RCPT:'' 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 If a Dell system has "OS DBPM(Performance Per Watt OS)" set in BIOS, cpupower frequency-info outputs current CPU frequency: Unable to call hardware current CPU frequency: 2.50 GHz (asserted by call to kernel) to indicate that cpupower cannot read the frequency from hardware and is using the kernel's cpu frequency estimate. This output is confusing to end users who wonder why the hardware is not responding. Update the cpupower frequency-info output message to only output an error if both the hardware and kernel calls fail. Signed-off-by: Prarit Bhargava Cc: Thomas Renninger Cc: Shuah Khan Cc: Stafford Horne --- tools/power/cpupower/utils/cpufreq-info.c | 32 +++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index df43cd45d810..d7dcd78de544 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c @@ -246,17 +246,19 @@ static int get_boost_mode(unsigned int cpu) /* --freq / -f */ -static int get_freq_kernel(unsigned int cpu, unsigned int human) +static int get_freq_kernel(unsigned int cpu, unsigned int human, int fail_msg) { unsigned long freq = cpufreq_get_freq_kernel(cpu); - printf(_(" current CPU frequency: ")); + if (!freq) { - printf(_(" Unable to call to kernel\n")); + if (fail_msg) + printf(_(" current CPU frequency: Unable to call to kernel\n")); return -EINVAL; } - if (human) { + printf(_(" current CPU frequency: ")); + if (human) print_speed(freq); - } else + else printf("%lu", freq); printf(_(" (asserted by call to kernel)\n")); return 0; @@ -265,17 +267,19 @@ static int get_freq_kernel(unsigned int cpu, unsigned int human) /* --hwfreq / -w */ -static int get_freq_hardware(unsigned int cpu, unsigned int human) +static int get_freq_hardware(unsigned int cpu, unsigned int human, int fail_msg) { unsigned long freq = cpufreq_get_freq_hardware(cpu); - printf(_(" current CPU frequency: ")); + if (!freq) { - printf("Unable to call hardware\n"); + if (fail_msg) + printf(_(" current CPU frequency: Unable to call hardware\n")); return -EINVAL; } - if (human) { + printf(_(" current CPU frequency: ")); + if (human) print_speed(freq); - } else + else printf("%lu", freq); printf(_(" (asserted by call to hardware)\n")); return 0; @@ -475,8 +479,8 @@ static void debug_output_one(unsigned int cpu) get_available_governors(cpu); get_policy(cpu); - if (get_freq_hardware(cpu, 1) < 0) - get_freq_kernel(cpu, 1); + if (get_freq_hardware(cpu, 1, 0) && get_freq_kernel(cpu, 1, 0)) + printf(_(" current CPU frequency: Unable to call hardware or kernel\n")); get_boost_mode(cpu); } @@ -627,10 +631,10 @@ int cmd_freq_info(int argc, char **argv) ret = get_hardware_limits(cpu, human); break; case 'w': - ret = get_freq_hardware(cpu, human); + ret = get_freq_hardware(cpu, human, 1); break; case 'f': - ret = get_freq_kernel(cpu, human); + ret = get_freq_kernel(cpu, human, 1); break; case 's': ret = get_freq_stats(cpu, human);