Kmalloc while holding a spinlock
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- Subject: Kmalloc while holding a spinlock
- From: "Leonidas ." <leonidas137@xxxxxxxxx>
- Date: Tue, 29 Sep 2009 11:30:08 +0530
Hi List,
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?
Is there any way I can avoid using GFP_ATOMIC without preallocating the buffers?
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?
Is GFP_NOWAIT | GFP_KERNEL guarantee that?
Is ( GFP_NOWAIT | GFP_KERNEL ) == ( GFP_ATOMIC - dont access emergency pools)?
I think GFP_KERNEL | GFP_NOWAIT will solve my issue, what say?
-Leo.
[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]