All of lore.kernel.org
 help / color / mirror / Atom feed
From: moshrefj@usc.edu (Masoud Moshref Javadi)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Get a huge page in a linux kernel module
Date: Sat, 04 Oct 2014 16:07:22 -0700	[thread overview]
Message-ID: <54307DAA.1030208@usc.edu> (raw)

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

                 reply	other threads:[~2014-10-04 23:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54307DAA.1030208@usc.edu \
    --to=moshrefj@usc.edu \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.