All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 00/10] perf tool: Assorted fixes
@ 2018-02-07 14:48 Jiri Olsa
  2018-02-07 14:48 ` [PATCH 01/10] tools lib symbol: Skip non-address kallsyms line Jiri Olsa
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Jiri Olsa @ 2018-02-07 14:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra

hi,
sending assorted general fixes that queued
up in my other branches.

v2 changes:
  - rebased on current perf/core
  - detailed changelog for patch 1
  - using zfree instead of free in patch 2
  - using machine__set_mmap_name function name

Also available in here:
  https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
  perf/fixes

thanks,
jirka

---
Jiri Olsa (10):
      tools lib symbol: Skip non-address kallsyms line
      perf tools: Free root_dir in machine__init error path
      perf tools: Move kernel mmap name into struct machine
      perf tools: Don't search for active kernel start in __machine__create_kernel_maps
      perf tools: Generalize machine__set_kernel_mmap function
      perf tools: Use machine__set_kernel_mmap instead of map_groups__fixup_end
      perf tools: Rename __map_groups__fixup_end to map_groups__fixup_end
      perf tools: Remove machine__load_kallsyms function
      perf tools: Do not create kernel maps in sample__resolve
      perf tools: Check if we read regular file in dso__load

 tools/lib/symbol/kallsyms.c         |   4 ++++
 tools/perf/tests/vmlinux-kallsyms.c |   2 +-
 tools/perf/util/build-id.c          |  10 +++------
 tools/perf/util/event.c             |  16 +-------------
 tools/perf/util/machine.c           | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------
 tools/perf/util/machine.h           |   6 +-----
 tools/perf/util/symbol-elf.c        |   2 +-
 tools/perf/util/symbol.c            |  20 ++++++-----------
 tools/perf/util/symbol.h            |   2 +-
 9 files changed, 86 insertions(+), 123 deletions(-)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 01/10] tools lib symbol: Skip non-address kallsyms line
  2018-02-07 14:48 [PATCHv2 00/10] perf tool: Assorted fixes Jiri Olsa
@ 2018-02-07 14:48 ` Jiri Olsa
  2018-02-07 14:48 ` [PATCH 02/10] perf tools: Free root_dir in machine__init error path Jiri Olsa
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jiri Olsa @ 2018-02-07 14:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra

Adding check on failed attempt to parse the address
and skip the line parsing early in that case.

The address can be replaced with '(null)' string in
case user don't have enough permissions, like:

  $ cat /proc/kallsyms
      (null) A irq_stack_union
      (null) A __per_cpu_start
      ...

Link: http://lkml.kernel.org/n/tip-djqwni3p6lgctf6o7xhhwpmw@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/symbol/kallsyms.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/lib/symbol/kallsyms.c b/tools/lib/symbol/kallsyms.c
index 914cb8e3d40b..689b6a130dd7 100644
--- a/tools/lib/symbol/kallsyms.c
+++ b/tools/lib/symbol/kallsyms.c
@@ -38,6 +38,10 @@ int kallsyms__parse(const char *filename, void *arg,
 
 		len = hex2u64(line, &start);
 
+		/* Skip the line if we failed to parse the address. */
+		if (!len)
+			continue;
+
 		len++;
 		if (len + 2 >= line_len)
 			continue;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 02/10] perf tools: Free root_dir in machine__init error path
  2018-02-07 14:48 [PATCHv2 00/10] perf tool: Assorted fixes Jiri Olsa
  2018-02-07 14:48 ` [PATCH 01/10] tools lib symbol: Skip non-address kallsyms line Jiri Olsa
@ 2018-02-07 14:48 ` Jiri Olsa
  2018-02-07 14:48 ` [PATCH 03/10] perf tools: Move kernel mmap name into struct machine Jiri Olsa
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jiri Olsa @ 2018-02-07 14:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra

Freeing root_dir in machine__init error path.

Link: http://lkml.kernel.org/n/tip-ng92slsanexqw7h1d6sadnj7@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/machine.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index b05a67464c03..c976384f9022 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -50,6 +50,8 @@ static void machine__threads_init(struct machine *machine)
 
 int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
 {
+	int err = -ENOMEM;
+
 	memset(machine, 0, sizeof(*machine));
 	map_groups__init(&machine->kmaps, machine);
 	RB_CLEAR_NODE(&machine->rb_node);
@@ -79,7 +81,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
 		char comm[64];
 
 		if (thread == NULL)
-			return -ENOMEM;
+			goto out;
 
 		snprintf(comm, sizeof(comm), "[guest/%d]", pid);
 		thread__set_comm(thread, comm, 0);
@@ -87,7 +89,11 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
 	}
 
 	machine->current_tid = NULL;
+	err = 0;
 
+out:
+	if (err)
+		zfree(&machine->root_dir);
 	return 0;
 }
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 03/10] perf tools: Move kernel mmap name into struct machine
  2018-02-07 14:48 [PATCHv2 00/10] perf tool: Assorted fixes Jiri Olsa
  2018-02-07 14:48 ` [PATCH 01/10] tools lib symbol: Skip non-address kallsyms line Jiri Olsa
  2018-02-07 14:48 ` [PATCH 02/10] perf tools: Free root_dir in machine__init error path Jiri Olsa
