You are not logged in.

#1 2019-03-20 12:38:32

nanxiao
Member
Registered: 2017-07-27
Posts: 21

Is it possible to get kernel function name through instruction address

Hi all,

Greeting from me!

My Arch Linux kernel version is 4.19.28-1-lts, and I try to use "perf record" to profile an application:

https://raw.githubusercontent.com/NanXi … h-perf.jpg

We can see the most executed instruction address is 0xffffffff8aa0015f and in kernel module. Is there any method to find the kernel function name through address?

Thanks very much in advance!

Best Regards

Nan Xiao

Mod note: Converted image to url, please adhere to our image posting guidelines -- V1del

Last edited by V1del (2019-03-20 12:41:00)

Offline

#2 2019-03-22 06:17:22

nixawk
Member
Registered: 2015-01-23
Posts: 7

Re: Is it possible to get kernel function name through instruction address

Try to compile 4.19.28-1-lts, and find the address from System.map or vmlinux.

~/Projects/kernelbuild/linux-5.0.3 ➭ head -5 System.map
0000000000000000 D __per_cpu_start
0000000000000000 D irq_stack_union
00000000000001e0 A kexec_control_code_size
0000000000004000 D cpu_debug_store
0000000000005000 D cpu_tss_rw
~/Projects/kernelbuild/linux-5.0.3 ➭ nm vmlinux | head -5
ffffffff81376410 T aa_af_perm
ffffffff81367230 T aa_alloc_profile
ffffffff81370f90 T aa_alloc_proxy
ffffffff8270f0a3 T aa_alloc_root_ns
ffffffff8136ee90 T aa_alloc_secid

- https://wiki.archlinux.org/index.php/Ke … System.map


Thanks for sharing.

Offline

#3 2019-03-31 10:25:38

nanxiao
Member
Registered: 2017-07-27
Posts: 21

Re: Is it possible to get kernel function name through instruction address

@ nixawk

Thanks for your reply! I am very sorry for my late response!

But I have a question. So is it guaranteed that my own build image has the same system table as official release?

Thanks!

Nan Xiao

Offline

#4 2019-03-31 15:23:15

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: Is it possible to get kernel function name through instruction address

nanxiao wrote:

But I have a question. So is it guaranteed that my own build image has the same system table as official release?

In my opinion, it would be unlikely.  You might have some luck if you were to build it in a chroot.   
I think the unstated assumption is that you would compile the kernel and then install it on your system.

Last edited by ewaller (2019-03-31 15:23:47)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2019-03-31 16:19:57

loqs
Member
Registered: 2014-03-06
Posts: 17,195

Re: Is it possible to get kernel function name through instruction address

Does the following return any results?

# grep nvidia /proc/kallsyms

Offline

#6 2019-04-01 00:52:12

nanxiao
Member
Registered: 2017-07-27
Posts: 21

Re: Is it possible to get kernel function name through instruction address

loqs wrote:

Does the following return any results?

# grep nvidia /proc/kallsyms

@loqs, thanks for your reply!

It actually outputs something:

$ grep nvidia /proc/kallsyms | more
0000000000000000 t nvidia_force_enable_hpet
0000000000000000 t nvidia_force_enable_hpet.cold.4
0000000000000000 t quirk_nvidia_ck804_pcie_aer_ext_cap
0000000000000000 t quirk_nvidia_ck804_msi_ht_cap
0000000000000000 t nvidia_hpet_check
0000000000000000 t nvidia_bugs
0000000000000000 t pci_mmcfg_nvidia_mcp55
0000000000000000 r _note_6      [nvidia_uvm]
0000000000000000 b uvm_debug_prints     [nvidia_uvm]
0000000000000000 b g_uvmBaseDev [nvidia_uvm]
0000000000000000 r __FUNCTION__.53470   [nvidia_uvm]
0000000000000000 b bUvmDriverModeChecked.53451  [nvidia_uvm]
0000000000000000 b uvmDriverMode.53452  [nvidia_uvm]
0000000000000000 t uvm_exit     [nvidia_uvm]
0000000000000000 r CSWTCH.18    [nvidia_uvm]
......

But  how can I map symbols into addresses? Thanks!

Offline

#7 2019-04-01 00:53:35

nanxiao
Member
Registered: 2017-07-27
Posts: 21

Re: Is it possible to get kernel function name through instruction address

ewaller wrote:
nanxiao wrote:

But I have a question. So is it guaranteed that my own build image has the same system table as official release?

In my opinion, it would be unlikely.  You might have some luck if you were to build it in a chroot.   
I think the unstated assumption is that you would compile the kernel and then install it on your system.

@ewaller Thanks for your reply!

So is there any method to map addresses to symbols? Thanks in advance!

Offline

#8 2019-04-01 10:58:55

loqs
Member
Registered: 2014-03-06
Posts: 17,195

Re: Is it possible to get kernel function name through instruction address

$ grep nvidia /proc/kallsyms | more

The addresses were zeroed out by the kernel as the command was not run by root.

Offline

#9 2019-04-02 03:14:09

nanxiao
Member
Registered: 2017-07-27
Posts: 21

Re: Is it possible to get kernel function name through instruction address

loqs wrote:
$ grep nvidia /proc/kallsyms | more

The addresses were zeroed out by the kernel as the command was not run by root.

@logs, Oh, you are correct! Thanks very much!

Offline

Board footer

Powered by FluxBB