* kernel memory allocation @ 2011-12-23 2:33 J.Hwan Kim 2011-12-23 3:02 ` Dave Hylands 0 siblings, 1 reply; 7+ messages in thread From: J.Hwan Kim @ 2011-12-23 2:33 UTC (permalink / raw) To: kernelnewbies Hi, everyone How can I allocated contiguous kernel memory over 128MB ? When I use _get_free_pages() function, it returns error. I guess the memory size is greater than the amount which the function can allocate. Thanks in advance. Best Regards, J.Hwan Kim ^ permalink raw reply [flat|nested] 7+ messages in thread
* kernel memory allocation 2011-12-23 2:33 kernel memory allocation J.Hwan Kim @ 2011-12-23 3:02 ` Dave Hylands 0 siblings, 0 replies; 7+ messages in thread From: Dave Hylands @ 2011-12-23 3:02 UTC (permalink / raw) To: kernelnewbies Hi, On Thu, Dec 22, 2011 at 6:33 PM, J.Hwan Kim <frog1120@gmail.com> wrote: > Hi, everyone > > How can I allocated contiguous kernel memory over 128MB ? > When I use _get_free_pages() function, it returns error. > I guess the memory size is greater than the amount which the function > can allocate. You can use bootmem to reserve the memory at boot time, and then use the bootmem allocator to alloocate from that reserved memory/ There is also some new code called CMA (Contiguous Memory Allocator) which hasn't hit the mainline yet, but it could also be used. See: http://lwn.net/Articles/468044/ for further details. -- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* kernel memory allocation @ 2011-06-03 18:07 Amirali Shambayati 2011-06-03 18:38 ` João Eduardo Luís 0 siblings, 1 reply; 7+ messages in thread From: Amirali Shambayati @ 2011-06-03 18:07 UTC (permalink / raw) To: kernelnewbies 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110603/3dceef79/attachment.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* kernel memory allocation 2011-06-03 18:07 Amirali Shambayati @ 2011-06-03 18:38 ` João Eduardo Luís [not found] ` <BANLkTin5f+tdmf_43w-4SS1P=8gMGuCc6w@mail.gmail.com> 0 siblings, 1 reply; 7+ messages in thread From: João Eduardo Luís @ 2011-06-03 18:38 UTC (permalink / raw) To: kernelnewbies 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 -------------- 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/87402d5e/attachment.bin ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <BANLkTin5f+tdmf_43w-4SS1P=8gMGuCc6w@mail.gmail.com>]
* kernel memory allocation [not found] ` <BANLkTin5f+tdmf_43w-4SS1P=8gMGuCc6w@mail.gmail.com> @ 2011-06-03 19:40 ` João Eduardo Luís [not found] ` <BANLkTi=h-fcM4=fP31AMDHxwbevuKAPtNA@mail.gmail.com> 2011-06-03 21:13 ` Jeff Haran 0 siblings, 2 replies; 7+ messages in thread From: João Eduardo Luís @ 2011-06-03 19:40 UTC (permalink / raw) To: kernelnewbies 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@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 ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <BANLkTi=h-fcM4=fP31AMDHxwbevuKAPtNA@mail.gmail.com>]
[parent not found: <BANLkTikYGpzsqWVgCNYPAZv_FZy3cgJJFQ@mail.gmail.com>]
* kernel memory allocation [not found] ` <BANLkTikYGpzsqWVgCNYPAZv_FZy3cgJJFQ@mail.gmail.com> @ 2011-06-03 20:46 ` João Eduardo Luís 0 siblings, 0 replies; 7+ messages in thread From: João Eduardo Luís @ 2011-06-03 20:46 UTC (permalink / raw) To: kernelnewbies Hello, Once again, I would pretty much enjoy if you CC'ed the list on replies. On Jun 3, 2011, at 8:49 PM, Amirali Shambayati wrote: > I set breakpoint before kmalloc. panic happens after kmalloc. > >> 2011/6/4 Amirali Shambayati <amirali.shambayati@gmail.com> >> ofcourse it's null before allocate it. I make an instantiation of it. then I want to allocate memory for it.What else I should do? I meant, are you checking if 'newBun' is NULL _AFTER_ the kmalloc? The kmalloc call will return NULL instead of a pointer to newly allocated memory whenever an error occurs. If by any chance you are not checking if 'newBun' is NULL after the kmalloc, then you should do it. Also, if the panic happens _after_ the kmalloc, and not _during_ the kmalloc, I would say there's a slim chance of kmalloc being the cause of the panic. --- Jo?o Eduardo Lu?s gpg key: 477C26E5 from pool.keyserver.eu -------------- 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/dac98d86/attachment.bin ^ permalink raw reply [flat|nested] 7+ messages in thread
* kernel memory allocation 2011-06-03 19:40 ` João Eduardo Luís [not found] ` <BANLkTi=h-fcM4=fP31AMDHxwbevuKAPtNA@mail.gmail.com> @ 2011-06-03 21:13 ` Jeff Haran 1 sibling, 0 replies; 7+ messages in thread From: Jeff Haran @ 2011-06-03 21:13 UTC (permalink / raw) To: kernelnewbies > -----Original Message----- > From: kernelnewbies-bounces at kernelnewbies.org [mailto:kernelnewbies- > bounces at kernelnewbies.org] On Behalf Of Jo?o Eduardo Lu?s > Sent: Friday, June 03, 2011 12:40 PM > To: Amirali Shambayati > Cc: kernelnewbies > Subject: Re: kernel memory allocation > > 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. > > Just guessing, but the most likely reason for the above call to kmalloc() to cause a panic is it's being called in atomic context. Are you seeing anything like "scheduling while atomic" in the panic back trace? If so, that's your problem and the solution is most likely to replace the above GFP_KERNEL with GFP_ATOMIC. The alternative would be to restructure the code so that the allocation doesn't happen in atomic context. Jeff Haran Bytemobile ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-12-23 3:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-23 2:33 kernel memory allocation J.Hwan Kim
2011-12-23 3:02 ` Dave Hylands
-- strict thread matches above, loose matches on Subject: below --
2011-06-03 18:07 Amirali Shambayati
2011-06-03 18:38 ` João Eduardo Luís
[not found] ` <BANLkTin5f+tdmf_43w-4SS1P=8gMGuCc6w@mail.gmail.com>
2011-06-03 19:40 ` João Eduardo Luís
[not found] ` <BANLkTi=h-fcM4=fP31AMDHxwbevuKAPtNA@mail.gmail.com>
[not found] ` <BANLkTikYGpzsqWVgCNYPAZv_FZy3cgJJFQ@mail.gmail.com>
2011-06-03 20:46 ` João Eduardo Luís
2011-06-03 21:13 ` Jeff Haran
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).