aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/machine.c4
-rw-r--r--tools/perf/util/machine.h3
-rw-r--r--tools/perf/util/session.c2
-rw-r--r--tools/perf/util/vdso.c39
-rw-r--r--tools/perf/util/vdso.h2
5 files changed, 37 insertions, 13 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index a25f3ee1b5b3..65269b8ac186 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -8,6 +8,7 @@
8#include "sort.h" 8#include "sort.h"
9#include "strlist.h" 9#include "strlist.h"
10#include "thread.h" 10#include "thread.h"
11#include "vdso.h"
11#include <stdbool.h> 12#include <stdbool.h>
12#include <symbol/kallsyms.h> 13#include <symbol/kallsyms.h>
13#include "unwind.h" 14#include "unwind.h"
@@ -23,6 +24,8 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
23 INIT_LIST_HEAD(&machine->dead_threads); 24 INIT_LIST_HEAD(&machine->dead_threads);
24 machine->last_match = NULL; 25 machine->last_match = NULL;
25 26
27 machine->vdso_info = NULL;
28
26 machine->kmaps.machine = machine; 29 machine->kmaps.machine = machine;
27 machine->pid = pid; 30 machine->pid = pid;
28 31
@@ -105,6 +108,7 @@ void machine__exit(struct machine *machine)
105 map_groups__exit(&machine->kmaps); 108 map_groups__exit(&machine->kmaps);
106 dsos__delete(&machine->user_dsos); 109 dsos__delete(&machine->user_dsos);
107 dsos__delete(&machine->kernel_dsos); 110 dsos__delete(&machine->kernel_dsos);
111 vdso__exit(machine);
108 zfree(&machine->root_dir); 112 zfree(&machine->root_dir);
109 zfree(&machine->current_tid); 113 zfree(&machine->current_tid);
110} 114}
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 8771d0cbe9cb..b972824e6294 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -20,6 +20,8 @@ union perf_event;
20 20
21extern const char *ref_reloc_sym_names[]; 21extern const char *ref_reloc_sym_names[];
22 22
23struct vdso_info;
24
23struct machine { 25struct machine {
24 struct rb_node rb_node; 26 struct rb_node rb_node;
25 pid_t pid; 27 pid_t pid;
@@ -28,6 +30,7 @@ struct machine {
28 struct rb_root threads; 30 struct rb_root threads;
29 struct list_head dead_threads; 31 struct list_head dead_threads;
30 struct thread *last_match; 32 struct thread *last_match;
33 struct vdso_info *vdso_info;
31 struct list_head user_dsos; 34 struct list_head user_dsos;
32 struct list_head kernel_dsos; 35 struct list_head kernel_dsos;
33 struct map_groups kmaps; 36 struct map_groups kmaps;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index d3da1055239f..fab5838c06be 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -14,7 +14,6 @@
14#include "util.h" 14#include "util.h"
15#include "cpumap.h" 15#include "cpumap.h"
16#include "perf_regs.h" 16#include "perf_regs.h"
17#include "vdso.h"
18 17
19static int perf_session__open(struct perf_session *session) 18static int perf_session__open(struct perf_session *session)
20{ 19{
@@ -156,7 +155,6 @@ void perf_session__delete(struct perf_session *session)
156 if (session->file) 155 if (session->file)
157 perf_data_file__close(session->file); 156 perf_data_file__close(session->file);
158 free(session); 157 free(session);
159 vdso__exit();
160} 158}
161 159
162static int process_event_synth_tracing_data_stub(struct perf_tool *tool 160static int process_event_synth_tracing_data_stub(struct perf_tool *tool
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 {
28 struct vdso_file vdso; 28 struct vdso_file vdso;
29}; 29};
30 30
31static struct vdso_info vdso_info_ = { 31static struct vdso_info *vdso_info__new(void)
32 .vdso = { 32{
33 .temp_file_name = VDSO__TEMP_FILE_NAME, 33 static const struct vdso_info vdso_info_init = {
34 .dso_name = VDSO__MAP_NAME, 34 .vdso = {
35 }, 35 .temp_file_name = VDSO__TEMP_FILE_NAME,
36}; 36 .dso_name = VDSO__MAP_NAME,
37 37 },
38static struct vdso_info *vdso_info = &vdso_info_; 38 };
39
40 return memdup(&vdso_info_init, sizeof(vdso_info_init));
41}
39 42
40static int find_vdso_map(void **start, void **end) 43static int find_vdso_map(void **start, void **end)
41{ 44{
@@ -105,16 +108,32 @@ static char *get_file(struct vdso_file *vdso_file)
105 return vdso; 108 return vdso;
106} 109}
107 110
108void vdso__exit(void) 111void vdso__exit(struct machine *machine)
109{ 112{
113 struct vdso_info *vdso_info = machine->vdso_info;
114
115 if (!vdso_info)
116 return;
117
110 if (vdso_info->vdso.found) 118 if (vdso_info->vdso.found)
111 unlink(vdso_info->vdso.temp_file_name); 119 unlink(vdso_info->vdso.temp_file_name);
120
121 zfree(&machine->vdso_info);
112} 122}
113 123
114struct dso *vdso__dso_findnew(struct machine *machine) 124struct dso *vdso__dso_findnew(struct machine *machine)
115{ 125{
116 struct dso *dso = dsos__find(&machine->user_dsos, VDSO__MAP_NAME, true); 126 struct vdso_info *vdso_info;
127 struct dso *dso;
128
129 if (!machine->vdso_info)
130 machine->vdso_info = vdso_info__new();
131
132 vdso_info = machine->vdso_info;
133 if (!vdso_info)
134 return NULL;
117 135
136 dso = dsos__find(&machine->user_dsos, VDSO__MAP_NAME, true);
118 if (!dso) { 137 if (!dso) {
119 char *file; 138 char *file;
120 139
diff --git a/tools/perf/util/vdso.h b/tools/perf/util/vdso.h
index 9ab0738b6752..7cf1576863a4 100644
--- a/tools/perf/util/vdso.h
+++ b/tools/perf/util/vdso.h
@@ -15,6 +15,6 @@ static inline bool is_vdso_map(const char *filename)
15struct machine; 15struct machine;
16 16
17struct dso *vdso__dso_findnew(struct machine *machine); 17struct dso *vdso__dso_findnew(struct machine *machine);
18void vdso__exit(void); 18void vdso__exit(struct machine *machine);
19 19
20#endif /* __PERF_VDSO__ */ 20#endif /* __PERF_VDSO__ */