Can Cebeci
Can Cebeci

Reputation: 1

Perf cannot use symbol from kernel module

I want to trace a kernel module I've written using Intel PT but I can not get perf to recognize symbols from my kernel modules. For the sake of simplicity, I tried tracing a module that periodically prints a string to the log, using perf record -e intel_pt// -a --filter 'filter print_hello' sleep 1. This results in the following error:

Kernel symbol lookup: Symbol 'print_hello' not found.
Note that symbols must be functions.
Failed to parse address filter: 'filter print_hello'
Filter format is: filter|start|stop|tracestop <start symbol or address> [/ <end symbol or size>] [@<file name>]
Where multiple filters are separated by space or comma.

Recording without a filter using perf record -a -e intel_pt//k sleep 1 and then grep'ing the perf script output for print_hello does not return anything either.

However, perf kallsyms print_hello returns

print_hello: [hello_periodic] /lib/modules/5.4.161/extra/hello-periodic.ko 0xffffffffc07af07c-0xffffffffc07af0b6 (0x7c-0xb6)

so I assume perf can find the symbol after all.

Why could this happen?

Upvotes: 0

Views: 528

Answers (1)

Ajay
Ajay

Reputation: 21

A workaround is possible:

perf record -e intel_pt// -a "$(printf 'filter print_hello\t[hello_periodic]')" sleep 1

Or just use numbers:

perf record -e intel_pt// -a --filter 'filter 0xffffffffc07af07c/0x3a' sleep 1

However, at least kernel v5.18 is probably needed because it has commit c243cecb58e3 ("perf/x86/intel/pt: Relax address filter validation")

For perf help, also try the linux perf users mailing list:

[email protected]

and mail archive at:

https://lore.kernel.org/linux-perf-users/

For general information, the kernel perf wiki:

https://perf.wiki.kernel.org

And for Intel PT, the Intel PT wiki page:

https://perf.wiki.kernel.org/index.php/Perf_tools_support_for_Intel%C2%AE_Processor_Trace

Upvotes: 1

Related Questions