linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Stephane Eranian <eranian@google.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	David Ahern <dsahern@gmail.com>, Andi Kleen <ak@linux.intel.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 25/49] perf tools: Save timestamp of a map creation
Date: Tue,  9 Jan 2018 16:34:58 +0100	[thread overview]
Message-ID: <20180109153522.14116-26-jolsa@kernel.org> (raw)
In-Reply-To: <20180109153522.14116-1-jolsa@kernel.org>

From: Namhyung Kim <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>
Link: http://lkml.kernel.org/n/tip-p39jo653jdpz7uyzz7ih5xk9@git.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/dso.c        |  2 +-
 tools/perf/util/machine.c    | 25 +++++++++++++++----------
 tools/perf/util/machine.h    |  2 +-
 tools/perf/util/map.c        | 12 +++++++-----
 tools/perf/util/map.h        |  9 ++++++---
 tools/perf/util/symbol-elf.c |  2 +-
 tools/perf/util/symbol.c     |  4 ++--
 7 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index d5b6f7f5baff..41b7def15931 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -1014,7 +1014,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 26f4fc719601..b1eb0b6672df 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -807,7 +807,7 @@ static void dso__adjust_kmod_long_name(struct dso *dso, const char *filename)
 }
 
 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 = NULL;
@@ -832,7 +832,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;
 
@@ -1018,7 +1018,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;
 
@@ -1333,7 +1333,7 @@ static int machine__create_module(void *arg, const char *name, u64 start,
 	if (arch__fix_module_text_start(&start, name) < 0)
 		return -1;
 
-	map = machine__findnew_module_map(machine, start, name);
+	map = machine__findnew_module_map(machine, start, name, 0);
 	if (map == NULL)
 		return -1;
 	map->end = start + size;
@@ -1440,7 +1440,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];
@@ -1463,7 +1464,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;
 
@@ -1563,7 +1565,8 @@ int machine__process_mmap2_event(struct machine *machine,
 
 	if (sample->cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
 	    sample->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;
@@ -1586,7 +1589,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;
@@ -1621,7 +1625,8 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
 
 	if (sample->cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
 	    sample->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;
@@ -1641,7 +1646,7 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
 			event->mmap.len, event->mmap.pgoff,
 			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 8eca8af88d02..42291b8c397f 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -229,7 +229,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 arch__fix_module_text_start(u64 *start, const char *name);
 
 int __machine__load_kallsyms(struct machine *machine, const char *filename,
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index dbd8c2c3d712..991592718025 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -130,7 +130,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;
@@ -144,12 +144,13 @@ void map__init(struct map *map, enum map_type type,
 	map->groups   = NULL;
 	map->erange_warned = false;
 	refcount_set(&map->refcnt, 1);
+	map->timestamp = timestamp;
 }
 
 struct map *map__new(struct machine *machine, u64 start, u64 len,
 		     u64 pgoff, 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));
 	struct nsinfo *nsi = NULL;
@@ -203,7 +204,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;
@@ -231,7 +232,8 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
  * 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)));
