From patchwork Mon Sep 10 15:04:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prarit Bhargava X-Patchwork-Id: 10594315 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 F2C1814BD for ; Mon, 10 Sep 2018 15:04:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C69A27FC0 for ; Mon, 10 Sep 2018 15:04:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 609902858F; Mon, 10 Sep 2018 15:04:08 +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 475CA28415 for ; Mon, 10 Sep 2018 15:04:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727714AbeIJT6g (ORCPT ); Mon, 10 Sep 2018 15:58:36 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40260 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727411AbeIJT6g (ORCPT ); Mon, 10 Sep 2018 15:58:36 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78DDE406C7A0; Mon, 10 Sep 2018 15:04:04 +0000 (UTC) Received: from prarit.khw1.lab.eng.bos.redhat.com (prarit-guest.khw1.lab.eng.bos.redhat.com [10.16.200.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E18B2027EA4; Mon, 10 Sep 2018 15:04:04 +0000 (UTC) From: Prarit Bhargava To: linux-pm@vger.kernel.org Cc: Prarit Bhargava , Thomas Renninger , Shuah Khan , Stafford Horne Subject: [PATCH v2] cpupower: Add better frequency-info failure messaging Date: Mon, 10 Sep 2018 11:04:00 -0400 Message-Id: <20180910150400.11907-1-prarit@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 10 Sep 2018 15:04:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 10 Sep 2018 15:04:04 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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 Tested with: Performance Per Watt (OS) (ie, kernel) current policy: frequency should be within 800 MHz and 3.00 GHz. The governor "performance" may decide which speed to use within this range. current CPU frequency: 2.03 GHz (asserted by call to kernel) Performance Per Watt (DAPC) (ie, niether) current policy: frequency should be within 800 MHz and 3.00 GHz. The governor "performance" may decide which speed to use within this range. current CPU frequency: Unable to call hardware current CPU frequency: Unable to call kernel Performance (ie, HW) current policy: frequency should be within 800 MHz and 3.00 GHz. The governor "performance" may decide which speed to use within this range. current CPU frequency: 2.33 GHz (asserted by call to kernel) ----8<---- 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 the error if both the hardware and kernel calls fail. v2: Update logic and output separate error lines on failure. Signed-off-by: Prarit Bhargava Cc: Thomas Renninger Cc: Shuah Khan Cc: Stafford Horne Reviewed-by: Thomas Renninger --- tools/power/cpupower/utils/cpufreq-info.c | 36 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index df43cd45d810..8c39f735745b 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,12 @@ 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)) { + if (get_freq_kernel(cpu, 1, 0)) { + printf(_(" current CPU frequency: Unable to call hardware\n")); + printf(_(" current CPU frequency: Unable to call kernel\n")); + } + } get_boost_mode(cpu); } @@ -627,10 +635,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);