question about alloc_bootmem

javaweb zhang javawebzwp at gmail.com
Sat Apr 16 09:20:07 EDT 2011


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.

2011/4/15 Dave Hylands <dhylands at gmail.com>

> Hi,
>
> On Thu, Apr 14, 2011 at 10:49 PM, javaweb zhang <javawebzwp at gmail.com>
> wrote:
> > Hello, everyone. I use alloc_bootmem() in profile.c to allocate a big
> memory
> > at function profile_init(), how I know whether it is success? The
> following
> > is my code:
> > // at kernel/profile.c
> > ctxsw_A = (struct ctxsw_rec *)alloc_bootmem(sizeof(struct
> ctxsw_rec)*CTXSW);
> > ctxsw_rec is a struct which declared in include/linux/profile.h,  CTXSW =
> > 4>>10
>
> Looking at the source code for alloc_bootmem, it returns a NULL
> pointer (which is what most allocators do when the allocation fails).
> It appears that it will hit a panic first though, so you may never get
> to the receiving the NULL.
>
> --
> Dave Hylands
> Shuswap, BC, Canada
> http://www.davehylands.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110416/6a14bdf5/attachment.html 


More information about the Kernelnewbies mailing list