From patchwork Mon Jul 16 13:26:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 10526785 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 1FC6D600D0 for ; Mon, 16 Jul 2018 13:26:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FFD7288E4 for ; Mon, 16 Jul 2018 13:26:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0342028924; Mon, 16 Jul 2018 13:26:44 +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, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, 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 A037D288E4 for ; Mon, 16 Jul 2018 13:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727276AbeGPNyK (ORCPT ); Mon, 16 Jul 2018 09:54:10 -0400 Received: from mga01.intel.com ([192.55.52.88]:18296 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727265AbeGPNyK (ORCPT ); Mon, 16 Jul 2018 09:54:10 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2018 06:26:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,361,1526367600"; d="scan'208";a="55372206" Received: from powerlab.fi.intel.com (HELO powerlab.backendnet) ([10.237.71.25]) by fmsmga008.fm.intel.com with ESMTP; 16 Jul 2018 06:26:27 -0700 From: Artem Bityutskiy To: "Rafael J. Wysocki" , Len Brown , Linux PM Mailing List Subject: [PATCH] turbostat: fix -S on UP systems Date: Mon, 16 Jul 2018 16:26:26 +0300 Message-Id: <20180716132626.163661-1-dedekind1@gmail.com> X-Mailer: git-send-email 2.14.4 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: Artem Bityutskiy Turbostat -S option makes the tool print only the summary line and no per-CPU lines, and this is a useful feature. It does not, however, work as expected on a single core system and this patch fixes the problem. The patch is a trivial one-liner and I'll skip explaining how it works. Here is what a non-patched turbostat prints on a UP system (a 2S IvyBridge Xeon with all but one CPUs offline): $ turbostat -S -n2 ... nip... cpu0: MSR_PKGC7_IRTL: 0x00000000 (NOTvalid, 0 ns) CPU Avg_MHz Busy% Bzy_MHz TSC_MHz IRQ SMI POLL C1 ...snip... CPU Avg_MHz Busy% Bzy_MHz TSC_MHz IRQ SMI POLL C1 ...snip... With this patch: $turbostat -S -n2 ...snip... cpu0: MSR_PKGC7_IRTL: 0x00000000 (NOTvalid, 0 ns) Avg_MHz Busy% Bzy_MHz TSC_MHz IRQ SMI POLL C1 C1E ...snip... 2 0.07 3000 2700 153 0 0 19 2 ...snip... 3 0.10 3000 2700 239 0 0 16 0 ...snip... Change-Id: I00358bdacf9b309962771ce28e328e5a3409321f Signed-off-by: Artem Bityutskiy --- turbostat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/turbostat.c b/turbostat.c index 4d14bbb..9013051 100644 --- a/turbostat.c +++ b/turbostat.c @@ -1169,7 +1169,7 @@ void format_all_counters(struct thread_data *t, struct core_data *c, struct pkg_ printed = 1; - if (summary_only) + if (summary_only && topo.num_cpus > 1) return; for_all_cpus(format_counters, t, c, p);