I know how to get normal pages in linux kernel and share that with user process using mmap based on this code: http://people.ee.ethz.ch/~arkeller/linux/multi/kernel_user_space_howto-8.html Now I want to extend it to use hugepages (2M).
Is it enough to put the file that backs up the shared memory in the hugetlbfs filesystem? Can you also point me to a tutorial on using hugepages?
Progress until now: I used hugeadm to enable hugepages and transparent hugepages and added the corresponding grub configs.
This post on stackoverflow says to use the following parameters for alloc_pages
struct page *p = alloc_pages(GFP_TRANSHUGE, HPAGE_PMD_ORDER);
It didn't work as /proc/meminfo still says all huge pages are free.
Then I changed
vma->vm_flags |= VM_RESERVED;
to
vma->vm_flags |= VM_HUGETLB;
but the following error happened:
Oct 4 15:43:50 masoud-VirtualBox kernel: [ 2756.091381] BUG: unable to handle kernel paging request at 00000000006f0082
Oct 4 15:43:50 masoud-VirtualBox kernel: [ 2756.091387] IP: [<ffffffff8119522e>] hugetlb_fault+0x3e/0x760
Oct 4 15:43:50 masoud-VirtualBox kernel: [ 2756.091394] PGD bde87067 PUD c2ad7067 PMD b79ca067 PTE 0
Oct 4 15:43:50 masoud-VirtualBox kernel: [ 2756.091399] Oops: 0000 [#1] SMP