From patchwork Thu Apr 13 00:08:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Len Brown X-Patchwork-Id: 9678489 X-Patchwork-Delegate: rjw@sisk.pl 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 1A79B60383 for ; Thu, 13 Apr 2017 00:09:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CE2328631 for ; Thu, 13 Apr 2017 00:09:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01F302863B; Thu, 13 Apr 2017 00:09:51 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 A475328631 for ; Thu, 13 Apr 2017 00:09:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755872AbdDMAJu (ORCPT ); Wed, 12 Apr 2017 20:09:50 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:34176 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755875AbdDMAJe (ORCPT ); Wed, 12 Apr 2017 20:09:34 -0400 Received: by mail-qt0-f195.google.com with SMTP id r49so6006457qta.1; Wed, 12 Apr 2017 17:09:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references:reply-to:organization; bh=zpAr2DE1P4WYMaFwYcqvpTz2EbBJmn0L5mDQ2Eve9E0=; b=kTLSPovqOPSLu1unnJGIhBpZ+CIs9xsrv1svhoCEx276ARUlXcbKZsfr81JTbXjDkM iNtNbmhG44K+WPH7RNSZoA/C8a8zDV/HgEkqHJA70+RkdHf7Mo3u3BJOT91WxMFPxFLc T/oQwBu1B1Dkwp/LsUcD4IwGy9WBQ9mc3MTCNnINH55TXRZ9b50OeJ4HTfmcE3KGLQ7o 5MHQ1iY/oZXGN5WYcZf1PTLCWvFjvSnHVWqceckx/yh5gTFBXYtmUE4Lz9b+33O8Qpie kbfbZli5mQsTtIxTtfVPtrVTywwYXLvyFJYPkRFcEhYYGiuXD9Uo1Bj/gDQErDQYbOtu pEjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references:reply-to:organization; bh=zpAr2DE1P4WYMaFwYcqvpTz2EbBJmn0L5mDQ2Eve9E0=; b=QRjooygPka1coIYHPGDrd7NTOK3kjbcYgbYv6ZxQ7QidqS/o1GLHG9k9tAI28ECsb6 2m6vo7fyGu9JXrvrWqZS/XWpKDSCnU1gMQ/OXMj8hOH3WP2hpXnHnFsmiJgwC/u1clxT UozU4MnuF2BqbISwydfxUR7rRT+9kJnmo9oJtPBZyVff+0uMZSpBWa7zpYqO+XsHN4l3 Z12SGsprgoMrg4kEtPa5X6BUNwzSemlRNMTDcxCfoKpt3w6qHhI7EJdVEy+9QB+RtRL7 i01gatmeKuYjR3delxPB10jS8uF3XwxJGoL3EdNy4pgz1dny6C6kPwcI6vrxV1GiqrIP NCyg== X-Gm-Message-State: AN3rC/7pzFKpW7bsm4L7dPdhrq8Yme1Oun1wet+rOaqthtRUQBGnOuqT /06Xck/01MiCG5nt X-Received: by 10.200.50.199 with SMTP id a7mr284534qtb.95.1492042173979; Wed, 12 Apr 2017 17:09:33 -0700 (PDT) Received: from z87.localdomain (pool-173-48-65-169.bstnma.fios.verizon.net. [173.48.65.169]) by smtp.gmail.com with ESMTPSA id g15sm14621086qte.58.2017.04.12.17.09.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Apr 2017 17:09:33 -0700 (PDT) From: Len Brown To: rjw@rjwysocki.net, linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Len Brown Subject: [PATCH 6/7] tools/power turbostat: fix impossibly large CPU%c1 value Date: Wed, 12 Apr 2017 20:08:52 -0400 Message-Id: <95149369c1c28b10f7318dfde54018ab107277d0.1492041840.git.len.brown@intel.com> X-Mailer: git-send-email 2.11.0.161.g6610af872 In-Reply-To: <20170413000853.21648-1-lenb@kernel.org> References: <20170413000853.21648-1-lenb@kernel.org> In-Reply-To: <22048c5485503749754b3b5daf9d99ef89fcacdc.1492041840.git.len.brown@intel.com> References: <22048c5485503749754b3b5daf9d99ef89fcacdc.1492041840.git.len.brown@intel.com> Reply-To: Len Brown Organization: Intel Open Source Technology Center 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: Len Brown Most CPUs do not have a hardware c1 counter, and so turbostat derives c1 residency: c1 = TSC - MPERF - other_core_cstate_counters As it is not possible to atomically read these coutners, measurement jitter can case this calcuation to "go negative" when very close to 0. Turbostat detect that case and simply prints c1 = 0.00% But that check neglected to account for systems where the TSC crystal clock domain and the MPERF BCLK domain are differ by a small amount. That allowed very small negative c1 numbers to escape this check and be printed as huge positve numbers. This code begs for a bit of cleanup, but this patch is the minimal change to fix the issue. Signed-off-by: Len Brown --- tools/power/x86/turbostat/turbostat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index b0591d0da801..0ad966114e58 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -1142,7 +1142,7 @@ delta_thread(struct thread_data *new, struct thread_data *old, * it is possible for mperf's non-halted cycles + idle states * to exceed TSC's all cycles: show c1 = 0% in that case. */ - if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > old->tsc) + if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > (old->tsc * tsc_tweak)) old->c1 = 0; else { /* normal case, derive c1 */