Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1263300

[PATCH 08/25] perf stat record: Write stat round events on record

From Jiri Olsa <jolsa@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 08/25] perf stat record: Write stat round events on record
Date 2015-11-05 16:00 +0100
Message-ID <qrub7-81X-5@gated-at.bofh.it> (permalink)
References <qru1r-7Yg-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Writing stat round events on 'perf stat record' for
each interval round. In non interval mode we store
round event after the last stat event.

Tested-by: Kan Liang <kan.liang@intel.com>
Link: http://lkml.kernel.org/n/tip-a43rs4c6szofeuo2gjlcpm0h@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/builtin-stat.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 1567c5337941..16f6fe2f3435 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -210,6 +210,16 @@ static int process_synthesized_event(struct perf_tool *tool __maybe_unused,
 	return 0;
 }
 
+static int write_stat_round_event(u64 time, u64 type)
+{
+	return perf_event__synthesize_stat_round(NULL, time, type,
+						 process_synthesized_event,
+						 NULL);
+}
+
+#define WRITE_STAT_ROUND_EVENT(time, interval) \
+	write_stat_round_event(time, PERF_STAT_ROUND_TYPE__ ## interval)
+
 #define SID(e, x, y) xyarray__entry(e->sample_id, x, y)
 
 static int
@@ -285,6 +295,11 @@ static void process_interval(void)
 	clock_gettime(CLOCK_MONOTONIC, &ts);
 	diff_timespec(&rs, &ts, &ref_time);
 
+	if (STAT_RECORD) {
+		if (WRITE_STAT_ROUND_EVENT(rs.tv_sec * NSECS_PER_SEC + rs.tv_nsec, INTERVAL))
+			pr_err("failed to write stat round event\n");
+	}
+
 	print_counters(&rs, 0, NULL);
 }
 
@@ -1622,6 +1637,11 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (STAT_RECORD) {
 		int fd = perf_data_file__fd(&perf_stat.file);
 
+		if (!interval) {
+			if (WRITE_STAT_ROUND_EVENT(walltime_nsecs_stats.max, FINAL))
+				pr_err("failed to write stat round event\n");
+		}
+
 		if (!perf_stat.file.is_pipe) {
 			perf_stat.session->header.data_size += perf_stat.bytes_written;
 			perf_session__write_header(perf_stat.session, evsel_list, fd, true);
-- 
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHv6 00/25] perf stat: Add scripting support Jiri Olsa <jolsa@kernel.org> - 2015-11-05 15:50 +0100
  [PATCH 15/25] perf stat report: Process stat and stat round events Jiri Olsa <jolsa@kernel.org> - 2015-11-05 15:50 +0100
  [PATCH 14/25] perf stat report: Add support to initialize aggr_map from file Jiri Olsa <jolsa@kernel.org> - 2015-11-05 15:50 +0100
  [PATCH 24/25] perf script: Add python support for stat events Jiri Olsa <jolsa@kernel.org> - 2015-11-05 15:50 +0100
  [PATCH 11/25] perf stat report: Add report command Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
  [PATCH 16/25] perf stat report: Process event update events Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
  [PATCH 08/25] perf stat record: Write stat round events on record Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
  [PATCH 12/25] perf stat report: Process cpu/threads maps Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
  [PATCH 20/25] perf script: Process stat config event Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
  [PATCH 01/25] perf stat: Make stat options global Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
    [tip:perf/urgent] perf stat: Make stat options global tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-11-08 08:40 +0100
  [PATCH 03/25] perf stat record: Initialize record features Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100
  [PATCH 18/25] perf stat report: Allow to override aggr_mode Jiri Olsa <jolsa@kernel.org> - 2015-11-05 16:00 +0100

csiph-web