Re: Kmalloc while holding a spinlock

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

 



> I need to do lot of small allocations (around 70-80 bytes) from a
> critical region
> while holding a spinlock. Total number of such allocation could go
> upto tens of 
> thousands in few hours. So all these allocations use GFP_ATOMIC flag
> instead of
> GFP_KERNEL. As per my understanding, GFP_ATOMIC can never fail, and I
> dont
> want my allocations to fail. But this could be a bad idea right? Using
> GFP_ATOMIC
> for all these allocations?

GFP_ATOMIC is ideal for situations while using a spinlock or in
interrupt context or in places like BH - softirqs and tasklets) as long
as you dont want to block or sleep. On the other hand GPF_KERNEL could
block. 
 

> Is GFP_NOWAIT | GFP_KERNEL guarantee that?
> 
> Is ( GFP_NOWAIT | GFP_KERNEL ) == ( GFP_ATOMIC - dont access emergency
> pools)?
Not sure if you can do something like this.

> I think GFP_KERNEL | GFP_NOWAIT will solve my issue, what say?

http://lxr.linux.no/#linux+v2.6.31/include/linux/gfp.h#L41

GFP_ATOMIC is __GFP_WAIT unset while using allocation from the resource
pool. So GFP_NOWAIT would be (GFP_ATOMIC & ~__GFP_HIGH) now not
allocating from the pool and wait not set. But GFP_KERNEL does include a
_GFP_WAIT which may not work.

look into _GP_NOMEMALLOC - if you dont want to use memory pool.  



--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[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