using kmalloc
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 6 lines
I am getting some problems with kmalloc. If I tried to allocate more than certain memory then the system is hanging while booting with the changed kernel. Can you suggest me how to come out this situation. Can't I allocate as much I want when I want to allocate in the kernel.
kmalloc() allocates physically-contiguous pages of memory. Due to fragmentation, more than 64KB-128KB of contiguous pages might not be available, and hence kmalloc() will fail.
To allocate more memory, use vmalloc(), which allocates and maps physically disjoint pages into a virtually-contiguous region. Be careful when doing DMA to a vmalloc() area, since it is not physically contiguous and exists only in the kernel's virtual memory map... Also I believe vmalloc()ed memory is only accessible from (the context of) the process in which it was allocated (?).
Regards,
Dan
Quoted 6 lines
To allocate more memory, use
vmalloc(), which allocates and maps physically disjoint pages into a virtually-contiguous region. Be careful when doing DMA to avmalloc()area, since it is not physically contiguous and exists only in the kernel's virtual memory map... Also I believe vmalloc()ed memory is only accessible from (the context of) the process in which it was allocated (?).
vmalloc memory is accessible everywhere. You can't allocate it during interrupts or tasklets, and you will get deadlocks if you allocate it in the write out path of a file system/disk driver.
Alan
Quoted 3 lines
kmalloc()allocates physically-contiguous pages of memory. Due to fragmentation, more than 64KB-128KB of contiguous pages might not be available, and hencekmalloc()will fail.
kmalloc allocates from generic slab caches. They come in sizes of powers of 2 from 32B to 128KiB. The largest has slabs 128KiB large (on i386 at least). Pages are allocated via __get_free_pages, so they have to be continuous.
However if you allocate namy instances of some structure, it's best to create a kmem cache and allocate via kmem_cache_alloc (since it does not round the requested size up to a power of two).
--------------------------------------------------------------------------------
- Jan Hudec `Bulb' <[email protected]>