@@ -239,7 +241,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 38d5954771e8..8162d084f50e 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -45,6 +45,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 @@ struct thread;
 	__map__for_each_symbol_by_name(map, sym_name, (pos))
 
 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 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/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 2de770511e70..6f283616d5fa 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1056,7 +1056,7 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 				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);
 				dso__put(curr_dso);
 				if (curr_map == NULL) {
 					goto out_elf_end;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index cc065d4bfafc..9ba402636ffe 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -843,7 +843,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;
@@ -1147,7 +1147,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.13.6

  parent reply	other threads:[~2018-01-09 15:37 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09 15:34 [RFC 00/49] perf tools: Add threads to record command Jiri Olsa
2018-01-09 15:34 ` [PATCH 01/49] perf tools: Remove perf_tool from event_op2 Jiri Olsa
2018-01-09 15:34 ` [PATCH 02/49] perf tools: Remove perf_tool from event_op3 Jiri Olsa
2018-01-09 15:34 ` [PATCH 03/49] perf tools: Pass struct perf_mmap into auxtrace_mmap__read* functions Jiri Olsa
2018-01-09 15:34 ` [PATCH 04/49] perf tools: Add struct perf_mmap arg into record__write Jiri Olsa
2018-01-09 15:34 ` [PATCH 05/49] perf tools: Use a software dummy event to track task/mmap events Jiri Olsa
2018-01-09 15:34 ` [PATCH 06/49] perf tools: Create separate mmap for dummy tracking event Jiri Olsa
2018-01-09 15:34 ` [PATCH 07/49] perf tools: Extend perf_evlist__mmap_ex() to use track mmap Jiri Olsa
2018-01-09 15:34 ` [PATCH 08/49] perf report: Skip dummy tracking event Jiri Olsa
2018-01-09 15:34 ` [PATCH 09/49] perf tools: Make copyfile_offset global Jiri Olsa
2018-01-09 15:34 ` [PATCH 10/49] perf tools: Add HEADER_DATA_INDEX feature Jiri Olsa
2018-01-09 15:34 ` [PATCH 11/49] perf tools: Handle indexed data file properly Jiri Olsa
2018-01-09 15:34 ` [PATCH 12/49] perf tools: Add perf_data__create_index function Jiri Olsa
2018-01-09 15:34 ` [PATCH 13/49] perf record: Add --index option for building index table Jiri Olsa
2018-01-09 15:34 ` [PATCH 14/49] perf tools: Introduce thread__comm(_str)_by_time() helpers Jiri Olsa
2018-01-09 15:34 ` [PATCH 15/49] perf tools: Add a test case for thread comm handling Jiri Olsa
2018-01-09 15:34 ` [PATCH 16/49] perf tools: Use thread__comm_by_time() when adding hist entries Jiri Olsa
2018-01-09 15:34 ` [PATCH 17/49] perf tools: Convert dead thread list into rbtree Jiri Olsa
2018-01-09 15:34 ` [PATCH 18/49] perf tools: Introduce machine__find*_thread_by_time() Jiri Olsa
2018-01-09 15:34 ` [PATCH 19/49] perf tools: Add thread::exited flag Jiri Olsa
2018-01-09 15:34 ` [PATCH 20/49] perf tools: Add a test case for timed thread handling Jiri Olsa
2018-01-09 15:34 ` [PATCH 21/49] perf tools: Maintain map groups list in a leader thread Jiri Olsa
2018-01-09 15:34 ` [PATCH 22/49] perf tools: Introduce thread__find_addr_location_by_time() and friends Jiri Olsa
2018-01-09 15:34 ` [PATCH 23/49] perf callchain: Use " Jiri Olsa
2018-01-09 15:34 ` [PATCH 24/49] perf tools: Add a test case for timed map groups handling Jiri Olsa
2018-01-09 15:34 ` Jiri Olsa [this message]
2018-01-09 15:34 ` [PATCH 26/49] perf tools: Introduce map_groups__{insert,find}_by_time() Jiri Olsa
2018-01-09 15:35 ` [PATCH 27/49] perf tools: Use map_groups__find_addr_by_time() Jiri Olsa
2018-01-09 15:35 ` [PATCH 28/49] perf tools: Add testcase for managing maps with time Jiri Olsa
2018-01-09 15:35 ` [PATCH 29/49] perf callchain: Maintain libunwind's address space in map_groups Jiri Olsa
2018-01-09 15:35 ` [PATCH 30/49] perf tools: Rename perf_evlist__munmap_filtered to perf_mmap__put_filtered Jiri Olsa
2018-01-09 15:35 ` [PATCH 31/49] tools lib fd array: Introduce fdarray__add_clone function Jiri Olsa
2018-01-09 15:35 ` [PATCH 32/49] tools lib subcmd: Add OPT_INTEGER_OPTARG|_SET options Jiri Olsa
2018-01-09 15:35 ` [PATCH 33/49] perf tools: Move __perf_session__process_events args into struct Jiri Olsa
2018-01-09 15:35 ` [PATCH 34/49] perf ui progress: Fix index progress display Jiri Olsa
2018-01-09 15:35 ` [PATCH 35/49] perf tools: Add threads debug variable Jiri Olsa
2018-01-09 15:35 ` [PATCH 36/49] perf tools: Add cpu into struct perf_mmap Jiri Olsa
2018-01-09 15:35 ` [PATCH 37/49] perf tools: Add perf_mmap__read_tail function Jiri Olsa
2018-01-09 15:35 ` [PATCH 38/49] perf record: Introduce struct record_thread Jiri Olsa
2018-01-09 15:35 ` [PATCH 39/49] perf record: Read record thread's mmaps Jiri Olsa
2018-01-09 15:35 ` [PATCH 40/49] perf record: Move waking into struct record Jiri Olsa
2018-01-09 15:35 ` [PATCH 41/49] perf record: Move samples into struct record_thread Jiri Olsa
2018-01-09 15:35 ` [PATCH 42/49] perf record: Move bytes_written " Jiri Olsa
2018-01-09 15:35 ` [PATCH 43/49] perf record: Add record_thread start/stop/process functions Jiri Olsa
2018-01-09 15:35 ` [PATCH 44/49] perf record: Wait for all threads being started Jiri Olsa
2018-01-09 15:35 ` [PATCH 45/49] perf record: Add --threads option Jiri Olsa
2018-01-09 15:35 ` [PATCH 46/49] perf record: Add --thread-stats option support Jiri Olsa
2018-01-09 15:35 ` [PATCH 47/49] perf record: Add maps to --thread-stats output Jiri Olsa
2018-01-09 15:35 ` [PATCH 48/49] perf record: Spread maps for --threads option Jiri Olsa
2018-01-09 15:35 ` [PATCH 49/49] perf record: Spread maps for --threads=X option Jiri Olsa
2018-03-07 14:10 ` [RFC 00/49] perf tools: Add threads to record command 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=20180109153522.14116-26-jolsa@kernel.org \
    --to=jolsa@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).