aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/vdso.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2014-07-23 14:23:00 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-07-23 17:14:39 -0300
commitd027b64001b21328cc92d35c6444e1a7a926ea76 (patch)
tree9a192e3b023222d6b3f22f385d5d2c9440aa1685 /tools/perf/util/vdso.c
parentperf tools: Group VDSO global variables into a structure (diff)
downloadlinux-dev-d027b64001b21328cc92d35c6444e1a7a926ea76.tar.xz
linux-dev-d027b64001b21328cc92d35c6444e1a7a926ea76.zip
perf machine: Fix the lifetime of the VDSO temporary file
The VDSO temporary file is unlinked when a session is deleted. That precludes the possibilities that there is no session or there is more than one session. Correctly the vdso belongs to the machine so put the information on 'struct machine' and get rid of the global variables. Reviewed-by: Jiri Olsa <jolsa@redhat.com> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/53CF9B14.7040408@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/vdso.c')
-rw-r--r--tools/perf/util/vdso.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c
index 75245f081b60..fdaccaf67371 100644
--- a/tools/perf/util/vdso.c
+++ b/tools/perf/util/vdso.c
@@ -28,14 +28,17 @@ struct vdso_info {
struct vdso_file vdso;
};
-static struct vdso_info vdso_info_ = {
- .vdso = {
- .temp_file_name = VDSO__TEMP_FILE_NAME,
- .dso_name = VDSO__MAP_NAME,
- },
-};
-
-static struct vdso_info *vdso_info = &vdso_info_;
+static struct vdso_info *vdso_info__new(void)
+{
+ static const struct vdso_info vdso_info_init = {
+ .vdso = {
+ .temp_file_name = VDSO__TEMP_FILE_NAME,
+ .dso_name = VDSO__MAP_NAME,
+ },
+ };
+
+ return memdup(&vdso_info_init, sizeof(vdso_info_init));
+}
static int find_vdso_map(void **start, void **end)
{
@@ -105,16 +108,32 @@ static char *get_file(struct vdso_file *vdso_file)
return vdso;
}
-void vdso__exit(void)
+void vdso__exit(struct machine *machine)
{
+ struct vdso_info *vdso_info = machine->vdso_info;
+
+ if (!vdso_info)
+ return;
+
if (vdso_info->vdso.found)
unlink(vdso_info->vdso.temp_file_name);
+
+ zfree(&machine->vdso_info);
}
struct dso *vdso__dso_findnew(struct machine *machine)
{
- struct dso *dso = dsos__find(&machine->user_dsos, VDSO__MAP_NAME, true);
+ struct vdso_info *vdso_info;
+ struct dso *dso;
+
+ if (!machine->vdso_info)
+ machine->vdso_info = vdso_info__new();
+
+ vdso_info = machine->vdso_info;
+ if (!vdso_info)
+ return NULL;
+ dso = dsos__find(&machine->user_dsos, VDSO__MAP_NAME, true);
if (!dso) {
char *file;