LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 05-18-2012, 12:40 PM   #1
cwcarlson
LQ Newbie
 
Registered: Jun 2011
Location: Mission Viejo, CA
Distribution: Fedora 9, 13 and 15.
Posts: 13

Rep: Reputation: Disabled
Question 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
 
Old 05-18-2012, 12:53 PM   #2
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,753

Rep: Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271
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)
 
Old 05-18-2012, 04:51 PM   #3
cwcarlson
LQ Newbie
 
Registered: Jun 2011
Location: Mission Viejo, CA
Distribution: Fedora 9, 13 and 15.
Posts: 13

Original Poster
Rep: Reputation: Disabled
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
 
Old 05-19-2012, 03:24 AM   #4
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,753

Rep: Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271
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.
 
1 members found this post helpful.
Old 05-19-2012, 01:01 PM   #5
cwcarlson
LQ Newbie
 
Registered: Jun 2011
Location: Mission Viejo, CA
Distribution: Fedora 9, 13 and 15.
Posts: 13

Original Poster
Rep: Reputation: Disabled
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
 
Old 05-19-2012, 01:06 PM   #6
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,753

Rep: Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271
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.
 
  


Reply

Tags
memory management, trace


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 09:25 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration