From patchwork Thu Apr 13 00:08:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Len Brown X-Patchwork-Id: 9678511 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 BD86A60383 for ; Thu, 13 Apr 2017 00:11:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFFA328631 for ; Thu, 13 Apr 2017 00:11:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4F912863B; Thu, 13 Apr 2017 00:11:20 +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=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 E171D28633 for ; Thu, 13 Apr 2017 00:11:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755659AbdDMALC (ORCPT ); Wed, 12 Apr 2017 20:11:02 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:34187 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755609AbdDMAJ3 (ORCPT ); Wed, 12 Apr 2017 20:09:29 -0400 Received: by mail-qk0-f194.google.com with SMTP id p68so6265262qke.1; Wed, 12 Apr 2017 17:09:28 -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 :reply-to:organization; bh=eKqFenGY0zFXRSKUvAPe6LdKKHYgitGt2K6IxtTe0y0=; b=vSZwQcgMPNB6XHJ71lyjilqeSp/flI5jy97HRn21eMMr6Oo1pTHpDypzFad2/eSdxQ fpETWT/DSsuLKNrTR1XABl7cZRBATirD3olb0gBQ0/ckbnCoYddRep6jum7C2tCHWpdZ sNZhvkZsbTEOM3kgu78p0eUB8zYJV8UHkt0ujE8p2J7YvFlpfOfvxgciWiHoXP6oMATI lKWm0Dg/Mr5TQotfIcNjd8iOpjrrQvsoCVO3D8WSUmr7xgv6DezqRkqPCp7Ubf/eNZ+1 zN40MszQzmyRDvsf+XFOEgvhg4erGIqHxnTJgnqAPHCMkGoVhUctwsTKzD8xaUtnpdX9 43Mw== 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:reply-to:organization; bh=eKqFenGY0zFXRSKUvAPe6LdKKHYgitGt2K6IxtTe0y0=; b=p1VQ0OMjnGdglgSeknWK6FlXKUGC9vYLqTXu2e6Hw75QxxC/qYMI3AgpC+Oys2W5L5 +qAgQypDg7K2SmIA5vxq0LkLbc9uNgO9yTfAqYhKgJelZDFZ09w0nkSRizFy0AslRXfW lBw4rDlMRVapGNSQ5DgpmewtQjfXOxa1HAxnQ0GhrP3hE3cHLWOtK2qsgW4+7501r7pG /+bhThaSgIOMmsvC4Wq0540bf9T9TXb0go0bx5YqZT3VaK+zfi1QW6Oo2JfFhD2Vla9f ZYMuXZ56NfIGIvXrcYjhwtnOB9uSo+lcz/mGCeuNGYfbiY2h2MhWeSqw6LoXD6GBTDd6 vI9g== X-Gm-Message-State: AN3rC/4Ti1So4GsVPqUUPlc/EFBat+fH4BoKNnTXJ2ULtSCJF0O0auXh uV8IXJYasRSsSw== X-Received: by 10.55.148.194 with SMTP id w185mr285045qkd.58.1492042168064; Wed, 12 Apr 2017 17:09:28 -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.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Apr 2017 17:09:27 -0700 (PDT) From: Len Brown To: rjw@rjwysocki.net, linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Len Brown Subject: [PATCH 1/7] tools/power turbostat: bugfix: GFXMHz column not changing Date: Wed, 12 Apr 2017 20:08:47 -0400 Message-Id: <22048c5485503749754b3b5daf9d99ef89fcacdc.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> 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 turbostat displays a GFXMHz column, which comes from reading /sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz But GFXMHz was not changing, even when a manual cat /sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz showed a new value. It turns out that a rewind() on the open file is not sufficient, fflush() (or a close/open) is needed to read fresh values. Reported-by: Yaroslav Isakov Signed-off-by: Len Brown --- tools/power/x86/turbostat/turbostat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 828dccd3f01e..d7fb6bcb2744 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -2485,8 +2485,10 @@ int snapshot_gfx_mhz(void) if (fp == NULL) fp = fopen_or_die("/sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz", "r"); - else + else { rewind(fp); + fflush(fp); + } retval = fscanf(fp, "%d", &gfx_cur_mhz); if (retval != 1)