On Tue, Sep 29, 2009 at 1:06 PM, askb <ask...@gmail.com> wrote:

> > 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.
>
>
>
You mean use only _GP_NOMEMALLOC as a sole flag to kmalloc?

As per your explaination, can't I use just

 <http://lxr.linux.no/linux+*/include/linux/gfp.h#L72>#define
GFP_NOWAIT <http://lxr.linux.no/linux+*/+code=GFP_NOWAIT>
(GFP_ATOMIC <http://lxr.linux.no/linux+*/+code=GFP_ATOMIC> &
~__GFP_HIGH <http://lxr.linux.no/linux+*/+code=__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.

Reply via email to