简体   繁体   中英

Adding dynamic tracepoint through perf in Linux for function that is not listed

I am trying to trace function zap_pte_range from mm/memory.c using perf . But function is not listed in the perf probe -F . So is there a way to dynamically trace this function? Ie with explicitly adding the tracepoint and recompiling the kernel?

perf probe -a zap_pte_range

gives:

[kernel.kallsyms] with build id 33b15ec444475ee7806331034772f61666fa6719 not found, continuing without symbols

Failed to find symbol zap_pte_range in kernel

Error: Failed to add events.

There is no such trace point. So apparently you cannot trace it the easy way. It seems that this function was inlined by compiler (keep in mind that function also could be omitted for some optimization reasons). That's why there is no its symbol in /proc/kallsyms .

You can choose the most suitable function for you to trace. Eg in my Debian with 4.9 kernel I can trace unmap_page_range() , which eventually "calls" the function you need. Perhaps it logically will meet your goal.

Another way is a little bit hacking. You can do something like objdump -dS memory.o | vim - objdump -dS memory.o | vim - (you should have binaries) and investigate where is the code you needed. Given that the chain zap_pud_range() -> zap_pmd_range() -> zap_pte_range() is probably inlined, you will have to investigate aforementioned unmap_page_range() . Perhaps you'll finally gain some code address for kprobes .

If you want to explicitly trace zap_pte_range() eg through jprobes (about args) or kretprobes (about return value), you can try to specify noinline -attribute for needed function(s), recompile Linux kernel and trace it as you want.

Guess I have no more useful ways for you.

More info: Related post , Jprobes example , Ftrace: trace your kernel functions! , Post about ftrace and systemtap , man nm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM