How to allocate hugepage in kernel module?

aurum spark aurum.spark at gmail.com
Sun Aug 12 03:47:03 EDT 2012


Hi J.Hwan Kim,

Before we talk about APIs let's understand few things about requirement
1. How much contiguous memory do you require for you module ?
2. Should it be DMAble ?
3. Are you going to use that as shared memory with any other card or processor ?

So there are certain API which can provide you huge chunk of contiguous memory.
1. One of them as you are using is get_free_pages(). Try suggestions
by others to get rid of error.
2. Another thing you can use is dma_alloc_coherent(). But there is
limit on this and you should consider that other modules will also
required DMAble memory.
3. Depending on the kernel version you are using you can do
bootmem_reserve() API during initialization code of kernel and you can
keep this memory reserved for your module. Pass that as platform data.
4. You can try passing say mem=768M parameter through kernel
commandline(assuming you have 1G of memory). That will force kernel to
use 768M and you can use rest of the 256M memory by doing ioremap in
your module.

Regards,
~/Aurum



More information about the Kernelnewbies mailing list