Re: Need to allocate memory always in interrupt handler which MUST succeed.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Amol,
 
Point is, Need to allocate memory from the interrupt handler in non-blocking manner and
there is another thread which operates on this memory and after that it frees.
 
There is a possibility that thread doesn't get schedule and interrupts are keep coming on. I am keeping limit of 1MB (4096 interrupts * 256 bytes per intr)
 
How the kmalloc(GFP_ATOMIC) make sure that it will return me 1MB?
Somehow I have to tell the OS.

What kmalloc does for "kmalloc tries its best "?
 
Regards,
Parav Pandit
 

Amol Lad <amol@xxxxxxxxxxxxxxxxxxx> wrote:
On Thu, 2006-10-12 at 01:40 -0700, Parav Pandit wrote:
> Hi,
>
> I need to allocate some 256 bytes of memory in the interrupt handler
> each time when I get the interrupt. Size varies from 8 bytes to 256
> bytes.
> There are various options such as
> (a) kmalloc(GFP_ATOMIC),
> (b) kmem_cache_alloc
> (c) mempool_alloc
> My driver need to support, at max 4096 * 256 = 1MByte buffer. I donâ??t
> need DMA support.
>
> How can I use above APIs so that I always get the memory in the
> interrupt handler?

You can use kmalloc(GFP_ATOMIC). However, remember to check the return
value. For GFP_ATOMIC, kmalloc tries its best to give you the requested
memory. There is a reserve pool of memory which is used for GFP_ATOMIC
if kmalloc cannot allocate memory from regular pool.

Be sure to kfree() the memory also after use..

>
> ______________________________________________________________________
> Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+
> countries) for 2¢/min or less.



Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail.

[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]
  Powered by Linux