perf symbols: Introduce map__is_(kernel,kmodule)()

To, with members we already have, check if a kernel level map is for the
kernel proper or for a module.
Acked-by: default avatarDavid Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-m5ic7h0z2crmtj7vi1a1rj3b@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b685ac22
...@@ -224,6 +224,20 @@ struct map *map__new2(u64 start, struct dso *dso, enum map_type type) ...@@ -224,6 +224,20 @@ struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
return map; return map;
} }
/*
* Use this and __map__is_kmodule() for map instances that are in
* machine->kmaps, and thus have map->groups->machine all properly set, to
* disambiguate between the kernel and modules.
*
* When the need arises, introduce map__is_{kernel,kmodule)() that
* checks (map->groups != NULL && map->groups->machine != NULL &&
* map->dso->kernel) before calling __map__is_{kernel,kmodule}())
*/
bool __map__is_kernel(const struct map *map)
{
return map->groups->machine->vmlinux_maps[map->type] == map;
}
static void map__exit(struct map *map) static void map__exit(struct map *map)
{ {
BUG_ON(!RB_EMPTY_NODE(&map->rb_node)); BUG_ON(!RB_EMPTY_NODE(&map->rb_node));
......
...@@ -256,4 +256,11 @@ int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, ...@@ -256,4 +256,11 @@ int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map,
struct map *map_groups__find_by_name(struct map_groups *mg, struct map *map_groups__find_by_name(struct map_groups *mg,
enum map_type type, const char *name); enum map_type type, const char *name);
bool __map__is_kernel(const struct map *map);
static inline bool __map__is_kmodule(const struct map *map)
{
return !__map__is_kernel(map);
}
#endif /* __PERF_MAP_H */ #endif /* __PERF_MAP_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment