Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About hugepages on ubuntu 12.04 #131

Closed
bruce3557 opened this issue Nov 22, 2013 · 6 comments
Closed

About hugepages on ubuntu 12.04 #131

bruce3557 opened this issue Nov 22, 2013 · 6 comments
Labels

Comments

@bruce3557
Copy link
Collaborator

I tried to execute the hugepage example on ubuntu but failed with following message:

terminate called after throwing an instance of 'std::system_error'
what(): hugepage_allocator could not allocate hugepages: Cannot allocate memory
Aborted (core dumped)

Is there any setting needs? Or we cannot use hugepages on ubuntu@@?

Thanks a lot!

@simongog
Copy link
Owner

Yes, you have to configure your system. Install the hugepage package
sudo apt-get install hugepages

and then you have to change your grub config:

sudo vim /etc/default/grub
add hugepagesz=1GB hugepages=1 default_hugepagesz=1GB to line 11
sudo update-grub
then reboot. I have activated 1 hugepage in this example, you get more by increasing the number assigned to hugepages=. Please notice that those hugepages cannot be allocated by programs which do not allocate them explicitly. So be careful ;)

@mpetri
Copy link
Collaborator

mpetri commented Nov 22, 2013

I think it is easier than this.

run the command cat /proc/meminfo to get something like

HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB

thus on my system the current hugepage size is 2MB (compared to 4kb without hugepages).

Currently the total number of hugepages available is 0 so the program would fail similar to your problem. If you run
echo 500 > /proc/sys/vm/nr_hugepages

the output would look like this:

HugePages_Total:     500
HugePages_Free:      500
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB

thus 500*2MB = 1GB of hugepage mapped memory is available and you could run a program using up to 1GB of memory.

The method simon posted would allow you to change the type of hugepages used by the system to 1GB instead of 2MB which would result in better performance improvements.

@bruce3557
Copy link
Collaborator Author

Thanks for your help =P

I've tried Simon's solution but failed, it still returned the same error

So I tried Petri's solution, but it also failed with the following message:
I executed ./hugepages.x Makefile 1:

*** glibc detected *** ./hugepages.x: free(): invalid pointer: 0x0000000000678868 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7eb96)[0x7fc6ec505b96]
./hugepages.x[0x444830]
./hugepages.x[0x4449f8]
./hugepages.x[0x40bacc]
./hugepages.x[0x40c4c8]
./hugepages.x[0x404bc7]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7fc6ec4a876d]
./hugepages.x[0x4050cd]
======= Memory map: ========
00400000-00477000 r-xp 00000000 08:01 58862624                           /home/brucekuo/OpenSource/sdsl-lite/examples/hugepages.x
00676000-00677000 r--p 00076000 08:01 58862624                           /home/brucekuo/OpenSource/sdsl-lite/examples/hugepages.x
00677000-00678000 rw-p 00077000 08:01 58862624                           /home/brucekuo/OpenSource/sdsl-lite/examples/hugepages.x
00678000-00679000 rw-p 00000000 00:00 0 
016ca000-016eb000 rw-p 00000000 00:00 0                                  [heap]
7fc6ec487000-7fc6ec63c000 r-xp 00000000 08:01 99091064                   /lib/x86_64-linux-gnu/libc-2.15.so
7fc6ec63c000-7fc6ec83c000 ---p 001b5000 08:01 99091064                   /lib/x86_64-linux-gnu/libc-2.15.so
7fc6ec83c000-7fc6ec840000 r--p 001b5000 08:01 99091064                   /lib/x86_64-linux-gnu/libc-2.15.so
7fc6ec840000-7fc6ec842000 rw-p 001b9000 08:01 99091064                   /lib/x86_64-linux-gnu/libc-2.15.so
7fc6ec842000-7fc6ec847000 rw-p 00000000 00:00 0 
7fc6ec847000-7fc6ec85c000 r-xp 00000000 08:01 99091346                   /lib/x86_64-linux-gnu/libgcc_s.so.1
7fc6ec85c000-7fc6eca5b000 ---p 00015000 08:01 99091346                   /lib/x86_64-linux-gnu/libgcc_s.so.1
7fc6eca5b000-7fc6eca5c000 r--p 00014000 08:01 99091346                   /lib/x86_64-linux-gnu/libgcc_s.so.1
7fc6eca5c000-7fc6eca5d000 rw-p 00015000 08:01 99091346                   /lib/x86_64-linux-gnu/libgcc_s.so.1
7fc6eca5d000-7fc6ecb58000 r-xp 00000000 08:01 99098818                   /lib/x86_64-linux-gnu/libm-2.15.so
7fc6ecb58000-7fc6ecd57000 ---p 000fb000 08:01 99098818                   /lib/x86_64-linux-gnu/libm-2.15.so
7fc6ecd57000-7fc6ecd58000 r--p 000fa000 08:01 99098818                   /lib/x86_64-linux-gnu/libm-2.15.so
7fc6ecd58000-7fc6ecd59000 rw-p 000fb000 08:01 99098818                   /lib/x86_64-linux-gnu/libm-2.15.so
7fc6ecd59000-7fc6ece3f000 r-xp 00000000 08:01 108931703                  /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.18
7fc6ece3f000-7fc6ed03e000 ---p 000e6000 08:01 108931703                  /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.18
7fc6ed03e000-7fc6ed046000 r--p 000e5000 08:01 108931703                  /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.18
7fc6ed046000-7fc6ed048000 rw-p 000ed000 08:01 108931703                  /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.18
7fc6ed048000-7fc6ed05d000 rw-p 00000000 00:00 0 
7fc6ed05d000-7fc6ed07f000 r-xp 00000000 08:01 99098819                   /lib/x86_64-linux-gnu/ld-2.15.so
7fc6ed25d000-7fc6ed262000 rw-p 00000000 00:00 0 
7fc6ed27b000-7fc6ed27f000 rw-p 00000000 00:00 0 
7fc6ed27f000-7fc6ed280000 r--p 00022000 08:01 99098819                   /lib/x86_64-linux-gnu/ld-2.15.so
7fc6ed280000-7fc6ed282000 rw-p 00023000 08:01 99098819                   /lib/x86_64-linux-gnu/ld-2.15.so
7fc6ed400000-7fc72bc00000 rw-p 00000000 00:0c 22936                      /anon_hugepage (deleted)
7fffa8619000-7fffa863a000 rw-p 00000000 00:00 0                          [stack]
7fffa868e000-7fffa868f000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
已經終止 (core dumped)

Is there any error when I use the command?

@mpetri
Copy link
Collaborator

mpetri commented Nov 25, 2013

I'll investigate this and get back to you. I'm getting the same error.

@mpetri
Copy link
Collaborator

mpetri commented Nov 27, 2013

I found the bug (#135) you encountered and fixed it. in 2-3 hours you should be able to pull the current version and it hopefully will work. let me if you have any other problems.

@bruce3557
Copy link
Collaborator Author

I've tested on my computer and it worked so great.
Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants