Skip to contentSkip to conversation

perf top: Don't complain about lack of vmlinux when not resolving some kernel samples

PATCH In review Arnaldo Carvalho de Melo 2 participants 3 messages Jan 3, 2025 – Jan 8, 2025 perf events

lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

PATCH 1/1 perf top: Don't complain about lack of vmlinux when not resolving some kernel samples

Recently we got a case where a kernel sample wasn't being resolved due to a bug that was not setting the end address on kernel functions implemented in assembly (see Link: tag), and then those were not being found by machine__resolve() -> map__find_symbol().

So we ended up with:

  # perf top --stdio
  PerfTop: 0 irqs/s  kernel: 0%  exact: 0% lost: 0/0 drop: 0/0 [cycles/P]
  -----------------------------------------------------------------------

Warning:
A vmlinux file was not found.
Kernel samples will not be resolved.
^Z
[1]+ Stopped perf top --stdio
#

But then resolving all other kernel symbols.

So just fixup the logic to only print that warning when there are no symbols in the kernel map.

---
 tools/perf/builtin-top.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-top.c +1 -1
index 724a7938632126bf..ca3e8eca6610e851 100644
@@ -809,7 +809,7 @@ static void perf_event__process_sample(const struct perf_tool *tool,
 		 * invalid --vmlinux ;-)
 		 */
 		if (!machine->kptr_restrict_warned && !top->vmlinux_warned &&
-		    __map__is_kernel(al.map) && map__has_symbols(al.map)) {
+		    __map__is_kernel(al.map) && !map__has_symbols(al.map)) {
 			if (symbol_conf.vmlinux_name) {
 				char serr[256];
 
Signature · 1 line
2.47.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Arnaldo,

Quoted 23 lines · Arnaldo Carvalho de Melo

Recently we got a case where a kernel sample wasn't being resolved due to a bug that was not setting the end address on kernel functions implemented in assembly (see Link: tag), and then those were not being found by machine__resolve() -> map__find_symbol().

So we ended up with:

  # perf top --stdio
  PerfTop: 0 irqs/s  kernel: 0%  exact: 0% lost: 0/0 drop: 0/0 [cycles/P]
  -----------------------------------------------------------------------

Warning:
A vmlinux file was not found.
Kernel samples will not be resolved.
^Z
[1]+ Stopped perf top --stdio
#

But then resolving all other kernel symbols.

So just fixup the logic to only print that warning when there are no symbols in the kernel map.

Quoted 8 lines

Looks like an old bug since d88205db9caa0e9d ("perf dso: Add dso__has_symbols() method"). :)

Thanks,
Namhyung

Quoted 20 lines
---
 tools/perf/builtin-top.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-top.c +1 -1
index 724a7938632126bf..ca3e8eca6610e851 100644
@@ -809,7 +809,7 @@ static void perf_event__process_sample(const struct perf_tool *tool,
 		 * invalid --vmlinux ;-)
 		 */
 		if (!machine->kptr_restrict_warned && !top->vmlinux_warned &&
-		    __map__is_kernel(al.map) && map__has_symbols(al.map)) {
+		    __map__is_kernel(al.map) && !map__has_symbols(al.map)) {
 			if (symbol_conf.vmlinux_name) {
 				char serr[256];
 
Signature · 1 line
2.47.0
author maintainer
#2 lore raw
Quoted 35 lines · Namhyung Kim

Hi Arnaldo,

Quoted 23 lines · Arnaldo Carvalho de Melo

Recently we got a case where a kernel sample wasn't being resolved due to a bug that was not setting the end address on kernel functions implemented in assembly (see Link: tag), and then those were not being found by machine__resolve() -> map__find_symbol().

So we ended up with:

  # perf top --stdio
  PerfTop: 0 irqs/s  kernel: 0%  exact: 0% lost: 0/0 drop: 0/0 [cycles/P]
  -----------------------------------------------------------------------

Warning:
A vmlinux file was not found.
Kernel samples will not be resolved.
^Z
[1]+ Stopped perf top --stdio
#

But then resolving all other kernel symbols.

So just fixup the logic to only print that warning when there are no symbols in the kernel map.

Quoted 8 lines
Quoted 4 lines

Looks like an old bug since d88205db9caa0e9d ("perf dso: Add dso__has_symbols() method"). :)

Agreed, logic inversion, I'm adding the Fixes tag, thanks for finding it!

- Arnaldo