All of lore.kernel.org
 help / color / mirror / Atom feed
* Get a huge page in a linux kernel module
@ 2014-10-04 23:07 Masoud Moshref Javadi
  0 siblings, 0 replies; only message in thread
From: Masoud Moshref Javadi @ 2014-10-04 23:07 UTC (permalink / raw)
  To: kernelnewbies

I want to reserve a hugepage at kernel (Ubuntu 3.13.0-32-generic) and 
share it with a user process.
I used the code for regular page sharing from:
http://people.ee.ethz.ch/~arkeller/linux/code/mmap_bart_tanghe_dan_hordern.c

Then 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
http://stackoverflow.com/questions/19460544/how-do-i-allocate-a-dma-buffer-backed-by-1gb-hugepages-in-a-linux-kernel-module

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

So it seems that something is wrong with hugetlb_fault. What else should 
I change to reserve a huge page?

And the call trace is:
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091489] Call Trace:
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091496] 
[<ffffffff811795fd>] handle_mm_fault+0xd4d/0xf00
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091501] 
[<ffffffff8117da87>] ? vma_link+0xb7/0xc0
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091507] 
[<ffffffff81727be4>] __do_page_fault+0x184/0x560
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091512] 
[<ffffffff8101b7e9>] ? sched_clock+0x9/0x10
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091517] 
[<ffffffff8109d1ad>] ? sched_clock_local+0x1d/0x80
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091522] 
[<ffffffff8111155c>] ? acct_account_cputime+0x1c/0x20
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091527] 
[<ffffffff8109d7db>] ? account_user_time+0x8b/0xa0
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091531] 
[<ffffffff8109ddf4>] ? vtime_account_user+0x54/0x60
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091535] 
[<ffffffff81727fda>] do_page_fault+0x1a/0x70
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091540] 
[<ffffffff81724448>] page_fault+0x28/0x30
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091542] Code: 54 53 48 
83 ec 38 48 8b 86 a0 00 00 00 48 89 55 d0 48 89 7d b8 89 4d ac 48 8b 40 
20 48 8b 40 28 48 8b 80 f8 02 00 00 4c 8b 68 18 <49> 8b 45 10 48 21 45 
d0 48 8b 75 d0 e8 c1 ed ff ff 48 85 c0 48
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091557] RIP 
[<ffffffff8119522e>] hugetlb_fault+0x3e/0x760
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091559]  RSP 
<ffff880093cb1d28>
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091562] CR2: 
00000000006f0082
Oct  4 15:43:50 masoud-VirtualBox kernel: [ 2756.091565] ---[ end trace 
75afe8697af08287 ]--

-- 
Masoud Moshref Javadi
Computer Engineering PhD Candidate
Ming Hsieh Department of Electrical Engineering
University of Southern California

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-10-04 23:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-04 23:07 Get a huge page in a linux kernel module Masoud Moshref Javadi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.