lkml.org 
[lkml]   [2009]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: GFP_NOWAIT and GFP_NOMEMALLOC
    On Tue 2009-09-29 16:55:24, Leonidas . wrote:
    > Hi list,
    >
    > I am new here, I have googled/binged enough before posting this message,
    > in case of redundancy please point me to appropriate links/resources etc.
    >
    > I want to kmalloc memory while holding spinlocks in process context, here I
    > can't use GFP_KERNEL flag since it can sleep. Using GFP_ATOMIC guarantees
    > that allocation will succeed by allocating from emergency pools if needed.
    > But I dont think, I need to use emergency pool and I want to limit my memory
    > consumption to ZONE_NORMAL without sleeping, my module is ready to handle
    > the allocation failure if any.

    Umm. Either preallocate, or use gfp_atomic. It should be ok.

    > Something like,
    >
    > ptr = kmalloc(..., GFP_KERNEL | GFP_DONT_SLEEP );
    >
    > if( !ptr ) {
    >
    > /*GFP_KERNEL failed, Use GFP_ATOMIC pool*/
    > ptr = kmalloc(..., GFP_ATOMIC );
    >
    > }
    > /*Go ahead and do stuff*/

    That's pretty stupid, no? Just alloc GFP_ATOMIC directly... oh and
    check return values...
    --
    (english) http://www.livejournal.com/~pavelmachek
    (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


    \
     
     \ /
      Last update: 2009-10-04 21:03    [W:2.411 / U:0.140 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site