From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756395AbcAIQcL (ORCPT ); Sat, 9 Jan 2016 11:32:11 -0500 Received: from terminus.zytor.com ([198.137.202.10]:41994 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755758AbcAIQcJ (ORCPT ); Sat, 9 Jan 2016 11:32:09 -0500 Date: Sat, 9 Jan 2016 08:31:54 -0800 From: tip-bot for Jiri Olsa Message-ID: Cc: tglx@linutronix.de, jolsa@kernel.org, hpa@zytor.com, mingo@kernel.org, a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org, acme@redhat.com, dsahern@gmail.com, kan.liang@intel.com, namhyung@kernel.org Reply-To: acme@redhat.com, linux-kernel@vger.kernel.org, a.p.zijlstra@chello.nl, mingo@kernel.org, tglx@linutronix.de, jolsa@kernel.org, hpa@zytor.com, namhyung@kernel.org, kan.liang@intel.com, dsahern@gmail.com In-Reply-To: <1452077397-31958-3-git-send-email-jolsa@kernel.org> References: <1452077397-31958-3-git-send-email-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf script: Display stat events by default Git-Commit-ID: 36e33c53f4b693d96fb8dd4529fe14306d4e3e76 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 36e33c53f4b693d96fb8dd4529fe14306d4e3e76 Gitweb: http://git.kernel.org/tip/36e33c53f4b693d96fb8dd4529fe14306d4e3e76 Author: Jiri Olsa AuthorDate: Wed, 6 Jan 2016 11:49:56 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Jan 2016 20:11:16 -0300 perf script: Display stat events by default If no script is specified for stat data, display stat events in raw form. $ perf stat record ls SNIP Performance counter stats for 'ls': 0.851585 task-clock (msec) # 0.717 CPUs utilized 0 context-switches # 0.000 K/sec 0 cpu-migrations # 0.000 K/sec 114 page-faults # 0.134 M/sec 2,620,918 cycles # 3.078 GHz stalled-cycles-frontend stalled-cycles-backend 2,714,111 instructions # 1.04 insns per cycle 542,434 branches # 636.970 M/sec 15,946 branch-misses # 2.94% of all branches 0.001186954 seconds time elapsed $ perf script CPU THREAD VAL ENA RUN TIME EVENT -1 26185 851585 851585 851585 1186954 task-clock -1 26185 0 851585 851585 1186954 context-switches -1 26185 0 851585 851585 1186954 cpu-migrations -1 26185 114 851585 851585 1186954 page-faults -1 26185 2620918 853340 853340 1186954 cycles -1 26185 0 0 0 1186954 stalled-cycles-frontend -1 26185 0 0 0 1186954 stalled-cycles-backend -1 26185 2714111 853340 853340 1186954 instructions -1 26185 542434 853340 853340 1186954 branches -1 26185 15946 853340 853340 1186954 branch-misses Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Tested-by: Kan Liang Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1452077397-31958-3-git-send-email-jolsa@kernel.org [ Rename 'time' parameter to 'tstamp' to fix build on older distros ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-script.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 5e18654..5e2f9d2 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -677,10 +677,46 @@ static void process_event(struct perf_script *script __maybe_unused, union perf_ static struct scripting_ops *scripting_ops; +static void __process_stat(struct perf_evsel *counter, u64 tstamp) +{ + int nthreads = thread_map__nr(counter->threads); + int ncpus = perf_evsel__nr_cpus(counter); + int cpu, thread; + static int header_printed; + + if (counter->system_wide) + nthreads = 1; + + if (!header_printed) { + printf("%3s %8s %15s %15s %15s %15s %s\n", + "CPU", "THREAD", "VAL", "ENA", "RUN", "TIME", "EVENT"); + header_printed = 1; + } + + for (thread = 0; thread < nthreads; thread++) { + for (cpu = 0; cpu < ncpus; cpu++) { + struct perf_counts_values *counts; + + counts = perf_counts(counter->counts, cpu, thread); + + printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n", + counter->cpus->map[cpu], + thread_map__pid(counter->threads, thread), + counts->val, + counts->ena, + counts->run, + tstamp, + perf_evsel__name(counter)); + } + } +} + static void process_stat(struct perf_evsel *counter, u64 tstamp) { if (scripting_ops && scripting_ops->process_stat) scripting_ops->process_stat(&stat_config, counter, tstamp); + else + __process_stat(counter, tstamp); } static void process_stat_interval(u64 tstamp)