lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1442931223-51708-6-git-send-email-kan.liang@intel.com>
Date:	Tue, 22 Sep 2015 10:13:38 -0400
From:	kan.liang@...el.com
To:	acme@...nel.org
Cc:	jolsa@...nel.org, a.p.zijlstra@...llo.nl, mingo@...hat.com,
	namhyung@...nel.org, ak@...ux.intel.com,
	linux-kernel@...r.kernel.org, Kan Liang <kan.liang@...el.com>
Subject: [PATCH RFC 05/10] perf,tools: record counter statistics during sampling

From: Kan Liang <kan.liang@...el.com>

Reading at the start and the end of sampling, and save the counter
statistics value to PERF_RECORD_COUNTER_READ.

Signed-off-by: Kan Liang <kan.liang@...el.com>
---
 tools/perf/builtin-record.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 142eeb3..cc8fd08 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -398,6 +398,40 @@ static struct perf_event_header finished_round_event = {
 	.type = PERF_RECORD_FINISHED_ROUND,
 };
 
+static void process_counter_read_event(struct record *rec, int id,
+				    struct perf_evsel *pos,
+				    struct perf_counts_values *count)
+{
+	union perf_event ev;
+
+	memset(&ev, 0, sizeof(ev));
+	ev.counter_read.header.type = PERF_RECORD_COUNTER_READ;
+	ev.counter_read.header.size = sizeof(ev.counter_read);
+	ev.counter_read.cpu = pos->cpus->map[id];
+	ev.counter_read.idx = pos->idx;
+	memcpy(ev.counter_read.values, count, 3 * sizeof(u64));
+
+	record__write(rec, &ev, sizeof(ev.counter_read));
+}
+
+static void perf_read_counter(struct record *rec)
+{
+	struct perf_evlist *evlist = rec->evlist;
+	struct perf_counts_values count;
+	struct perf_evsel *pos;
+	int cpu;
+
+	evlist__for_each(evlist, pos) {
+		if (!pos->counter_read)
+			continue;
+
+		for (cpu = 0; cpu < cpu_map__nr(pos->cpus); cpu++) {
+			if (!perf_evsel__read(pos, cpu, 0, &count))
+				process_counter_read_event(rec, cpu, pos, &count);
+		}
+	}
+}
+
 static int record__mmap_read_all(struct record *rec)
 {
 	u64 bytes_written = rec->bytes_written;
@@ -644,6 +678,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
 		perf_evlist__enable(rec->evlist);
 	}
 
+	perf_read_counter(rec);
 	auxtrace_snapshot_enabled = 1;
 	for (;;) {
 		int hits = rec->samples;
@@ -688,6 +723,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
 		 */
 		if (done && !disabled && !target__none(&opts->target)) {
 			auxtrace_snapshot_enabled = 0;
+			perf_read_counter(rec);
 			perf_evlist__disable(rec->evlist);
 			disabled = true;
 		}
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