@ 2018-02-07 14:48 ` Jiri Olsa
  2018-02-07 14:48 ` [PATCH 04/10] perf tools: Don't search for active kernel start in __machine__create_kernel_maps Jiri Olsa
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jiri Olsa @ 2018-02-07 14:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra

It simplifies and centralizes the code. The kernel mmap
name is set for machine type, which we know from the
beginning, so there's no reason to generate it every time
we need it.

Link: http://lkml.kernel.org/n/tip-2fx7kxxdc5zcm6990cq2mday@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/build-id.c | 10 +++----
 tools/perf/util/event.c    |  5 +---
 tools/perf/util/machine.c  | 67 +++++++++++++++++++++++-----------------------
 tools/perf/util/machine.h  |  3 +--
 tools/perf/util/symbol.c   |  3 +--
 5 files changed, 39 insertions(+), 49 deletions(-)

diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 7f8553630c4d..537eadd81914 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -316,7 +316,6 @@ static int machine__write_buildid_table(struct machine *machine,
 					struct feat_fd *fd)
 {
 	int err = 0;
-	char nm[PATH_MAX];
 	struct dso *pos;
 	u16 kmisc = PERF_RECORD_MISC_KERNEL,
 	    umisc = PERF_RECORD_MISC_USER;
@@ -338,9 +337,8 @@ static int machine__write_buildid_table(struct machine *machine,
 			name = pos->short_name;
 			name_len = pos->short_name_len;
 		} else if (dso__is_kcore(pos)) {
-			machine__mmap_name(machine, nm, sizeof(nm));
-			name = nm;
-			name_len = strlen(nm);
+			name = machine->mmap_name;
+			name_len = strlen(name);
 		} else {
 			name = pos->long_name;
 			name_len = pos->long_name_len;
@@ -813,12 +811,10 @@ static int dso__cache_build_id(struct dso *dso, struct machine *machine)
 	bool is_kallsyms = dso__is_kallsyms(dso);
 	bool is_vdso = dso__is_vdso(dso);
 	const char *name = dso->long_name;
-	char nm[PATH_MAX];
 
 	if (dso__is_kcore(dso)) {
 		is_kallsyms = true;
-		machine__mmap_name(machine, nm, sizeof(nm));
-		name = nm;
+		name = machine->mmap_name;
 	}
 	return build_id_cache__add_b(dso->build_id, sizeof(dso->build_id), name,
 				     dso->nsinfo, is_kallsyms, is_vdso);
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 44e603c27944..4644e751a3e3 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -894,8 +894,6 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
 				       struct machine *machine)
 {
 	size_t size;
-	const char *mmap_name;
-	char name_buff[PATH_MAX];
 	struct map *map = machine__kernel_map(machine);
 	struct kmap *kmap;
 	int err;
@@ -918,7 +916,6 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
 		return -1;
 	}
 
-	mmap_name = machine__mmap_name(machine, name_buff, sizeof(name_buff));
 	if (machine__is_host(machine)) {
 		/*
 		 * kernel uses PERF_RECORD_MISC_USER for user space maps,
@@ -931,7 +928,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
 
 	kmap = map__kmap(map);
 	size = snprintf(event->mmap.filename, sizeof(event->mmap.filename),
-			"%s%s", mmap_name, kmap->ref_reloc_sym->name) + 1;
+			"%s%s", machine->mmap_name, kmap->ref_reloc_sym->name) + 1;
 	size = PERF_ALIGN(size, sizeof(u64));
 	event->mmap.header.type = PERF_RECORD_MMAP;
 	event->mmap.header.size = (sizeof(event->mmap) -
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index c976384f9022..b1f1961b13f4 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -48,6 +48,27 @@ static void machine__threads_init(struct machine *machine)
 	}
 }
 
+static int machine__set_mmap_name(struct machine *machine)
+{
+	if (machine__is_host(machine)) {
+		if (symbol_conf.vmlinux_name)
+			machine->mmap_name = strdup(symbol_conf.vmlinux_name);
+		else
+			machine->mmap_name = strdup("[kernel.kallsyms]");
+	} else if (machine__is_default_guest(machine)) {
+		if (symbol_conf.default_guest_vmlinux_name)
+			machine->mmap_name = strdup(symbol_conf.default_guest_vmlinux_name);
+		else
+			machine->mmap_name = strdup("[guest.kernel.kallsyms]");
+	} else {
+		if (asprintf(&machine->mmap_name, "[guest.kernel.kallsyms.%d]",
+			 machine->pid) < 0)
+			machine->mmap_name = NULL;
+	}
+
+	return machine->mmap_name ? 0 : -ENOMEM;
+}
+
 int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
 {
 	int err = -ENOMEM;
@@ -75,6 +96,9 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
 	if (machine->root_dir == NULL)
 		return -ENOMEM;
 
+	if (machine__set_mmap_name(machine))
+		goto out;
+
 	if (pid != HOST_KERNEL_ID) {
 		struct thread *thread = machine__findnew_thread(machine, -1,
 								pid);
@@ -92,8 +116,10 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
 	err = 0;
 
 out:
-	if (err)
+	if (err) {
 		zfree(&machine->root_dir);
+		zfree(&machine->mmap_name);
+	}
 	return 0;
 }
 
@@ -186,6 +212,7 @@ void machine__exit(struct machine *machine)
 	dsos__exit(&machine->dsos);
 	machine__exit_vdso(machine);
 	zfree(&machine->root_dir);
+	zfree(&machine->mmap_name);
 	zfree(&machine->current_tid);
 
 	for (i = 0; i < THREADS__TABLE_SIZE; i++) {
@@ -328,20 +355,6 @@ void machines__process_guests(struct machines *machines,
 	}
 }
 
-char *machine__mmap_name(struct machine *machine, char *bf, size_t size)
-{
-	if (machine__is_host(machine))
-		snprintf(bf, size, "[%s]", "kernel.kallsyms");
-	else if (machine__is_default_guest(machine))
-		snprintf(bf, size, "[%s]", "guest.kernel.kallsyms");
-	else {
-		snprintf(bf, size, "[%s.%d]", "guest.kernel.kallsyms",
-			 machine->pid);
-	}
-
-	return bf;
-}
-
 void machines__set_id_hdr_size(struct machines *machines, u16 id_hdr_size)
 {
 	struct rb_node *node;
@@ -777,25 +790,13 @@ size_t machine__fprintf(struct machine *machine, FILE *fp)
 
 static struct dso *machine__get_kernel(struct machine *machine)
 {
-	const char *vmlinux_name = NULL;
+	const char *vmlinux_name = machine->mmap_name;
 	struct dso *kernel;
 
 	if (machine__is_host(machine)) {
-		vmlinux_name = symbol_conf.vmlinux_name;
-		if (!vmlinux_name)
-			vmlinux_name = DSO__NAME_KALLSYMS;
-
 		kernel = machine__findnew_kernel(machine, vmlinux_name,
 						 "[kernel]", DSO_TYPE_KERNEL);
 	} else {
-		char bf[PATH_MAX];
-
-		if (machine__is_default_guest(machine))
-			vmlinux_name = symbol_conf.default_guest_vmlinux_name;
-		if (!vmlinux_name)
-			vmlinux_name = machine__mmap_name(machine, bf,
-							  sizeof(bf));
-
 		kernel = machine__findnew_kernel(machine, vmlinux_name,
 						 "[guest.kernel]",
 						 DSO_TYPE_GUEST_KERNEL);
@@ -1295,7 +1296,6 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
 					      union perf_event *event)
 {
 	struct map *map;
-	char kmmap_prefix[PATH_MAX];
 	enum dso_kernel_type kernel_type;
 	bool is_kernel_mmap;
 
@@ -1303,15 +1303,14 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
 	if (machine__uses_kcore(machine))
 		return 0;
 
-	machine__mmap_name(machine, kmmap_prefix, sizeof(kmmap_prefix));
 	if (machine__is_host(machine))
 		kernel_type = DSO_TYPE_KERNEL;
 	else
 		kernel_type = DSO_TYPE_GUEST_KERNEL;
 
 	is_kernel_mmap = memcmp(event->mmap.filename,
-				kmmap_prefix,
-				strlen(kmmap_prefix) - 1) == 0;
+				machine->mmap_name,
+				strlen(machine->mmap_name) - 1) == 0;
 	if (event->mmap.filename[0] == '/' ||
 	    (!is_kernel_mmap && event->mmap.filename[0] == '[')) {
 		map = machine__findnew_module_map(machine, event->mmap.start,
@@ -1322,7 +1321,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
 		map->end = map->start + event->mmap.len;
 	} else if (is_kernel_mmap) {
 		const char *symbol_name = (event->mmap.filename +
-				strlen(kmmap_prefix));
+				strlen(machine->mmap_name));
 		/*
 		 * Should be there already, from the build-id table in
 		 * the header.
@@ -1363,7 +1362,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
 		up_read(&machine->dsos.lock);
 
 		if (kernel == NULL)
-			kernel = machine__findnew_dso(machine, kmmap_prefix);
+			kernel = machine__findnew_dso(machine, machine->mmap_name);
 		if (kernel == NULL)
 			goto out_problem;
 
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 5ce860b64c74..cb0a20f3a96b 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -43,6 +43,7 @@ struct machine {
 	bool		  comm_exec;
 	bool		  kptr_restrict_warned;
 	char		  *root_dir;
+	char		  *mmap_name;
 	struct threads    threads[THREADS__TABLE_SIZE];
 	struct vdso_info  *vdso_info;
 	struct perf_env   *env;
@@ -142,8 +143,6 @@ struct machine *machines__find(struct machines *machines, pid_t pid);
 struct machine *machines__findnew(struct machines *machines, pid_t pid);
 
 void machines__set_id_hdr_size(struct machines *machines, u16 id_hdr_size);
-char *machine__mmap_name(struct machine *machine, char *bf, size_t size);
-
 void machines__set_comm_exec(struct machines *machines, bool comm_exec);
 
 struct machine *machine__new_host(void);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index cc065d4bfafc..dcb81176669a 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1960,8 +1960,7 @@ static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map)
 		pr_debug("Using %s for symbols\n", kallsyms_filename);
 	if (err > 0 && !dso__is_kcore(dso)) {
 		dso->binary_type = DSO_BINARY_TYPE__GUEST_KALLSYMS;
-		machine__mmap_name(machine, path, sizeof(path));
-		dso__set_long_name(dso, strdup(path), true);
+		dso__set_long_name(dso, machine->mmap_name, false);
 		map__fixup_start(map);
 		map__fixup_end(map);
 	}
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 04/10] perf tools: Don't search for active kernel start in __machine__create_kernel_maps
  2018-02-07 14:48 [PATCHv2 00/10] perf tool: Assorted fixes Jiri Olsa
                   ` (2 preceding siblings ...)
  2018-02-07 14:48 ` [PATCH 03/10] perf tools: Move kernel mmap name into struct machine Jiri Olsa
@ 2018-02-07 14:48 ` Jiri Olsa
  2018-02-07 14:48 ` [PATCH 05/10] perf tools: Generalize machine__set_kernel_mmap function Jiri Olsa
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jiri Olsa @ 2018-02-07 14:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra

We should not search for kernel start address in
__machine__create_kernel_maps function, because it's being
used in 'report' code path, where we are interested in kernel
MMAP data address instead of in current kernel address

The __machine__create_kernel_maps serves purely for creating
the machines kernel maps and setting up the kmap group. The
report code path then sets the address based on the data from
kernel MMAP event in machine__set_kernel_mmap function.

The kallsyms search address logic is used for test code, that
calls machine__create_kernel_maps to get current maps and calls
machine__get_running_kernel_start to get kernel starting address.

Also making __machine__create_kernel_maps static, because there's
no external user.

Link: http://lkml.kernel.org/n/tip-37lmdjzh8dwq03golnk7hgkd@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/machine.c | 6 ++----
 tools/perf/util/machine.h | 1 -
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index b1f1961b13f4..da85666f3a02 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -856,14 +856,12 @@ static int machine__get_running_kernel_start(struct machine *machine,
 	return 0;
 }
 
-int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
+static int
+__machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
 {
 	int type;
 	u64 start = 0;
 
-	if (machine__get_running_kernel_start(machine, NULL, &start))
-		return -1;
-
 	/* In case of renewal the kernel map, destroy previous one */
 	machine__destroy_kernel_maps(machine);
 
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index cb0a20f3a96b..50d587d34459 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -238,7 +238,6 @@ size_t machines__fprintf_dsos_buildid(struct machines *machines, FILE *fp,
 				     bool (skip)(struct dso *dso, int parm), int parm);
 
 void machine__destroy_kernel_maps(struct machine *machine);
-int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel);
 int machine__create_kernel_maps(struct machine *machine);
 
 int machines__create_kernel_maps(struct machines *machines, pid_t pid);
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 05/10] perf tools: Generalize machine__set_kernel_mmap function
  2018-02-07 14:48 [PATCHv2 00/10] perf tool: Assorted fixes Jiri Olsa
                   ` (3 preceding siblings ...)
  2018-02-07 14:48 ` [PATCH 04/10] perf tools: Don't search for active kernel start in __machine__create_kernel_maps Jiri Olsa
