Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
This is a very specific question for which I was baffled for an answer. I have searched the forums, but maybe I was too specific.
I'm getting an OOM error, specifically for DMA memory allocated with dma_generic_alloc_coherent(). I'm trying to figure out where the kernel is calling printk() within the function __alloc_pages_nodemask() (which is called from dma_generic_alloc_coherent). I came upon the function trace_mm_page_alloc(), and I'm guessing this is a macro with some kind of logic that ultimately performs a printk().
I went to the top of the kernel source tree (Ubuntu 1.2.2) and did the following:
find . -type f -exec grep trace_mm_page_alloc \{} \; -print
It is my theory that this should have searched EVERY file, no matter whether it is documentation or C code or assembly or header file. The only place it was found was in __alloc_pages_nodemask(). The response being:
how did you find this function (trace_mm_page_alloc)? You can try to use nm <some *.so> instead of this grep to find where is it implemented (but maybe you won't find it)
I was walking through the backtrace generated in the printk ring buffer (via dmesg). It indicated one of the functions was the dma_general_alloc_coherent(), and I stepped through it. The actual error occurred in a printk(), which is what I wanted to see.
Part of my issue is, why can't I find a definition for it? Is there some macro pre-process that is happening that changes the names of functions before they're compiled?
Your idea of using nm to see which .o defines it is a good one. I'll give that a try.
in the linux kernel source tree I found the following:
include/trace/events/kmem.h:TRACE_EVENT(mm_page_alloc,
here is some documentation: Documentation/trace/events-kmem.txt
and it is probably called from mm/page_alloc.c
The implementation is based on include/linux/tracepoint.h where you can see it will be evaluated as a static inline void trace_<something>
(so it is implemented inline in the kernel, you will not find any other .o or .so containing it).
Also marcos are resolved compile time, you will not be able to find macros during a debug session.
Wow! Thanks for that! No wonder I couldn't find it anywhere.
I didn't need to find it in a debug session, I just wanted to know what the function did, what caused it to print, etc. That's exactly the info I needed to keep me going.
__________________________________
Happy with solution ... mark as SOLVED
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.