perf map: Add map__refcnt() accessor to use in the maps test

To remove one more direct access to 'struct map' so that we can intecept
accesses to its instantiations and refcount check it to catch use after
free, etc.

Cc: Adrian Hunter <[email protected]>
Cc: Alexey Bayduraev <[email protected]>
Cc: Dmitriy Vyukov <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Riccardo Mancini <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Stephen Brennan <[email protected]>
Link: https://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
Arnaldo Carvalho de Melo
2023-04-12 12:49:16 -03:00
parent 984abd349d
commit 4e8db2d752
2 changed files with 7 additions and 2 deletions
+2 -2
View File
@@ -30,7 +30,7 @@ static int check_maps(struct map_def *merged, unsigned int size, struct maps *ma
if (map__start(map) != merged[i].start ||
map__end(map) != merged[i].end ||
strcmp(map__dso(map)->name, merged[i].name) ||
refcount_read(&map->refcnt) != 1) {
refcount_read(map__refcnt(map)) != 1) {
failed = true;
}
i++;
@@ -50,7 +50,7 @@ static int check_maps(struct map_def *merged, unsigned int size, struct maps *ma
map__start(map),
map__end(map),
map__dso(map)->name,
refcount_read(&map->refcnt));
refcount_read(map__refcnt(map)));
}
}
return failed ? TEST_FAIL : TEST_OK;
+5
View File
@@ -97,6 +97,11 @@ static inline bool map__priv(const struct map *map)
return map->priv;
}
static inline refcount_t *map__refcnt(struct map *map)
{
return &map->refcnt;
}
static inline size_t map__size(const struct map *map)
{
return map__end(map) - map__start(map);