@ 2018-02-07 14:48 ` Jiri Olsa
  2018-02-07 14:48 ` [PATCH 06/10] perf tools: Use machine__set_kernel_mmap instead of map_groups__fixup_end Jiri Olsa
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jiri Olsa @ 2018-02-07 14:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra

So it could be called without event object, just with start
and end values. It will be used in following patch.

Link: http://lkml.kernel.org/n/tip-u4hu7m5fmwwsscy6ki70hhq6@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/machine.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index da85666f3a02..7563b750137d 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1260,15 +1260,15 @@ int machine__create_kernel_maps(struct machine *machine)
 	return 0;
 }
 
-static void machine__set_kernel_mmap_len(struct machine *machine,
-					 union perf_event *event)
+static void machine__set_kernel_mmap(struct machine *machine,
+				     u64 start, u64 end)
 {
 	int i;
 
 	for (i = 0; i < MAP__NR_TYPES; i++) {
-		machine->vmlinux_maps[i]->start = event->mmap.start;
-		machine->vmlinux_maps[i]->end   = (event->mmap.start +
-						   event->mmap.len);
+		machine->vmlinux_maps[i]->start = start;
+		machine->vmlinux_maps[i]->end   = end;
+
 		/*
 		 * Be a bit paranoid here, some perf.data file came with
 		 * a zero sized synthesized MMAP event for the kernel.
@@ -1373,7 +1373,8 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
 		if (strstr(kernel->long_name, "vmlinux"))
 			dso__set_short_name(kernel, "[kernel.vmlinux]", false);
 
-		machine__set_kernel_mmap_len(machine, event);
+		machine__set_kernel_mmap(machine, event->mmap.start,
+					 event->mmap.start + event->mmap.len);
 
 		/*
 		 * Avoid using a zero address (kptr_restrict) for the ref reloc
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 06/10] perf tools: Use machine__set_kernel_mmap instead of map_groups__fixup_end
  2018-02-07 14:48 [PATCHv2 00/10] perf tool: Assorted fixes Jiri Olsa
                   ` (4 preceding siblings ...)
  2018-02-07 14:48 ` [PATCH 05/10] perf tools: Generalize machine__set_kernel_mmap function Jiri Olsa
@ 2018-02-07 14:48 ` Jiri Olsa
  2018-02-08  0:34   ` Namhyung Kim
  2018-02-07 14:48 ` [PATCH 07/10] perf tools: Rename __map_groups__fixup_end to map_groups__fixup_end Jiri Olsa
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Jiri Olsa @ 2018-02-07 14:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra

The machine__set_kernel_mmap does the same job as map_groups__fixup_end
when used on kernel maps within machine__create_kernel_maps call.

This way we can also remove map_groups__fixup_end function, because there's
no user to it. Also moving machine__set_kernel_mmap up in code, so we don't
need forward declaration.

Link: http://lkml.kernel.org/n/tip-9kqrs3bsojwe4ktwpnkxc6g4@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/machine.c | 49 ++++++++++++++++++-----------------------------
 1 file changed, 19 insertions(+), 30 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 7563b750137d..49ebd451151a 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1028,13 +1028,6 @@ int machine__load_vmlinux_path(struct machine *machine, enum map_type type)
 	return ret;
 }
 
-static void map_groups__fixup_end(struct map_groups *mg)
-{
-	int i;
-	for (i = 0; i < MAP__NR_TYPES; ++i)
-		__map_groups__fixup_end(mg, i);
-}
-
 static char *get_kernel_version(const char *root_dir)
 {
 	char version[PATH_MAX];
@@ -1220,6 +1213,24 @@ static int machine__create_modules(struct machine *machine)
 	return 0;
 }
 
+static void machine__set_kernel_mmap(struct machine *machine,
+				     u64 start, u64 end)
+{
+	int i;
+
+	for (i = 0; i < MAP__NR_TYPES; i++) {
+		machine->vmlinux_maps[i]->start = start;
+		machine->vmlinux_maps[i]->end   = end;
+
+		/*
+		 * Be a bit paranoid here, some perf.data file came with
+		 * a zero sized synthesized MMAP event for the kernel.
+		 */
+		if (machine->vmlinux_maps[i]->end == 0)
+			machine->vmlinux_maps[i]->end = ~0ULL;
+	}
+}
+
 int machine__create_kernel_maps(struct machine *machine)
 {
 	struct dso *kernel = machine__get_kernel(machine);
@@ -1244,11 +1255,6 @@ int machine__create_kernel_maps(struct machine *machine)
 				 "continuing anyway...\n", machine->pid);
 	}
 
