Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161972AbbKEOle (ORCPT ); Thu, 5 Nov 2015 09:41:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46754 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161947AbbKEOl3 (ORCPT ); Thu, 5 Nov 2015 09:41:29 -0500 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , David Ahern , Ingo Molnar , Namhyung Kim , Peter Zijlstra , "Liang, Kan" Subject: [PATCH 07/25] perf stat record: Write stat events on record Date: Thu, 5 Nov 2015 15:40:51 +0100 Message-Id: <1446734469-11352-8-git-send-email-jolsa@kernel.org> In-Reply-To: <1446734469-11352-1-git-send-email-jolsa@kernel.org> References: <1446734469-11352-1-git-send-email-jolsa@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1752 Lines: 55 Writing stat events on 'perf stat record' at the time we read counter values from kernel. Tested-by: Kan Liang Link: http://lkml.kernel.org/n/tip-ojc826gy0x9jj74elbjfccej@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/builtin-stat.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index c8c0acb0c2cd..1567c5337941 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -210,6 +210,18 @@ static int process_synthesized_event(struct perf_tool *tool __maybe_unused, return 0; } +#define SID(e, x, y) xyarray__entry(e->sample_id, x, y) + +static int +perf_evsel__write_stat_event(struct perf_evsel *counter, u32 cpu, u32 thread, + struct perf_counts_values *count) +{ + struct perf_sample_id *sid = SID(counter, cpu, thread); + + return perf_event__synthesize_stat(NULL, cpu, thread, sid->id, count, + process_synthesized_event, NULL); +} + /* * Read out the results of a single counter: * do not aggregate counts across CPUs in system-wide mode @@ -233,6 +245,13 @@ static int read_counter(struct perf_evsel *counter) count = perf_counts(counter->counts, cpu, thread); if (perf_evsel__read(counter, cpu, thread, count)) return -1; + + if (STAT_RECORD) { + if (perf_evsel__write_stat_event(counter, cpu, thread, count)) { + pr_err("failed to write stat event\n"); + return -1; + } + } } } -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/