Increasing number of huge pages exhausted memory

1

On the box we have 38 GBs of memory. After I have set the number of huge pages (2048k) to 17290, I've found out that nearly all of the memory was used. But I didn't run any process. How could it be? Which number of huge pages should I set?

user710818

Posted 2014-08-04T12:23:44.383

Reputation: 340

Answers

1

You've reserved almost all your memory for huge tlb pages. That leaves almost no memory to store actual data. The recommend size is about 1/1,000th of what you've set it to.

David Schwartz

Posted 2014-08-04T12:23:44.383

Reputation: 58 310

My java application that uses near 35G and uses LargePages(-XX:+UseLargePages). So I guess that total space for huge pages should be near 35G. – user710818 – 2014-08-04T12:39:46.220

@user710818 The "number of huge pages" that you set has nothing to do with the number of huge pages the application uses. It has to do with the number of huge page TLBs used by the OS. – David Schwartz – 2014-08-04T12:40:49.203

So it should be 17 pages only? – user710818 – 2014-08-04T12:58:13.980

That's the recommendation. – David Schwartz – 2014-08-04T16:51:06.057

Downvote, because I think this answer is wrong and what has been seen is as expected: https://superuser.com/a/1327823/308859

– Thorsten Schöning – 2018-06-01T15:44:28.460

0

This question is old, but I think the other answer is wrong. Depending on how huge pages have been allocated exactly, if done properly at that time using

echo 17290 > /proc/sys/vm/nr_hugepages

or something like that, what has been seen was intended behaviour and is as documented. It is absolutely OK to reserve the number of huge pages one thinks is needed for ones workload and that almost all free memory is gone in the described scenario is as expected as well:

Pages that are used as huge pages are reserved inside the kernel and cannot be used for other purposes. Huge pages cannot be swapped out under memory pressure.

https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt

Others do exactly the same:

Set the vm.nr_hugepages kernel parameter to a suitable value. In this case, we decided to use 12GB and set the parameter to 6144 (6144*2M=12GB). You can run: echo 6144 > /proc/sys/vm/nr_hugepages

https://blog.pythian.com/performance-tuning-hugepages-in-linux/

Thorsten Schöning

Posted 2014-08-04T12:23:44.383

Reputation: 523