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-next>] [day] [month] [year] [list]
Date:	Fri,  8 Jul 2016 14:56:11 +0900
From:	Namhyung Kim <namhyung@...il.com>
To:	Steven Rostedt <rostedt@...dmis.org>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Joonsoo Kim <js1304@...il.com>,
	Namhyung Kim <namhyung@...nel.org>
Subject: [PATCH 1/2] trace-cmd: Introduce tracecmd_peek_next_data()

The tracecmd_peek_next_data() is similar to tracecmd_read_next_data()
but it doesn't consume the record.

Signed-off-by: Namhyung Kim <namhyung@...nel.org>
---
 trace-cmd.h   |  3 +++
 trace-input.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/trace-cmd.h b/trace-cmd.h
index cef2458..5798345 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -164,6 +164,9 @@ struct pevent_record *
 tracecmd_read_next_data(struct tracecmd_input *handle, int *rec_cpu);
 
 struct pevent_record *
+tracecmd_peek_next_data(struct tracecmd_input *handle, int *rec_cpu);
+
+struct pevent_record *
 tracecmd_read_at(struct tracecmd_input *handle, unsigned long long offset,
 		 int *cpu);
 struct pevent_record *
diff --git a/trace-input.c b/trace-input.c
index 2fea066..e825328 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -1787,6 +1787,49 @@ tracecmd_read_next_data(struct tracecmd_input *handle, int *rec_cpu)
 }
 
 /**
+ * tracecmd_peek_next_data - return the next record
+ * @handle: input handle to the trace.dat file
+ * @rec_cpu: return pointer to the CPU that the record belongs to
+ *
+ * This returns the next record by time. This is different than
+ * tracecmd_peek_data in that it looks at all CPUs. It does a peek
+ * at each CPU and the record with the earliest time stame is
+ * returned. If @rec_cpu is not NULL it gets the CPU id the record was
+ * on. It does not increment the CPU iterator.
+ */
+struct pevent_record *
+tracecmd_peek_next_data(struct tracecmd_input *handle, int *rec_cpu)
+{
+	unsigned long long ts;
+	struct pevent_record *record, *next_record = NULL;
+	int next_cpu;
+	int cpu;
+
+	if (rec_cpu)
+		*rec_cpu = -1;
+
+	next_cpu = -1;
+	ts = 0;
+
+	for (cpu = 0; cpu < handle->cpus; cpu++) {
+		record = tracecmd_peek_data(handle, cpu);
+		if (record && (!next_record || record->ts < ts)) {
+			ts = record->ts;
+			next_cpu = cpu;
+			next_record = record;
+		}
+	}
+
+	if (next_record) {
+		if (rec_cpu)
+			*rec_cpu = next_cpu;
+		return next_record;
+	}
+
+	return NULL;
+}
+
+/**
  * tracecmd_read_prev - read the record before the given record
  * @handle: input handle to the trace.dat file
  * @record: the record to use to find the previous record.
-- 
2.9.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