Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp638484pxx; Mon, 26 Oct 2020 17:43:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7pz6bcMH8Rl/1j8bOymCJ1GAlRCISz9kURFcMb+KO9kyUBLdiK9J4tQinITC87lTXSEfK X-Received: by 2002:a17:906:22d8:: with SMTP id q24mr17750656eja.479.1603759421890; Mon, 26 Oct 2020 17:43:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603759421; cv=none; d=google.com; s=arc-20160816; b=fgQEiL1cNBY4MKlThbFQLxbv57jBeowoOifUK3+GXbKpAmFr3N0Tz8kBmrsCl172JT mYMnX6TG+lD4gJocNAsGlACRzILlK0kOfGmkjpawUcf3BzIPV5FB5qqfdVZSnSuPwGYG Scm+qfsNOLQKNDMArwjA+UIr1xMgOf8cTRe2J1IZSp3XF3m95izsXY3X6dt1/E8kqhGc YPPEzOUMpBvm8FSQdUJbS0D+ji3VEF90rmWho4Lt9jEnkQgHXcaDd091qw8hK/BYOgoV qgb0K2CV0GQgY2/XlC0kCZxAexdwc/NtPvyFPtKW2RJbVp1Q5aCOWhjKRkdES9kGqVw0 vKCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=71dFUD8mcWHBMmc3r0mHiXgDCrifw4UWlp48ARGwbUw=; b=XlgiTjiiOOBB2qx6qzs9OhnwCcIBOxJf2Jz18ksHSrb33y1nAVs4FAcCssMvsseaCq J5YBjYfRG6tuM0MIojci17GU+ccdh7S8p13s/dqUnopCP8u/iIdA0d5/iyetMS3DCbM9 QFMmyFRLZcRTNQ1BVd8iM2G22V8MUu6t9TgWx7xmKh4f10kqh64PVMWcLxLqaGo06lI+ QW81EaryWtJQYtDR8lXFMSz+o3tBUVuTac6jIY4Lx47XIqwIwCaVIgIh33DHQJ8ETL82 ur+2fSEOuMSpyNLQYzrD6T8+4YLF3bYly/2kNYPB/z5EYXea3sdoACHL/GSd35qYU+d5 EsNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@firstfloor.org header.s=mail header.b=nKYTUPRz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e21si7885468edy.555.2020.10.26.17.43.20; Mon, 26 Oct 2020 17:43:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@firstfloor.org header.s=mail header.b=nKYTUPRz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2442682AbgJ0A1z (ORCPT + 99 others); Mon, 26 Oct 2020 20:27:55 -0400 Received: from one.firstfloor.org ([193.170.194.197]:59536 "EHLO one.firstfloor.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394876AbgJ0A1u (ORCPT ); Mon, 26 Oct 2020 20:27:50 -0400 Received: from firstfloor.org (c-71-237-255-61.hsd1.or.comcast.net [71.237.255.61]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by one.firstfloor.org (Postfix) with ESMTPSA id C4F5A86837; Tue, 27 Oct 2020 01:27:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=firstfloor.org; s=mail; t=1603758465; bh=9K+cenBFS949Ho1pS1ggc3fQZ0xkHgvhRaRIiyP+SII=; h=From:To:Cc:Subject:Date:From; b=nKYTUPRzYRcOWzj0ub69wuXgsmdlrqMPbs4FhUti+Embco1aKE+GfdwnFlAChFGCZ 3XPRFEiCiJLhIWSVcrUqxSvXIpui0bHt1y4x58D0kqwhLzEAxOLld/bFXUPrBfr9Nf hDCpcL/2rpQ4pctqFjbmUtxXGjusCg37zmRMyJMA= Received: by firstfloor.org (Postfix, from userid 1000) id EDAF9A0A57; Mon, 26 Oct 2020 17:27:42 -0700 (PDT) From: Andi Kleen To: acme@kernel.org Cc: jolsa@kernel.org, linux-kernel@vger.kernel.org, alexey.budankov@linux.intel.com, Andi Kleen Subject: [PATCH 1/2] perf tools: Add --quiet option to perf stat Date: Mon, 26 Oct 2020 17:27:36 -0700 Message-Id: <20201027002737.30942-1-andi@firstfloor.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new --quiet option to perf stat. This is useful with perf stat record to write the data only to the perf.data file, which can lower measurement overhead because the data doesn't need to be formatted. On my 4C desktop: % time ./perf stat record -e $(python -c 'print ",".join(["cycles"]*1000)') -a -I 1000 sleep 5 ... real 0m5.377s user 0m0.238s sys 0m0.452s % time ./perf stat record --quiet -e $(python -c 'print ",".join(["cycles"]*1000)') -a -I 1000 sleep 5 real 0m5.452s user 0m0.183s sys 0m0.423s In this example it cuts the user time by 20%. On systems with more cores the savings are higher. Signed-off-by: Andi Kleen --- tools/perf/Documentation/perf-stat.txt | 4 ++++ tools/perf/builtin-stat.c | 6 +++++- tools/perf/util/stat.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt index 9f9f29025e49..b138dd192423 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -316,6 +316,10 @@ small group that need not have multiplexing is lowered. This option forbids the event merging logic from sharing events between groups and may be used to increase accuracy in this case. +--quiet:: +Don't print output. This is useful with perf stat record below to only +write data to the perf.data file. + STAT RECORD ----------- Stores stat data into perf data file. diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index b01af171d94f..743fe47e7a88 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -972,6 +972,8 @@ static void print_counters(struct timespec *ts, int argc, const char **argv) /* Do not print anything if we record to the pipe. */ if (STAT_RECORD && perf_stat.data.is_pipe) return; + if (stat_config.quiet) + return; perf_evlist__print_counters(evsel_list, &stat_config, &target, ts, argc, argv); @@ -1171,6 +1173,8 @@ static struct option stat_options[] = { "threads of same physical core"), OPT_BOOLEAN(0, "summary", &stat_config.summary, "print summary for interval mode"), + OPT_BOOLEAN(0, "quiet", &stat_config.quiet, + "don't print output (useful with record)"), #ifdef HAVE_LIBPFM OPT_CALLBACK(0, "pfm-events", &evsel_list, "event", "libpfm4 event selector. use 'perf list' to list available events", @@ -2132,7 +2136,7 @@ int cmd_stat(int argc, const char **argv) goto out; } - if (!output) { + if (!output && !stat_config.quiet) { struct timespec tm; mode = append_file ? "a" : "w"; diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 487010c624be..05adf8165025 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -122,6 +122,7 @@ struct perf_stat_config { bool metric_no_group; bool metric_no_merge; bool stop_read_counter; + bool quiet; FILE *output; unsigned int interval; unsigned int timeout; -- 2.28.0