-	/*
-	 * Now that we have all the maps created, just set the ->end of them:
-	 */
-	map_groups__fixup_end(&machine->kmaps);
-
 	if (!machine__get_running_kernel_start(machine, &name, &addr)) {
 		if (name &&
 		    maps__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, name, addr)) {
@@ -1257,27 +1263,10 @@ int machine__create_kernel_maps(struct machine *machine)
 		}
 	}
 
+	machine__set_kernel_mmap(machine, addr, 0);
 	return 0;
 }
 
-static void machine__set_kernel_mmap(struct machine *machine,
-				     u64 start, u64 end)
-{
-	int i;
-
-	for (i = 0; i < MAP__NR_TYPES; i++) {
-		machine->vmlinux_maps[i]->start = start;
-		machine->vmlinux_maps[i]->end   = end;
-
-		/*
-		 * Be a bit paranoid here, some perf.data file came with
-		 * a zero sized synthesized MMAP event for the kernel.
-		 */
-		if (machine->vmlinux_maps[i]->end == 0)
-			machine->vmlinux_maps[i]->end = ~0ULL;
-	}
-}
-
 static bool machine__uses_kcore(struct machine *machine)
 {
 	struct dso *dso;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 07/10] perf tools: Rename __map_groups__fixup_end to map_groups__fixup_end
  2018-02-07 14:48 [PATCHv2 00/10] perf tool: Assorted fixes Jiri Olsa
                   ` (5 preceding siblings ...)
  2018-02-07 14:48 ` [PATCH 06/10] perf tools: Use machine__set_kernel_mmap instead of map_groups__fixup_end Jiri Olsa
