kernel memory allocation
João Eduardo Luís
jecluis at gmail.com
Fri Jun 3 15:40:26 EDT 2011
Hi.
In future replies, please CC the list.
Does it panic in during the kmalloc, or afterwards? Are you checking if 'newBun' is NULL?
I may be missing something obvious in that code, but unless you are out of memory or with some past corruption, I don't think that should panic the kernel.
In any case, the panic trace should help.
Cheers.
---
João Eduardo Luís
gpg key: 477C26E5 from pool.keyserver.eu
On Jun 3, 2011, at 7:50 PM, Amirali Shambayati wrote:
> thanks for your guidance. I just want to allocate memory for a struct. I use this:
>
> struct bundle* newBun;
> newBun = kmalloc(sizeof(*newBun), GFP_KERNEL);
>
> but it goes to panic state.
>
> 2011/6/3 João Eduardo Luís <jecluis at gmail.com>
> Hi.
>
> From [1] I'm lead to believe the only difference between the regular kmalloc() arguments and those of kmalloc_node() is the one specifying which node you want to allocate the memory on.
>
> Aside from the third argument, which seems to be related with NUMA (with which I never worked on kernel-context), I would suggest you to read [2].
>
> If on the other hand you only want to allocate memory locally, maybe you should use kmalloc() or one of its variants [3].
>
>
> Cheers.
>
>
> [1] - http://www.kernel.org/doc/htmldocs/kernel-api/API-kmalloc-node.html
> [2] - http://www.kernel.org/doc/htmldocs/kernel-api/API-kcalloc.html
> [3] - http://www.kernel.org/doc/htmldocs/kernel-api/mm.html#id408507
> ---
> João Eduardo Luís
> gpg key: 477C26E5 from pool.keyserver.eu
>
>
>
>
>
> On Jun 3, 2011, at 7:07 PM, Amirali Shambayati wrote:
>
> >
> > Hello all,
> >
> > I just want to allocate memory for a struct instantiation. Would anyone guide me what arguments I should pass to "kmalloc_node"?
> > Regards,
> > --
> > Amirali Shambayati
> > Bachelor Student
> > Computer Engineering Department
> > Sharif University of Technology
> > Tehran, Iran
> >
> > _______________________________________________
> > Kernelnewbies mailing list
> > Kernelnewbies at kernelnewbies.org
> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
>
>
> --
> Amirali Shambayati
> Bachelor Student
> Computer Engineering Department
> Sharif University of Technology
> Tehran, Iran
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 495 bytes
Desc: This is a digitally signed message part
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110603/8df6616b/attachment.bin
More information about the Kernelnewbies
mailing list