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]
Date:	Wed, 1 Apr 2015 10:33:13 +0000
From:	Wang Nan <wangnan0@...wei.com>
To:	<acme@...nel.org>, <jolsa@...nel.org>, <namhyung@...nel.org>
CC:	<mingo@...hat.com>, <lizefan@...wei.com>, <pi3orama@....com>,
	<linux-kernel@...r.kernel.org>
Subject: [PATCH 2/4] perf tools: introduce machine_map_new to merge mmap/mmap2 processing code.

Create a machine_map_new() and merge mapping code in
machine__process_mmap2_event() and machine__process_mmap_event()
together. This patch is a preparation for following map adjustment
patches.

Signed-off-by: Wang Nan <wangnan0@...wei.com>
---
 tools/perf/util/machine.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index e335330..051883a 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1155,13 +1155,29 @@ out_problem:
 	return -1;
 }
 
+static int machine_map_new(struct machine *machine, u64 start, u64 len,
+		     u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino,
+		     u64 ino_gen, u32 prot, u32 flags, char *filename,
+		     enum map_type type, struct thread *thread)
+{
+	struct map *map;
+
+	map = map__new(machine, start, len, pgoff, pid, d_maj, d_min,
+			ino, ino_gen, prot, flags, filename, type, thread);
+
+	if (map == NULL)
+		return -1;
+
+	thread__insert_map(thread, map);
+	return 0;
+}
+
 int machine__process_mmap2_event(struct machine *machine,
 				 union perf_event *event,
 				 struct perf_sample *sample __maybe_unused)
 {
 	u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
 	struct thread *thread;
-	struct map *map;
 	enum map_type type;
 	int ret = 0;
 
@@ -1186,7 +1202,7 @@ int machine__process_mmap2_event(struct machine *machine,
 	else
 		type = MAP__FUNCTION;
 
-	map = map__new(machine, event->mmap2.start,
+	ret = machine_map_new(machine, event->mmap2.start,
 			event->mmap2.len, event->mmap2.pgoff,
 			event->mmap2.pid, event->mmap2.maj,
 			event->mmap2.min, event->mmap2.ino,
@@ -1195,10 +1211,8 @@ int machine__process_mmap2_event(struct machine *machine,
 			event->mmap2.flags,
 			event->mmap2.filename, type, thread);
 
-	if (map == NULL)
+	if (ret)
 		goto out_problem;
-
-	thread__insert_map(thread, map);
 	return 0;
 
 out_problem:
@@ -1211,7 +1225,6 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
 {
 	u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
 	struct thread *thread;
-	struct map *map;
 	enum map_type type;
 	int ret = 0;
 
@@ -1236,16 +1249,15 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
 	else
 		type = MAP__FUNCTION;
 
-	map = map__new(machine, event->mmap.start,
+	ret = machine_map_new(machine, event->mmap.start,
 			event->mmap.len, event->mmap.pgoff,
 			event->mmap.pid, 0, 0, 0, 0, 0, 0,
 			event->mmap.filename,
 			type, thread);
 
-	if (map == NULL)
+	if (ret)
 		goto out_problem;
 
-	thread__insert_map(thread, map);
 	return 0;
 
 out_problem:
-- 
1.8.3.4

--
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