How to read the LXR?

127 views Asked by At

I want to read some Linux Kernel source code, and I found LXR. It's great, but sometimes when I click on some function, like 'kfree', and I got this: enter image description here

When 'link' using ld, there must be no conflicts. So the question is : How to determine which one is THE ONE??? (I think gcc+makefile is the solution, but I don't know how to do it...)

Thanks!

2

There are 2 answers

0
alex On

Here is another linux cross reference search, with maybe more detailed information

https://code-grep.com/view/project/54b083273b2082684a000008/linux-3.19-rc2?search=kfree&type=definitions&page=0

As you can see, some are preprocessor definitions and some are function. To know which one is the correct one, you can check out the config options, typically in .config file of the kernel.

0
Alex Hoppus On

1. If you have some implicit knowledge about kernel, you will notice that kfree is a part of slub or slab or slob. Reviewing the kernel config you will be probably notice that you use slub allocator (by dfefault). So you conclude - the right answer is mm/slub.c:3334.

2.

nm -a ./vmlinux | grep kfree
ffffffff81151bd0 T kfree
addr2line -e ./vmlinux 0xffffffff81151bd0
/home/alexhoppus/Desktop/linux/mm/slub.c:3335