All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Stephane Eranian <eranian@google.com>,
	David Ahern <dsahern@gmail.com>, Andi Kleen <andi@firstfloor.org>
Subject: [RFC/PATCH 21/38] perf tools: Save timestamp of a map creation
Date: Fri,  2 Oct 2015 14:19:02 +0900	[thread overview]
Message-ID: <1443763159-29098-22-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1443763159-29098-1-git-send-email-namhyung@kernel.org>

It'll be used to support multiple maps on a same address like dlopen()
and/or JIT compile cases.

Cc: Stephane Eranian <eranian@google.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/dso.c         |  2 +-
 tools/perf/util/machine.c     | 29 +++++++++++++++++------------
 tools/perf/util/machine.h     |  2 +-
 tools/perf/util/map.c         | 12 +++++++-----
 tools/perf/util/map.h         |  9 ++++++---
 tools/perf/util/probe-event.c |  2 +-
 tools/perf/util/symbol-elf.c  |  2 +-
 tools/perf/util/symbol.c      |  4 ++--
 8 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 7c0c08386a1d..6cf2c0b095cf 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -859,7 +859,7 @@ struct map *dso__new_map(const char *name)
 	struct dso *dso = dso__new(name);
 
 	if (dso)
-		map = map__new2(0, dso, MAP__FUNCTION);
+		map = map__new2(0, dso, MAP__FUNCTION, 0);
 
 	return map;
 }
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 761b04b970ad..57f9aa1800a2 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -709,7 +709,7 @@ int machine__process_switch_event(struct machine *machine __maybe_unused,
 }
 
 struct map *machine__findnew_module_map(struct machine *machine, u64 start,
-					const char *filename)
+					const char *filename, u64 timestamp)
 {
 	struct map *map = NULL;
 	struct dso *dso;
@@ -727,7 +727,7 @@ struct map *machine__findnew_module_map(struct machine *machine, u64 start,
 	if (dso == NULL)
 		goto out;
 
-	map = map__new2(start, dso, MAP__FUNCTION);
+	map = map__new2(start, dso, MAP__FUNCTION, timestamp);
 	if (map == NULL)
 		goto out;
 
@@ -892,7 +892,7 @@ int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
 		struct kmap *kmap;
 		struct map *map;
 
-		machine->vmlinux_maps[type] = map__new2(start, kernel, type);
+		machine->vmlinux_maps[type] = map__new2(start, kernel, type, 0);
 		if (machine->vmlinux_maps[type] == NULL)
 			return -1;
 
@@ -1192,7 +1192,7 @@ static int machine__create_module(void *arg, const char *name, u64 start)
 	struct machine *machine = arg;
 	struct map *map;
 
-	map = machine__findnew_module_map(machine, start, name);
+	map = machine__findnew_module_map(machine, start, name, 0);
 	if (map == NULL)
 		return -1;
 
@@ -1293,7 +1293,8 @@ static bool machine__uses_kcore(struct machine *machine)
 }
 
 static int machine__process_kernel_mmap_event(struct machine *machine,
-					      union perf_event *event)
+					      union perf_event *event,
+					      u64 timestamp)
 {
 	struct map *map;
 	char kmmap_prefix[PATH_MAX];
@@ -1316,7 +1317,8 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
 	if (event->mmap.filename[0] == '/' ||
 	    (!is_kernel_mmap && event->mmap.filename[0] == '[')) {
 		map = machine__findnew_module_map(machine, event->mmap.start,
-						  event->mmap.filename);
+						  event->mmap.filename,
+						  timestamp);
 		if (map == NULL)
 			goto out_problem;
 
@@ -1404,7 +1406,7 @@ out_problem:
 
 int machine__process_mmap2_event(struct machine *machine,
 				 union perf_event *event,
-				 struct perf_sample *sample __maybe_unused)
+				 struct perf_sample *sample)
 {
 	u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
 	struct thread *thread;
@@ -1417,7 +1419,8 @@ int machine__process_mmap2_event(struct machine *machine,
 
 	if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
 	    cpumode == PERF_RECORD_MISC_KERNEL) {
-		ret = machine__process_kernel_mmap_event(machine, event);
+		ret = machine__process_kernel_mmap_event(machine, event,
+							 sample->time);
 		if (ret < 0)
 			goto out_problem;
 		return 0;
@@ -1440,7 +1443,8 @@ int machine__process_mmap2_event(struct machine *machine,
 			event->mmap2.ino_generation,
 			event->mmap2.prot,
 			event->mmap2.flags,
-			event->mmap2.filename, type, thread);
+			event->mmap2.filename, type, thread,
+			sample->time);
 
 	if (map == NULL)
 		goto out_problem_map;
@@ -1458,7 +1462,7 @@ out_problem:
 }
 
 int machine__process_mmap_event(struct machine *machine, union perf_event *event,
-				struct perf_sample *sample __maybe_unused)
+				struct perf_sample *sample)
 {
 	u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
 	struct thread *thread;
@@ -1471,7 +1475,8 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
 
 	if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
 	    cpumode == PERF_RECORD_MISC_KERNEL) {
-		ret = machine__process_kernel_mmap_event(machine, event);
+		ret = machine__process_kernel_mmap_event(machine, event,
+							 sample->time);
 		if (ret < 0)
 			goto out_problem;
 		return 0;
@@ -1491,7 +1496,7 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
 			event->mmap.len, event->mmap.pgoff,
 			event->mmap.pid, 0, 0, 0, 0, 0, 0,
 			event->mmap.filename,
-			type, thread);
+			type, thread, sample->time);
 
 	if (map == NULL)
 		goto out_problem_map;
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index f0c2cc9c90ae..98ade93f433f 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -205,7 +205,7 @@ struct symbol *machine__find_kernel_function_by_name(struct machine *machine,
 }
 
 struct map *machine__findnew_module_map(struct machine *machine, u64 start,
-					const char *filename);
+					const char *filename, u64 timestamp);
 
 int machine__load_kallsyms(struct machine *machine, const char *filename,
 			   enum map_type type, symbol_filter_t filter);
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index addd4b323027..2034127ac3f0 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -125,7 +125,7 @@ static inline bool replace_android_lib(const char *filename, char *newfilename)
 }
 
 void map__init(struct map *map, enum map_type type,
-	       u64 start, u64 end, u64 pgoff, struct dso *dso)
+	       u64 start, u64 end, u64 pgoff, struct dso *dso, u64 timestamp)
 {
 	map->type     = type;
 	map->start    = start;
@@ -138,13 +138,14 @@ void map__init(struct map *map, enum map_type type,
 	RB_CLEAR_NODE(&map->rb_node);
 	map->groups   = NULL;
 	map->erange_warned = false;
+	map->timestamp = timestamp;
 	atomic_set(&map->refcnt, 1);
 }
 
 struct map *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)
