On Tue, Sep 29, 2009 at 1:06 PM, askb <askb23@xxxxxxxxx> wrote:
> I need to do lot of small allocations (around 70-80 bytes) from aGFP_ATOMIC is ideal for situations while using a spinlock or in
> 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?
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.
Not sure if you can do something like this.
> Is GFP_NOWAIT | GFP_KERNEL guarantee that?
>
> Is ( GFP_NOWAIT | GFP_KERNEL ) == ( GFP_ATOMIC - dont access emergency
> pools)?
http://lxr.linux.no/#linux+v2.6.31/include/linux/gfp.h#L41
> I think GFP_KERNEL | GFP_NOWAIT will solve my issue, what say?
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.
You mean use only _GP_NOMEMALLOC as a sole flag to kmalloc?
As per your explaination, can't I use just
#define GFP_NOWAIT (GFP_ATOMIC & ~__GFP_HIGH)
as a sole flag to kmalloc? Meaning I will not user GFP_KERNEL at all..
Would be that correct things to do?
-Leo.