aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/map.c')
-rw-r--r--tools/perf/util/map.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 5dc60ca5a294..bdaa0a4edc17 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -146,11 +146,13 @@ void map__init(struct map *map, enum map_type type,
146} 146}
147 147
148struct map *map__new(struct machine *machine, u64 start, u64 len, 148struct map *map__new(struct machine *machine, u64 start, u64 len,
149 u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino, 149 u64 pgoff, u32 d_maj, u32 d_min, u64 ino,
150 u64 ino_gen, u32 prot, u32 flags, char *filename, 150 u64 ino_gen, u32 prot, u32 flags, char *filename,
151 enum map_type type, struct thread *thread) 151 enum map_type type, struct thread *thread)
152{ 152{
153 struct map *map = malloc(sizeof(*map)); 153 struct map *map = malloc(sizeof(*map));
154 struct nsinfo *nsi = NULL;
155 struct nsinfo *nnsi;
154 156
155 if (map != NULL) { 157 if (map != NULL) {
156 char newfilename[PATH_MAX]; 158 char newfilename[PATH_MAX];
@@ -168,9 +170,11 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
168 map->ino_generation = ino_gen; 170 map->ino_generation = ino_gen;
169 map->prot = prot; 171 map->prot = prot;
170 map->flags = flags; 172 map->flags = flags;
173 nsi = nsinfo__get(thread->nsinfo);
171 174
172 if ((anon || no_dso) && type == MAP__FUNCTION) { 175 if ((anon || no_dso) && nsi && type == MAP__FUNCTION) {
173 snprintf(newfilename, sizeof(newfilename), "/tmp/perf-%d.map", pid); 176 snprintf(newfilename, sizeof(newfilename),
177 "/tmp/perf-%d.map", nsi->pid);
174 filename = newfilename; 178 filename = newfilename;
175 } 179 }
176 180
@@ -180,6 +184,16 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
180 } 184 }
181 185
182 if (vdso) { 186 if (vdso) {
187 /* The vdso maps are always on the host and not the
188 * container. Ensure that we don't use setns to look
189 * them up.
190 */
191 nnsi = nsinfo__copy(nsi);
192 if (nnsi) {
193 nsinfo__put(nsi);
194 nnsi->need_setns = false;
195 nsi = nnsi;
196 }
183 pgoff = 0; 197 pgoff = 0;
184 dso = machine__findnew_vdso(machine, thread); 198 dso = machine__findnew_vdso(machine, thread);
185 } else 199 } else
@@ -201,11 +215,12 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
201 if (type != MAP__FUNCTION) 215 if (type != MAP__FUNCTION)
202 dso__set_loaded(dso, map->type); 216 dso__set_loaded(dso, map->type);
203 } 217 }
204 dso->nsinfo = nsinfo__get(thread->nsinfo); 218 dso->nsinfo = nsi;
205 dso__put(dso); 219 dso__put(dso);
206 } 220 }
207 return map; 221 return map;
208out_delete: 222out_delete:
223 nsinfo__put(nsi);
209 free(map); 224 free(map);
210 return NULL; 225 return NULL;
211} 226}