perf map: Introduce map__has_symbols()
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 23 Apr 2018 20:13:49 +0000 (17:13 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 26 Apr 2018 16:47:06 +0000 (13:47 -0300)
To further simplify checking if symbols are available for a given map
and to reduce the number of users of MAP__{FUNCTION,VARIABLE}.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-iyfoyvbfdti5uehgpjum3qrq@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-report.c
tools/perf/builtin-top.c
tools/perf/util/map.c
tools/perf/util/map.h

index a4104e447f5620c77a0bb7483397803410f4c153..68ea336bf31165939b16d7c60693b5e0d4c867c6 100644 (file)
@@ -523,12 +523,9 @@ static void report__warn_kptr_restrict(const struct report *rep)
                    "As no suitable kallsyms nor vmlinux was found, kernel samples\n"
                    "can't be resolved.";
 
-               if (kernel_map) {
-                       const struct dso *kdso = kernel_map->dso;
-                       if (dso__has_symbols(kdso, MAP__FUNCTION)) {
-                               desc = "If some relocation was applied (e.g. "
-                                      "kexec) symbols may be misresolved.";
-                       }
+               if (kernel_map && map__has_symbols(kernel_map)) {
+                       desc = "If some relocation was applied (e.g. "
+                              "kexec) symbols may be misresolved.";
                }
 
                ui__warning(
index c11b46b411d51844d05efba711f242838ddbb2d5..3c061c57afb67950b2dd6953b2a8a73571d1a354 100644 (file)
@@ -742,7 +742,7 @@ static void perf_event__process_sample(struct perf_tool *tool,
 "Kernel address maps (/proc/{kallsyms,modules}) are restricted.\n\n"
 "Check /proc/sys/kernel/kptr_restrict.\n\n"
 "Kernel%s samples will not be resolved.\n",
-                         al.map && dso__has_symbols(al.map->dso, MAP__FUNCTION) ?
+                         al.map && map__has_symbols(al.map) ?
                          " modules" : "");
                        if (use_browser <= 0)
                                sleep(5);
@@ -764,8 +764,7 @@ static void perf_event__process_sample(struct perf_tool *tool,
                 * invalid --vmlinux ;-)
                 */
                if (!machine->kptr_restrict_warned && !top->vmlinux_warned &&
-                   __map__is_kernel(al.map) &&
-                   dso__has_symbols(al.map->dso, MAP__FUNCTION)) {
+                   __map__is_kernel(al.map) && map__has_symbols(al.map)) {
                        if (symbol_conf.vmlinux_name) {
                                char serr[256];
                                dso__strerror_load(al.map->dso, serr, sizeof(serr));
index 8fe57031e1a85ba3816b322e30526bcf9f237d14..f553e302bf9c6eea915898245353a5511d3faa37 100644 (file)
@@ -259,6 +259,11 @@ bool __map__is_kernel(const struct map *map)
        return __machine__kernel_map(map->groups->machine, map->type) == map;
 }
 
+bool map__has_symbols(const struct map *map)
+{
+       return dso__has_symbols(map->dso, map->type);
+}
+
 static void map__exit(struct map *map)
 {
        BUG_ON(!RB_EMPTY_NODE(&map->rb_node));
index 0e9bbe01b0abc934daec873254e06c3da36f4d8f..fc91bac8fed083e5dbf597d5bef2740e88dba64a 100644 (file)
@@ -264,4 +264,6 @@ static inline bool __map__is_kmodule(const struct map *map)
        return !__map__is_kernel(map);
 }
 
+bool map__has_symbols(const struct map *map);
+
 #endif /* __PERF_MAP_H */