+		     enum map_type type, struct thread *thread, u64 timestamp)
 {
 	struct map *map = malloc(sizeof(*map));
 
@@ -184,7 +185,7 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
 		if (dso == NULL)
 			goto out_delete;
 
-		map__init(map, type, start, start + len, pgoff, dso);
+		map__init(map, type, start, start + len, pgoff, dso, timestamp);
 
 		if (anon || no_dso) {
 			map->map_ip = map->unmap_ip = identity__map_ip;
@@ -210,7 +211,8 @@ out_delete:
  * they are loaded) and for vmlinux, where only after we load all the
  * symbols we'll know where it starts and ends.
  */
-struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
+struct map *map__new2(u64 start, struct dso *dso, enum map_type type,
+		      u64 timestamp)
 {
 	struct map *map = calloc(1, (sizeof(*map) +
 				     (dso->kernel ? sizeof(struct kmap) : 0)));
@@ -218,7 +220,7 @@ struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
 		/*
 		 * ->end will be filled after we load all the symbols
 		 */
-		map__init(map, type, start, 0, 0, dso);
+		map__init(map, type, start, 0, 0, dso, timestamp);
 	}
 
 	return map;
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 1e3313a22d3a..858f700ea5a3 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -43,6 +43,7 @@ struct map {
 	u32			maj, min; /* only valid for MMAP2 record */
 	u64			ino;      /* only valid for MMAP2 record */
 	u64			ino_generation;/* only valid for MMAP2 record */
+	u64			timestamp;
 
 	/* ip -> dso rip */
 	u64			(*map_ip)(struct map *, u64);
@@ -143,12 +144,14 @@ typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);
 
 int arch__compare_symbol_names(const char *namea, const char *nameb);
 void map__init(struct map *map, enum map_type type,
-	       u64 start, u64 end, u64 pgoff, struct dso *dso);
+	       u64 start, u64 end, u64 pgoff, struct dso *dso, u64 timestamp);
 struct map *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__new2(u64 start, struct dso *dso, enum map_type type);
