RE: kernel memory allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: kernelnewbies-bounces@xxxxxxxxxxxxxxxxx [mailto:kernelnewbies-
> bounces@xxxxxxxxxxxxxxxxx] 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




_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux