Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1286987 > unrolled thread

[PATCH perf/core 21/22] perf: Fix machine.vmlinux_maps to make sure to clear the old one

Started byMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
First post2015-12-09 03:20 +0100
Last post2015-12-10 09:20 +0100
Articles 4 — 4 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH perf/core 21/22] perf: Fix machine.vmlinux_maps to make sure  to clear the old one Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> - 2015-12-09 03:20 +0100
    Re: [PATCH perf/core 21/22] perf: Fix machine.vmlinux_maps to make  sure to clear the old one Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-12-09 16:30 +0100
      Re: [PATCH perf/core 21/22] perf: Fix machine.vmlinux_maps to make  sure to clear the old one "Wangnan (F)" <wangnan0@huawei.com> - 2015-12-10 04:00 +0100
    [tip:perf/core] perf machine:   Fix machine.vmlinux_maps to make sure to clear the old one tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2015-12-10 09:20 +0100

#1286987 — [PATCH perf/core 21/22] perf: Fix machine.vmlinux_maps to make sure to clear the old one

FromMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Date2015-12-09 03:20 +0100
Subject[PATCH perf/core 21/22] perf: Fix machine.vmlinux_maps to make sure to clear the old one
Message-ID<qDCwi-25G-13@gated-at.bofh.it>
Fix machine.vmlinux_maps to make sure to clear the old one
if it is renewal. This can leak the previous maps on the
vmlinux_maps because those are just overwritten.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 tools/perf/util/machine.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index bfc289c..3172aa5 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -44,6 +44,8 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
 	machine->comm_exec = false;
 	machine->kernel_start = 0;
 
+	memset(machine->vmlinux_maps, 0, sizeof(struct map *) * MAP__NR_TYPES);
+
 	machine->root_dir = strdup(root_dir);
 	if (machine->root_dir == NULL)
 		return -ENOMEM;
@@ -770,6 +772,9 @@ int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
 	enum map_type type;
 	u64 start = machine__get_running_kernel_start(machine, NULL);
 
+	/* In case of renewal the kernel map, destroy previous one */
+	machine__destroy_kernel_maps(machine);
+
 	for (type = 0; type < MAP__NR_TYPES; ++type) {
 		struct kmap *kmap;
 		struct map *map;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1287570 — Re: [PATCH perf/core 21/22] perf: Fix machine.vmlinux_maps to make sure to clear the old one

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-12-09 16:30 +0100
SubjectRe: [PATCH perf/core 21/22] perf: Fix machine.vmlinux_maps to make sure to clear the old one
Message-ID<qDOQO-1FV-11@gated-at.bofh.it>
In reply to#1286987
Em Wed, Dec 09, 2015 at 11:11:33AM +0900, Masami Hiramatsu escreveu:
> Fix machine.vmlinux_maps to make sure to clear the old one
> if it is renewal. This can leak the previous maps on the
> vmlinux_maps because those are just overwritten.
> 
> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> ---
>  tools/perf/util/machine.c |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index bfc289c..3172aa5 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -44,6 +44,8 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
>  	machine->comm_exec = false;
>  	machine->kernel_start = 0;
>  
> +	memset(machine->vmlinux_maps, 0, sizeof(struct map *) * MAP__NR_TYPES);


Simpler:

	memset(machine->vmlinux_maps, 0, sizeof(machine->vmlinux_maps));

struct machine {
 	...
	struct map *vmlinux_maps[MAP__NR_TYPES];
 	...
};

[acme@zoo c]$ cat pointer_array_sizeof.c 
#include <stdio.h>

struct foo { int *array[2]; };
struct bar { int *array[4]; };

int main(void)
{
	struct foo *foo; struct bar *bar;

	printf("sizeof(foo->array)=%zd\n", sizeof(foo->array));
	printf("sizeof(bar->array)=%zd\n", sizeof(bar->array));
	return 0;
}
[acme@zoo c]$ make pointer_array_sizeof
cc     pointer_array_sizeof.c   -o pointer_array_sizeof
[acme@zoo c]$ ./pointer_array_sizeof 
sizeof(foo->array)=16
sizeof(bar->array)=32
[acme@zoo c]$

> +
>  	machine->root_dir = strdup(root_dir);
>  	if (machine->root_dir == NULL)
>  		return -ENOMEM;
> @@ -770,6 +772,9 @@ int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
>  	enum map_type type;
>  	u64 start = machine__get_running_kernel_start(machine, NULL);
>  
> +	/* In case of renewal the kernel map, destroy previous one */
> +	machine__destroy_kernel_maps(machine);
> +
>  	for (type = 0; type < MAP__NR_TYPES; ++type) {
>  		struct kmap *kmap;
>  		struct map *map;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1288151 — Re: [PATCH perf/core 21/22] perf: Fix machine.vmlinux_maps to make sure to clear the old one

From"Wangnan (F)" <wangnan0@huawei.com>
Date2015-12-10 04:00 +0100
SubjectRe: [PATCH perf/core 21/22] perf: Fix machine.vmlinux_maps to make sure to clear the old one
Message-ID<qDZCx-8tE-1@gated-at.bofh.it>
In reply to#1287570

On 2015/12/9 23:22, Arnaldo Carvalho de Melo wrote:
> Em Wed, Dec 09, 2015 at 11:11:33AM +0900, Masami Hiramatsu escreveu:
>> Fix machine.vmlinux_maps to make sure to clear the old one
>> if it is renewal. This can leak the previous maps on the
>> vmlinux_maps because those are just overwritten.
>>
>> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
>> ---
>>   tools/perf/util/machine.c |    5 +++++
>>   1 file changed, 5 insertions(+)

This patch solves one of my problem I met when 'perf test':

http://lkml.kernel.org/g/1449541544-67621-17-git-send-email-wangnan0@huawei.com

Thank you.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1288344 — [tip:perf/core] perf machine: Fix machine.vmlinux_maps to make sure to clear the old one

Fromtip-bot for Masami Hiramatsu <tipbot@zytor.com>
Date2015-12-10 09:20 +0100
Subject[tip:perf/core] perf machine: Fix machine.vmlinux_maps to make sure to clear the old one
Message-ID<qE4Cf-3wi-35@gated-at.bofh.it>
In reply to#1286987
Commit-ID:  cc1121ab9687d660cc02f50b1a4974112f87a8e6
Gitweb:     http://git.kernel.org/tip/cc1121ab9687d660cc02f50b1a4974112f87a8e6
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Wed, 9 Dec 2015 11:11:33 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 9 Dec 2015 13:42:00 -0300

perf machine: Fix machine.vmlinux_maps to make sure to clear the old one

Fix machine.vmlinux_maps to make sure to clear the old one if it is
renewal. This can leak the previous maps on the vmlinux_maps because
those are just overwritten.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20151209021133.10245.93730.stgit@localhost.localdomain
[ Simplified the memset, same end result ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/machine.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index bfc289c..f5882b8 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -44,6 +44,8 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
 	machine->comm_exec = false;
 	machine->kernel_start = 0;
 
+	memset(machine->vmlinux_maps, 0, sizeof(machine->vmlinux_maps));
+
 	machine->root_dir = strdup(root_dir);
 	if (machine->root_dir == NULL)
 		return -ENOMEM;
@@ -770,6 +772,9 @@ int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
 	enum map_type type;
 	u64 start = machine__get_running_kernel_start(machine, NULL);
 
+	/* In case of renewal the kernel map, destroy previous one */
+	machine__destroy_kernel_maps(machine);
+
 	for (type = 0; type < MAP__NR_TYPES; ++type) {
 		struct kmap *kmap;
 		struct map *map;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web