@ 2018-02-07 14:48 ` Jiri Olsa
  2018-02-07 14:48 ` [PATCH 08/10] perf tools: Remove machine__load_kallsyms function Jiri Olsa
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Jiri Olsa @ 2018-02-07 14:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra

There's no need to keep the '__' prefix now when there's
map_groups__fixup_end function gone.

Link: http://lkml.kernel.org/n/tip-xq9wpm97spnpaxfjhaz1a03n@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/machine.c    | 2 +-
 tools/perf/util/symbol-elf.c | 2 +-
 tools/perf/util/symbol.c     | 2 +-
 tools/perf/util/symbol.h     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 49ebd451151a..a02242eb25a1 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1005,7 +1005,7 @@ int __machine__load_kallsyms(struct machine *machine, const char *filename,
 		 * kernel, with modules between them, fixup the end of all
 		 * sections.
 		 */
-		__map_groups__fixup_end(&machine->kmaps, type);
+		map_groups__fixup_end(&machine->kmaps, type);
 	}
 
 	return ret;
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 2de770511e70..6d1e4dc2709f 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1124,7 +1124,7 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 			 * We need to fixup this here too because we create new
 			 * maps here, for things like vsyscall sections.
 			 */
-			__map_groups__fixup_end(kmaps, map->type);
+			map_groups__fixup_end(kmaps, map->type);
 		}
 	}
 	err = nr;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index dcb81176669a..fe15dafaef66 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -228,7 +228,7 @@ void symbols__fixup_end(struct rb_root *symbols)
 		curr->end = roundup(curr->start, 4096) + 4096;
 }
 
