Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm running java server on Red Hat Enterprise Linux Server release 5.9. Recently I started to use HugePages as it has some advantages I would like to use. System was configured correctly (as many sites and blog states) and 40G of RAM was set for hugepages to use.

HugePages_Total: 20480

HugePages_Free: 20480

HugePages_Rsvd: 0

Hugepagesize: 2048 kB

Total RAM on server: 128G. After setting hugePages machine was rebooted and server process started in hugePages with Heap size of 29G. All went smooth. Lately I did some changes in jvm parameters and increased Heap size to 30G. When jvm process was restarted it did not used hugepages. Error in log showed up:

Java HotSpot(TM) Server VM warning: Failed to reserve shared memory (errno = 22)

I did some testing to make sure that other changes in java parameters did not caused this and conclusion was that increasing heap size was the reason.

Now I don't get it. System shows no hugePages used at all, so 40G of space left and still java can't reserve 30G of it.

Can anybody explain why this is happening?

More important is there any way to make sure that it won't happen in the future?

This is production system so if I create final configuration it won't be able to run java process outside hugePages as there will be no space left. Final config will be 96G of hugePages with one 32GB java process working constantly and with reserve resources to run two more such processes in case of emergency. I have to make sure that when such emergency happens java processes will be able to use hugePages.

Any help would be great.

share|improve this question

2 Answers 2

I believe you need to explicitly enable hugepages usage in the JVM with -XX:+UseLargePages, check this article on Tuning big java heap and Linux huge pages.

You might want to check out the other related JVM switches.

share|improve this answer

Also, you should check the 'memlock' parameter in /etc/security/limits.conf. If that parameter is not set to a high enough value, for the user that's executing the JVM, that user will not be able to allocate the hugepages, even if there are enough of them configured. (Make sure memlock is set to at least 30GB, if that's what you're trying to allocate.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.