LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   What is trace_mm_page_alloc()? (https://www.linuxquestions.org/questions/linux-kernel-70/what-is-trace_mm_page_alloc-945764/)

cwcarlson 05-18-2012 12:40 PM

What is trace_mm_page_alloc()?
 
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:

trace_mm_page_alloc_extfrag(page, order, current_order,
trace_mm_page_alloc_zone_locked(page, order, migratetype);
trace_mm_page_alloc(page, order, gfp_mask, migratetype);
./mm/page_alloc.c

In other words, it is not DEFINED anywhere. It is not DOCUMENTED anywhere. How is it compiled?

Does anybody have any ideas on where it's defined and what this function does?

Thanks.
Chris

pan64 05-18-2012 12:53 PM

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)

cwcarlson 05-18-2012 04:51 PM

trace_mm_page_alloc()
 
Thanks for the reply.

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.

Thanks again,
Chris

pan64 05-19-2012 03:24 AM

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.

cwcarlson 05-19-2012 01:01 PM

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.

Thanks again,
Chris

pan64 05-19-2012 01:06 PM

Great!








__________________________________
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.


All times are GMT -5. The time now is 03:24 AM.