From patchwork Sun Jun 25 03:12:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Len Brown X-Patchwork-Id: 9807919 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 3BB8E6088A for ; Sun, 25 Jun 2017 03:13:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D25C128372 for ; Sun, 25 Jun 2017 03:13:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6D152845D; Sun, 25 Jun 2017 03:13:13 +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 2B0D528372 for ; Sun, 25 Jun 2017 03:13:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751094AbdFYDNL (ORCPT ); Sat, 24 Jun 2017 23:13:11 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:33119 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751083AbdFYDNK (ORCPT ); Sat, 24 Jun 2017 23:13:10 -0400 Received: by mail-qk0-f193.google.com with SMTP id p21so10962844qke.0 for ; Sat, 24 Jun 2017 20:13:09 -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=Wu+3nAZ6vISrMszXYTgzKDQ0XCSsRHsZHGFOjJj2Amw=; b=s+J7LqRTDGqJJ0KXEpOhPfY34PB++e5w8yl5394dLd/ptH50g5oeYHBYnucFT2e48r F9NbnmmDCtklmuXI7Tx2pIksUrd3SkSTvVS69wEj8I28HjYxAi26qRQd3l9RIWNbNbSV uYSwNXDtkvYDLlZkeAgooJlqqJBAZuyQdX4d3DJ6pSxjgY5yUphUKEB3bsmZFnQRqd6B RkgRm3fON9OUuYFvMNTdJ+KcE2JF1jn6sLtA52EJK/XGBGsoxVuZRZX5qP7W00ZC9kKf yZQtAMLEMdOFYQAJhyXvGI4xTUSdA9r4NPFQCP0BGUFlGZMzZUuXeT2McBK4Qy5Ic7zG LE3w== 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=Wu+3nAZ6vISrMszXYTgzKDQ0XCSsRHsZHGFOjJj2Amw=; b=QiuHL8RoUdh6cOMLw7ABjmVFeAOl8aALfeTli1Ey6uFGOMeFijKx/9Zr1Skxv7QyFl qf/+l4+WLU3oGGm0RDePdalHtrRsJCtcEvxhktKs6QfnF+5erwEaoyhbhJ8xuMI/xBiT 7CUVH+daDzoATy4c168UTGTA9VRoc9NHZP2GJ3Jo1lqnMUr/cFToft2UFLvPLXUJQRZJ iHYjzS3xu991XwwssLnsJx6wnDItYYiLsnA2x7Q0xJG1AMcSsAeMw2sQTmWnCqZlOjKQ MgiYzA4Z4mqQow6XMX/x6g8GI1KGayFX4P5l0z2v0eeoKPcrwAMJsMjdqx5OTTK3Ysrf 5C3Q== X-Gm-Message-State: AKS2vOx9rxS7pfls5p7nk6mRs9ThXTxsN8TBX6n0IcOGkpQtGQHgTnPu hucBH+BO001TYTC+ X-Received: by 10.55.17.36 with SMTP id b36mr16344765qkh.257.1498360389217; Sat, 24 Jun 2017 20:13:09 -0700 (PDT) Received: from localhost.localdomain (pool-173-48-65-169.bstnma.fios.verizon.net. [173.48.65.169]) by smtp.gmail.com with ESMTPSA id o76sm6158770qke.7.2017.06.24.20.13.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 24 Jun 2017 20:13:08 -0700 (PDT) From: Len Brown To: linux-pm@vger.kernel.org Cc: Len Brown Subject: [PATCH 2/5] tools/power turbostat: if --debug, print sampling overhead Date: Sat, 24 Jun 2017 20:12:58 -0700 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498360381-10293-1-git-send-email-lenb@kernel.org> References: <1498360381-10293-1-git-send-email-lenb@kernel.org> In-Reply-To: References: 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 The --debug option now pre-pends each row with the number of micro-seconds [usec] to collect the finishing snapshot for that row. Signed-off-by: Len Brown --- tools/power/x86/turbostat/turbostat.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 2b25727..6f7c64a 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -150,6 +150,8 @@ size_t cpu_present_setsize, cpu_affinity_setsize, cpu_subset_size; #define MAX_ADDED_COUNTERS 16 struct thread_data { + struct timeval tv_begin; + struct timeval tv_end; unsigned long long tsc; unsigned long long aperf; unsigned long long mperf; @@ -530,6 +532,8 @@ void print_header(char *delim) struct msr_counter *mp; int printed = 0; + if (debug) + outp += sprintf(outp, "usec %s", delim); if (DO_BIC(BIC_Package)) outp += sprintf(outp, "%sPackage", (printed++ ? delim : "")); if (DO_BIC(BIC_Core)) @@ -782,6 +786,14 @@ int format_counters(struct thread_data *t, struct core_data *c, (cpu_subset && !CPU_ISSET_S(t->cpu_id, cpu_subset_size, cpu_subset))) return 0; + if (debug) { + /* on each row, print how many usec each timestamp took to gather */ + struct timeval tv; + + timersub(&t->tv_end, &t->tv_begin, &tv); + outp += sprintf(outp, "%5ld\t", tv.tv_sec * 1000000 + tv.tv_usec); + } + interval_float = tv_delta.tv_sec + tv_delta.tv_usec/1000000.0; tsc = t->tsc * tsc_tweak; @@ -1503,6 +1515,9 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) struct msr_counter *mp; int i; + + gettimeofday(&t->tv_begin, (struct timezone *)NULL); + if (cpu_migrate(cpu)) { fprintf(outf, "Could not migrate to CPU %d\n", cpu); return -1; @@ -1586,7 +1601,7 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) /* collect core counters only for 1st thread in core */ if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) - return 0; + goto done; if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates) { if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3)) @@ -1622,7 +1637,7 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) /* collect package counters only for 1st core in package */ if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) - return 0; + goto done; if (DO_BIC(BIC_Totl_c0)) { if (get_msr(cpu, MSR_PKG_WEIGHTED_CORE_C0_RES, &p->pkg_wtd_core_c0)) @@ -1715,6 +1730,8 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) if (get_mp(cpu, mp, &p->counter[i])) return -10; } +done: + gettimeofday(&t->tv_end, (struct timezone *)NULL); return 0; }