-void __map_groups__fixup_end(struct map_groups *mg, enum map_type type)
+void map_groups__fixup_end(struct map_groups *mg, enum map_type type)
 {
 	struct maps *maps = &mg->maps[type];
 	struct map *next, *curr;
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 0563f33c1eb3..cf955f1d1718 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -316,7 +316,7 @@ void __symbols__insert(struct rb_root *symbols, struct symbol *sym, bool kernel)
 void symbols__insert(struct rb_root *symbols, struct symbol *sym);
 void symbols__fixup_duplicate(struct rb_root *symbols);
 void symbols__fixup_end(struct rb_root *symbols);
-void __map_groups__fixup_end(struct map_groups *mg, enum map_type type);
+void map_groups__fixup_end(struct map_groups *mg, enum map_type type);
 
 typedef int (*mapfn_t)(u64 start, u64 len, u64 pgoff, void *data);
 int file__read_maps(int fd, bool exe, mapfn_t mapfn, void *data,
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 08/10] perf tools: Remove machine__load_kallsyms function
  2018-02-07 14:48 [PATCHv2 00/10] perf tool: Assorted fixes Jiri Olsa
                   ` (6 preceding siblings ...)
  2018-02-07 14:48 ` [PATCH 07/10] perf tools: Rename __map_groups__fixup_end to map_groups__fixup_end Jiri Olsa
@ 2018-02-07 14:48 ` Jiri Olsa
  2018-02-07 14:48 ` [PATCH 09/10] perf tools: Do not create kernel maps in sample__resolve Jiri Olsa
  2018-02-07 14:48 ` [PATCH 10/10] perf tools: Check if we read regular file in dso__load Jiri Olsa
  9 siblings, 0 replies; 13+ messages in thread
From: Jiri Olsa @ 2018-02-07 14:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra

And replacing it with __machine__load_kallsyms function.

The current machine__load_kallsyms function has no caller,
so replacing it directly with __machine__load_kallsyms.
Also removing the no_kcore argument as it was always called
with true value.

Link: http://lkml.kernel.org/n/tip-kj9bpn6v213n6vaoe6ryxv2q@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/tests/vmlinux-kallsyms.c |  2 +-
 tools/perf/util/machine.c           | 14 ++++----------
 tools/perf/util/machine.h           |  2 --
 3 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index f6789fb029d6..58349297f9fb 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -56,7 +56,7 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest
 	 * be compacted against the list of modules found in the "vmlinux"
 	 * code and with the one got from /proc/modules from the "kallsyms" code.
 	 */
-	if (__machine__load_kallsyms(&kallsyms, "/proc/kallsyms", type, true) <= 0) {
+	if (machine__load_kallsyms(&kallsyms, "/proc/kallsyms", type) <= 0) {
 		pr_debug("dso__load_kallsyms ");
 		goto out;
 	}
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index a02242eb25a1..9074c63c056e 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -151,7 +151,7 @@ struct machine *machine__new_kallsyms(void)
 	 *    ask for not using the kcore parsing code, once this one is fixed
 	 *    to create a map per module.
 	 */
-	if (machine && __machine__load_kallsyms(machine, "/proc/kallsyms", MAP__FUNCTION, true) <= 0) {
+	if (machine && machine__load_kallsyms(machine, "/proc/kallsyms", MAP__FUNCTION) <= 0) {
 		machine__delete(machine);
 		machine = NULL;
 	}
@@ -992,11 +992,11 @@ int machines__create_kernel_maps(struct machines *machines, pid_t pid)
 	return machine__create_kernel_maps(machine);
 }
 
-int __machine__load_kallsyms(struct machine *machine, const char *filename,
-			     enum map_type type, bool no_kcore)
+int machine__load_kallsyms(struct machine *machine, const char *filename,
+			     enum map_type type)
 {
 	struct map *map = machine__kernel_map(machine);
-	int ret = __dso__load_kallsyms(map->dso, filename, map, no_kcore);
+	int ret = __dso__load_kallsyms(map->dso, filename, map, true);
 
 	if (ret > 0) {
 		dso__set_loaded(map->dso, type);
@@ -1011,12 +1011,6 @@ int __machine__load_kallsyms(struct machine *machine, const char *filename,
 	return ret;
 }
 
-int machine__load_kallsyms(struct machine *machine, const char *filename,
-			   enum map_type type)
-{
-	return __machine__load_kallsyms(machine, filename, type, false);
-}
-
 int machine__load_vmlinux_path(struct machine *machine, enum map_type type)
 {
 	struct map *map = machine__kernel_map(machine);
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 50d587d34459..66cc200ef86f 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -225,8 +225,6 @@ struct map *machine__findnew_module_map(struct machine *machine, u64 start,
 					const char *filename);
 int arch__fix_module_text_start(u64 *start, const char *name);
 
-int __machine__load_kallsyms(struct machine *machine, const char *filename,
-			     enum map_type type, bool no_kcore);
 int machine__load_kallsyms(struct machine *machine, const char *filename,
 			   enum map_type type);
 int machine__load_vmlinux_path(struct machine *machine, enum map_type type);
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 09/10] perf tools: Do not create kernel maps in sample__resolve
  2018-02-07 14:48 [PATCHv2 00/10] perf tool: Assorted fixes Jiri Olsa
                   ` (7 preceding siblings ...)
  2018-02-07 14:48 ` [PATCH 08/10] perf tools: Remove machine__load_kallsyms function Jiri Olsa
@ 2018-02-07 14:48 ` Jiri Olsa
  2018-02-07 14:48 ` [PATCH 10/10] perf tools: Check if we read regular file in dso__load Jiri Olsa
  9 siblings, 0 replies; 13+ messages in thread
From: Jiri Olsa @ 2018-02-07 14:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra

There's no need for kernel maps to be allocated at this
point - sample processing.

We search for kernel maps using the kernel map_groups in
machine::kmaps which is static. If vmlinux maps for any
reason still don't exist, the search correctly fails
because they are not in the map group.

Link: http://lkml.kernel.org/n/tip-f1swg55ooc3sihcvadgzkw1z@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/event.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 4644e751a3e3..f0a6cbd033cc 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1588,17 +1588,6 @@ int machine__resolve(struct machine *machine, struct addr_location *al,
 		return -1;
 
 	dump_printf(" ... thread: %s:%d\n", thread__comm_str(thread), thread->tid);
-	/*
-	 * Have we already created the kernel maps for this machine?
-	 *
-	 * This should have happened earlier, when we processed the kernel MMAP
-	 * events, but for older perf.data files there was no such thing, so do
-	 * it now.
-	 */
-	if (sample->cpumode == PERF_RECORD_MISC_KERNEL &&
-	    machine__kernel_map(machine) == NULL)
-		machine__create_kernel_maps(machine);
-
 	thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, sample->ip, al);
 	dump_printf(" ...... dso: %s\n",
 		    al->map ? al->map->dso->long_name :
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 10/10] perf tools: Check if we read regular file in dso__load
  2018-02-07 14:48 [PATCHv2 00/10] perf tool: Assorted fixes Jiri Olsa
                   ` (8 preceding siblings ...)
  2018-02-07 14:48 ` [PATCH 09/10] perf tools: Do not create kernel maps in sample__resolve Jiri Olsa
@ 2018-02-07 14:48 ` Jiri Olsa
  9 siblings, 0 replies; 13+ messages in thread
From: Jiri Olsa @ 2018-02-07 14:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Alexander Shishkin,
	Peter Zijlstra

Current code in dso__load calls the is_regular_file function,
but it checks its return value only after calling symsrc__init.

That can make symsrc__init block in elf_* functions on reading
the file if the file happens to be device and not regular one.

Make the check before calling symsrc__init.

Link: http://lkml.kernel.org/n/tip-qm0sl764xzwvzgz0abqt6m46@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/symbol.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index fe15dafaef66..ea002b27b39d 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1580,9 +1580,7 @@ int dso__load(struct dso *dso, struct map *map)
 	for (i = 0; i < DSO_BINARY_TYPE__SYMTAB_CNT; i++) {
 		struct symsrc *ss = &ss_[ss_pos];
 		bool next_slot = false;
-		bool is_reg;
 		bool nsexit;
-		int sirc;
 
 		enum dso_binary_type symtab_type = binary_type_symtab[i];
 
@@ -1599,18 +1597,15 @@ int dso__load(struct dso *dso, struct map *map)
 		if (nsexit)
 			nsinfo__mountns_exit(&nsc);
 
-		is_reg = is_regular_file(name);
-		sirc = symsrc__init(ss, dso, name, symtab_type);
+		if (!is_regular_file(name))
+			continue;
+
+		if (symsrc__init(ss, dso, name, symtab_type) < 0)
+			continue;
 
 		if (nsexit)
 			nsinfo__mountns_enter(dso->nsinfo, &nsc);
 
-		if (!is_reg || sirc < 0) {
-			if (sirc >= 0)
-				symsrc__destroy(ss);
-			continue;
-		}
-
 		if (!syms_ss && symsrc__has_symtab(ss)) {
 			syms_ss = ss;
 			next_slot = true;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 06/10] perf tools: Use machine__set_kernel_mmap instead of map_groups__fixup_end
  2018-02-07 14:48 ` [PATCH 06/10] perf tools: Use machine__set_kernel_mmap instead of map_groups__fixup_end Jiri Olsa
@ 2018-02-08  0:34   ` Namhyung Kim
  2018-02-08  8:56     ` Jiri Olsa
  0 siblings, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2018-02-08  0:34 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, lkml, Ingo Molnar, David Ahern,
	Alexander Shishkin, Peter Zijlstra, kernel-team

Hi Jiri,

On Wed, Feb 07, 2018 at 03:48:34PM +0100, Jiri Olsa wrote:
> The machine__set_kernel_mmap does the same job as map_groups__fixup_end
> when used on kernel maps within machine__create_kernel_maps call.

I'm not sure.  Modules have end address after machine__create_module()
but vmlinux_maps is not.  So map_groups__fixup() will set the end of
vmlinux_maps but with this change it will have ~0ULL.

Thanks,
Namhyung


> 
> This way we can also remove map_groups__fixup_end function, because there's
> no user to it. Also moving machine__set_kernel_mmap up in code, so we don't
> need forward declaration.
> 
> Link: http://lkml.kernel.org/n/tip-9kqrs3bsojwe4ktwpnkxc6g4@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/util/machine.c | 49 ++++++++++++++++++-----------------------------
>  1 file changed, 19 insertions(+), 30 deletions(-)
> 
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 7563b750137d..49ebd451151a 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -1028,13 +1028,6 @@ int machine__load_vmlinux_path(struct machine *machine, enum map_type type)
>  	return ret;
>  }
>  
> -static void map_groups__fixup_end(struct map_groups *mg)
> -{
> -	int i;
> -	for (i = 0; i < MAP__NR_TYPES; ++i)
> -		__map_groups__fixup_end(mg, i);
> -}
> -
>  static char *get_kernel_version(const char *root_dir)
>  {
>  	char version[PATH_MAX];
> @@ -1220,6 +1213,24 @@ static int machine__create_modules(struct machine *machine)
>  	return 0;
>  }
>  
> +static void machine__set_kernel_mmap(struct machine *machine,
> +				     u64 start, u64 end)
> +{
> +	int i;
> +
> +	for (i = 0; i < MAP__NR_TYPES; i++) {
> +		machine->vmlinux_maps[i]->start = start;
> +		machine->vmlinux_maps[i]->end   = end;
> +
> +		/*
> +		 * Be a bit paranoid here, some perf.data file came with
> +		 * a zero sized synthesized MMAP event for the kernel.
> +		 */
> +		if (machine->vmlinux_maps[i]->end == 0)
> +			machine->vmlinux_maps[i]->end = ~0ULL;
> +	}
> +}
> +
>  int machine__create_kernel_maps(struct machine *machine)
>  {
>  	struct dso *kernel = machine__get_kernel(machine);
> @@ -1244,11 +1255,6 @@ int machine__create_kernel_maps(struct machine *machine)
>  				 "continuing anyway...\n", machine->pid);
>  	}
>  
> -	/*
> -	 * Now that we have all the maps created, just set the ->end of them:
> -	 */
> -	map_groups__fixup_end(&machine->kmaps);
> -
>  	if (!machine__get_running_kernel_start(machine, &name, &addr)) {
>  		if (name &&
>  		    maps__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, name, addr)) {
> @@ -1257,27 +1263,10 @@ int machine__create_kernel_maps(struct machine *machine)
>  		}
>  	}
>  
> +	machine__set_kernel_mmap(machine, addr, 0);
>  	return 0;
>  }
>  
> -static void machine__set_kernel_mmap(struct machine *machine,
> -				     u64 start, u64 end)
> -{
> -	int i;
> -
> -	for (i = 0; i < MAP__NR_TYPES; i++) {
> -		machine->vmlinux_maps[i]->start = start;
> -		machine->vmlinux_maps[i]->end   = end;
> -
> -		/*
> -		 * Be a bit paranoid here, some perf.data file came with
> -		 * a zero sized synthesized MMAP event for the kernel.
> -		 */
> -		if (machine->vmlinux_maps[i]->end == 0)
> -			machine->vmlinux_maps[i]->end = ~0ULL;
> -	}
> -}
> -
>  static bool machine__uses_kcore(struct machine *machine)
>  {
>  	struct dso *dso;
> -- 
> 2.13.6
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 06/10] perf tools: Use machine__set_kernel_mmap instead of map_groups__fixup_end
  2018-02-08  0:34   ` Namhyung Kim
@ 2018-02-08  8:56     ` Jiri Olsa
  0 siblings, 0 replies; 13+ messages in thread
From: Jiri Olsa @ 2018-02-08  8:56 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, Ingo Molnar,
	David Ahern, Alexander Shishkin, Peter Zijlstra, kernel-team

On Thu, Feb 08, 2018 at 09:34:18AM +0900, Namhyung Kim wrote:
> Hi Jiri,
> 
> On Wed, Feb 07, 2018 at 03:48:34PM +0100, Jiri Olsa wrote:
> > The machine__set_kernel_mmap does the same job as map_groups__fixup_end
> > when used on kernel maps within machine__create_kernel_maps call.
> 
> I'm not sure.  Modules have end address after machine__create_module()
> but vmlinux_maps is not.  So map_groups__fixup() will set the end of
> vmlinux_maps but with this change it will have ~0ULL.

ugh, I missed the machine__create_modules call in there,
I'll rework and repost the patchset

thanks,
jirka

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-02-08  8:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-07 14:48 [PATCHv2 00/10] perf tool: Assorted fixes Jiri Olsa
2018-02-07 14:48 ` [PATCH 01/10] tools lib symbol: Skip non-address kallsyms line Jiri Olsa
2018-02-07 14:48 ` [PATCH 02/10] perf tools: Free root_dir in machine__init error path Jiri Olsa
2018-02-07 14:48 ` [PATCH 03/10] perf tools: Move kernel mmap name into struct machine Jiri Olsa
2018-02-07 14:48 ` [PATCH 04/10] perf tools: Don't search for active kernel start in __machine__create_kernel_maps Jiri Olsa
2018-02-07 14:48 ` [PATCH 05/10] perf tools: Generalize machine__set_kernel_mmap function Jiri Olsa
2018-02-07 14:48 ` [PATCH 06/10] perf tools: Use machine__set_kernel_mmap instead of map_groups__fixup_end Jiri Olsa
2018-02-08  0:34   ` Namhyung Kim
2018-02-08  8:56     ` Jiri Olsa
2018-02-07 14:48 ` [PATCH 07/10] perf tools: Rename __map_groups__fixup_end to map_groups__fixup_end Jiri Olsa
2018-02-07 14:48 ` [PATCH 08/10] perf tools: Remove machine__load_kallsyms function Jiri Olsa
2018-02-07 14:48 ` [PATCH 09/10] perf tools: Do not create kernel maps in sample__resolve Jiri Olsa
2018-02-07 14:48 ` [PATCH 10/10] perf tools: Check if we read regular file in dso__load Jiri Olsa

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.