+		     char *filename, enum map_type type, struct thread *thread,
+		     u64 timestamp);
+struct map *map__new2(u64 start, struct dso *dso, enum map_type type,
+		      u64 timestamp);
 void map__delete(struct map *map);
 struct map *map__clone(struct map *map);
 
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 3010abc071ff..01ecfbfe999a 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -167,7 +167,7 @@ static struct map *kernel_get_module_map(const char *module)
 
 	/* A file path -- this is an offline module */
 	if (module && strchr(module, '/'))
-		return machine__findnew_module_map(host_machine, 0, module);
+		return machine__findnew_module_map(host_machine, 0, module, 0);
 
 	if (!module)
 		module = "kernel";
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 475d88d0a1c9..b4443bacf811 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1025,7 +1025,7 @@ int dso__load_sym(struct dso *dso, struct map *map,
 				curr_dso->long_name = dso->long_name;
 				curr_dso->long_name_len = dso->long_name_len;
 				curr_map = map__new2(start, curr_dso,
-						     map->type);
+						     map->type, map->timestamp);
 				if (curr_map == NULL) {
 					dso__put(curr_dso);
 					goto out_elf_end;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index bcda43bee4d4..ff2a298f1780 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -799,7 +799,7 @@ static int dso__split_kallsyms(struct dso *dso, struct map *map, u64 delta,
 
 			ndso->kernel = dso->kernel;
 
-			curr_map = map__new2(pos->start, ndso, map->type);
+			curr_map = map__new2(pos->start, ndso, map->type, 0);
 			if (curr_map == NULL) {
 				dso__put(ndso);
 				return -1;
@@ -1101,7 +1101,7 @@ static int kcore_mapfn(u64 start, u64 len, u64 pgoff, void *data)
 	struct kcore_mapfn_data *md = data;
 	struct map *map;
 
-	map = map__new2(start, md->dso, md->type);
+	map = map__new2(start, md->dso, md->type, 0);
 	if (map == NULL)
 		return -ENOMEM;
 
-- 
2.6.0


  parent reply	other threads:[~2015-10-02  5:24 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-02  5:18 [RFC/PATCH 00/38] perf tools: Speed-up perf report by using multi thread (v5) Namhyung Kim
2015-10-02  5:18 ` [RFC/PATCH 01/38] perf tools: Use a software dummy event to track task/mmap events Namhyung Kim
2015-10-05 12:51   ` Jiri Olsa
2015-10-06  8:31     ` Namhyung Kim
2015-10-02  5:18 ` [RFC/PATCH 02/38] perf tools: Save mmap_param.len instead of mask Namhyung Kim
2015-10-02 18:44   ` Arnaldo Carvalho de Melo
2015-10-06  8:34     ` Namhyung Kim
2015-10-08 10:17   ` Jiri Olsa
2015-10-09  6:03     ` Namhyung Kim
2015-10-12 12:42       ` Jiri Olsa
2015-10-02  5:18 ` [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist Namhyung Kim
2015-10-02 18:45   ` Arnaldo Carvalho de Melo
2015-10-05 11:29     ` Adrian Hunter
2015-10-06  9:03       ` Namhyung Kim
2015-10-06  9:26         ` Adrian Hunter
2015-10-07  9:06           ` Namhyung Kim
2015-10-08 16:07             ` Adrian Hunter
2015-10-09  7:54               ` Namhyung Kim
2015-10-06  8:56     ` Namhyung Kim
2015-10-05 13:14   ` Jiri Olsa
2015-10-06  8:40     ` Namhyung Kim
2015-10-08 10:18   ` Jiri Olsa
2015-10-02  5:18 ` [RFC/PATCH 04/38] perf tools: pass perf_mmap desc directly Namhyung Kim
2015-10-02 18:47   ` Arnaldo Carvalho de Melo
2015-10-02  5:18 ` [RFC/PATCH 05/38] perf tools: Create separate mmap for dummy tracking event Namhyung Kim
2015-10-02  5:18 ` [RFC/PATCH 06/38] perf tools: Extend perf_evlist__mmap_ex() to use track mmap Namhyung Kim
2015-10-02  5:18 ` [RFC/PATCH 07/38] perf tools: Add HEADER_DATA_INDEX feature Namhyung Kim
2015-10-02  5:18 ` [RFC/PATCH 08/38] perf tools: Handle indexed data file properly Namhyung Kim
2015-10-02  5:18 ` [RFC/PATCH 09/38] perf record: Add --index option for building index table Namhyung Kim
2015-10-02 18:58   ` Arnaldo Carvalho de Melo
2015-10-05 13:46   ` Jiri Olsa
2015-10-07  8:21     ` Namhyung Kim
2015-10-07 12:10       ` Jiri Olsa
2015-10-02  5:18 ` [RFC/PATCH 10/38] perf report: Skip dummy tracking event Namhyung Kim
2015-10-02  5:18 ` [RFC/PATCH 11/38] perf tools: Introduce thread__comm(_str)_by_time() helpers Namhyung Kim
2015-10-02  5:18 ` [RFC/PATCH 12/38] perf tools: Add a test case for thread comm handling Namhyung Kim
2015-10-02  5:18 ` [RFC/PATCH 13/38] perf tools: Use thread__comm_by_time() when adding hist entries Namhyung Kim
2015-10-02  5:18 ` [RFC/PATCH 14/38] perf tools: Convert dead thread list into rbtree Namhyung Kim
2015-10-02  5:18 ` [RFC/PATCH 15/38] perf tools: Introduce machine__find*_thread_by_time() Namhyung Kim
2015-10-08 12:20   ` Jiri Olsa
2015-10-09  6:04     ` Namhyung Kim
2015-10-02  5:18 ` [RFC/PATCH 16/38] perf tools: Add a test case for timed thread handling Namhyung Kim
2015-10-02  5:18 ` [RFC/PATCH 17/38] perf tools: Maintain map groups list in a leader thread Namhyung Kim
2015-10-08 12:51   ` Jiri Olsa
2015-10-09  6:24     ` Namhyung Kim
2015-10-08 12:58   ` Jiri Olsa
2015-10-09  6:58     ` Namhyung Kim
2015-10-12 12:43       ` Jiri Olsa
2015-10-02  5:18 ` [RFC/PATCH 18/38] perf tools: Introduce thread__find_addr_location_by_time() and friends Namhyung Kim
2015-10-12 13:35   ` Jiri Olsa
2015-10-02  5:19 ` [RFC/PATCH 19/38] perf callchain: Use " Namhyung Kim
2015-10-02  5:19 ` [RFC/PATCH 20/38] perf tools: Add a test case for timed map groups handling Namhyung Kim
2015-10-02  5:19 ` Namhyung Kim [this message]
2015-10-02  5:19 ` [RFC/PATCH 22/38] perf tools: Introduce map_groups__{insert,find}_by_time() Namhyung Kim
2015-10-02  5:19 ` [RFC/PATCH 23/38] perf tools: Use map_groups__find_addr_by_time() Namhyung Kim
2015-10-02  5:19 ` [RFC/PATCH 24/38] perf tools: Add testcase for managing maps with time Namhyung Kim
2015-10-02  5:19 ` [RFC/PATCH 25/38] perf callchain: Maintain libunwind's address space in map_groups Namhyung Kim
2015-10-02  5:19 ` [RFC/PATCH 26/38] perf session: Pass struct events stats to event processing functions Namhyung Kim
2015-10-02  5:19 ` [RFC/PATCH 27/38] perf hists: Pass hists struct to hist_entry_iter struct Namhyung Kim
2015-10-02  5:19 ` [RFC/PATCH 28/38] perf tools: Move BUILD_ID_SIZE definition to perf.h Namhyung Kim
2015-10-02  5:22 ` Namhyung Kim
2015-10-02  6:58 ` Namhyung Kim
2015-10-12 14:32   ` Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443763159-29098-22-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.