Hi, Thank you. I have found the main reason for my problem. alloc_bootmem() must use after init_bootmem_node() and before free_all_bootmem(), but profile_init() is executed after free_all_bootmem(), so it could not alloc the memory what I want.<br>
<br><div class="gmail_quote">2011/4/15 Dave Hylands <span dir="ltr"><<a href="mailto:dhylands@gmail.com">dhylands@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<div><div></div><div class="h5"><br>
On Thu, Apr 14, 2011 at 10:49 PM, javaweb zhang <<a href="mailto:javawebzwp@gmail.com">javawebzwp@gmail.com</a>> wrote:<br>
> Hello, everyone. I use alloc_bootmem() in profile.c to allocate a big memory<br>
> at function profile_init(), how I know whether it is success? The following<br>
> is my code:<br>
> // at kernel/profile.c<br>
> ctxsw_A = (struct ctxsw_rec *)alloc_bootmem(sizeof(struct ctxsw_rec)*CTXSW);<br>
> ctxsw_rec is a struct which declared in include/linux/profile.h, CTXSW =<br>
> 4>>10<br>
<br>
</div></div>Looking at the source code for alloc_bootmem, it returns a NULL<br>
pointer (which is what most allocators do when the allocation fails).<br>
It appears that it will hit a panic first though, so you may never get<br>
to the receiving the NULL.<br>
<font color="#888888"><br>
--<br>
Dave Hylands<br>
Shuswap, BC, Canada<br>
<a href="http://www.davehylands.com" target="_blank">http://www.davehylands.com</a><br>
</font></blockquote></div><br>