Skip to content

Commit 2a03068

Browse files
ahunter6acmel
authored andcommitted
perf tools: Pass machine to vdso__dso_findnew()
This is preparation for removing the global variables used in vdso.c and thereby fixing the lifetime of the VDSO temporary file. Reviewed-by: Jiri Olsa <[email protected]> Signed-off-by: Adrian Hunter <[email protected]> Cc: David Ahern <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 6d36345 commit 2a03068

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

tools/perf/util/machine.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ int machine__process_mmap2_event(struct machine *machine,
10951095
else
10961096
type = MAP__FUNCTION;
10971097

1098-
map = map__new(&machine->user_dsos, event->mmap2.start,
1098+
map = map__new(machine, event->mmap2.start,
10991099
event->mmap2.len, event->mmap2.pgoff,
11001100
event->mmap2.pid, event->mmap2.maj,
11011101
event->mmap2.min, event->mmap2.ino,
@@ -1145,7 +1145,7 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
11451145
else
11461146
type = MAP__FUNCTION;
11471147

1148-
map = map__new(&machine->user_dsos, event->mmap.start,
1148+
map = map__new(machine, event->mmap.start,
11491149
event->mmap.len, event->mmap.pgoff,
11501150
event->mmap.pid, 0, 0, 0, 0, 0, 0,
11511151
event->mmap.filename,

tools/perf/util/map.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "build-id.h"
1414
#include "util.h"
1515
#include "debug.h"
16+
#include "machine.h"
1617
#include <linux/string.h>
1718

1819
const char *map_type__name[MAP__NR_TYPES] = {
@@ -137,7 +138,7 @@ void map__init(struct map *map, enum map_type type,
137138
map->erange_warned = false;
138139
}
139140

140-
struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
141+
struct map *map__new(struct machine *machine, u64 start, u64 len,
141142
u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino,
142143
u64 ino_gen, u32 prot, u32 flags, char *filename,
143144
enum map_type type)
@@ -173,9 +174,9 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
173174

174175
if (vdso) {
175176
pgoff = 0;
176-
dso = vdso__dso_findnew(dsos__list);
177+
dso = vdso__dso_findnew(machine);
177178
} else
178-
dso = __dsos__findnew(dsos__list, filename);
179+
dso = __dsos__findnew(&machine->user_dsos, filename);
179180

180181
if (dso == NULL)
181182
goto out_delete;

tools/perf/util/map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);
119119

120120
void map__init(struct map *map, enum map_type type,
121121
u64 start, u64 end, u64 pgoff, struct dso *dso);
122-
struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
122+
struct map *map__new(struct machine *machine, u64 start, u64 len,
123123
u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino,
124124
u64 ino_gen, u32 prot, u32 flags,
125125
char *filename, enum map_type type);

tools/perf/util/vdso.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "vdso.h"
1212
#include "util.h"
1313
#include "symbol.h"
14+
#include "machine.h"
1415
#include "linux/string.h"
1516
#include "debug.h"
1617

@@ -90,9 +91,9 @@ void vdso__exit(void)
9091
unlink(vdso_file);
9192
}
9293

93-
struct dso *vdso__dso_findnew(struct list_head *head)
94+
struct dso *vdso__dso_findnew(struct machine *machine)
9495
{
95-
struct dso *dso = dsos__find(head, VDSO__MAP_NAME, true);
96+
struct dso *dso = dsos__find(&machine->user_dsos, VDSO__MAP_NAME, true);
9697

9798
if (!dso) {
9899
char *file;
@@ -103,7 +104,7 @@ struct dso *vdso__dso_findnew(struct list_head *head)
103104

104105
dso = dso__new(VDSO__MAP_NAME);
105106
if (dso != NULL) {
106-
dsos__add(head, dso);
107+
dsos__add(&machine->user_dsos, dso);
107108
dso__set_long_name(dso, file, false);
108109
}
109110
}

tools/perf/util/vdso.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ static inline bool is_vdso_map(const char *filename)
1212
return !strcmp(filename, VDSO__MAP_NAME);
1313
}
1414

15-
struct dso *vdso__dso_findnew(struct list_head *head);
15+
struct machine;
16+
17+
struct dso *vdso__dso_findnew(struct machine *machine);
1618
void vdso__exit(void);
1719

1820
#endif /* __PERF_VDSO__ */

0 commit comments

Comments
 (0)