public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* GFP_NOWAIT and GFP_NOMEMALLOC
@ 2009-09-29 11:25 Leonidas .
  2009-09-29 11:59 ` Arjan van de Ven
  2009-10-04 18:56 ` Pavel Machek
  0 siblings, 2 replies; 6+ messages in thread
From: Leonidas . @ 2009-09-29 11:25 UTC (permalink / raw)
  To: linux-kernel

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.


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*/

Is there any flag which fetches memory from GFP_KERNEL pool with a
guarantee that
it will not sleep?

Does GFP_NOWAIT | GFP_KERNEL guarantee that?

Is ( GFP_NOWAIT | GFP_KERNEL ) == ( GFP_ATOMIC - dont access emergency pools)?

I am a bit confused about GFP_NOWAIT and GFP_NOMEMALLOC, any pointers will be
helpful.

-Leo.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-10-04 18:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-29 11:25 GFP_NOWAIT and GFP_NOMEMALLOC Leonidas .
2009-09-29 11:59 ` Arjan van de Ven
2009-09-29 12:16   ` Leonidas .
2009-09-29 12:37     ` Arjan van de Ven
2009-09-29 12:43       ` Leonidas .
2009-10-04 18:56 ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox