<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linux-kvm.org/index.php?action=history&amp;feed=atom&amp;title=UsingLargePages</id>
	<title>UsingLargePages - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://linux-kvm.org/index.php?action=history&amp;feed=atom&amp;title=UsingLargePages"/>
	<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=UsingLargePages&amp;action=history"/>
	<updated>2026-04-30T16:23:58Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://linux-kvm.org/index.php?title=UsingLargePages&amp;diff=2192&amp;oldid=prev</id>
		<title>ShaharMintz at 14:32, 31 March 2009</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=UsingLargePages&amp;diff=2192&amp;oldid=prev"/>
		<updated>2009-03-31T14:32:22Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;To utilize Larges Pages in the host to back your KVM guest one needs to use hugetlbfs.  A little bit of setup is needed to get this going.&lt;br /&gt;
&lt;br /&gt;
= Host Kernel Config =&lt;br /&gt;
Your host kernel config needs to have:&lt;br /&gt;
&lt;br /&gt;
 CONFIG_HUGETLBFS=y&lt;br /&gt;
 CONFIG_HUGETLB_PAGE=y&lt;br /&gt;
&lt;br /&gt;
= Host /etc/fstab =&lt;br /&gt;
hugetlbfs is indeed a pseudo-filesystem, like tmpfs, so you need to mount it somewhere and add an entry to fstab if you want to automatically have it mounted on boot.&lt;br /&gt;
&lt;br /&gt;
 % sudo mkdir /hugetlbfs&lt;br /&gt;
&lt;br /&gt;
Add an entry to fstab like this:&lt;br /&gt;
&lt;br /&gt;
 hugetlbfs       /hugetlbfs  hugetlbfs       defaults        0 0&lt;br /&gt;
&lt;br /&gt;
= Calculate amount number of pages to reserve =&lt;br /&gt;
On x86, large pages are 2M, so determine the max size of the guest, and with some fudge factor (about 30 pages, completely arbitrary value); we have something like:&lt;br /&gt;
&lt;br /&gt;
 HPAGES = $(($GUEST_SIZE_IN_MB / 2) + 30)&lt;br /&gt;
&lt;br /&gt;
For example, a 2G guest would yield 1054 2MB pages.&lt;br /&gt;
&lt;br /&gt;
= Reserve large pages after boot =&lt;br /&gt;
&lt;br /&gt;
Take your calculated value and echo that into proc quickly after a fresh boot of the machine to ensure you haven&amp;#039;t fragmented your memory such that you can&amp;#039;t reserve enough large pages.&lt;br /&gt;
&lt;br /&gt;
 echo $HPAGES &amp;gt;  /proc/sys/vm/nr_hugepages&lt;br /&gt;
&lt;br /&gt;
= Check your reservation =&lt;br /&gt;
You can check whether or not your reservation was successful by looking at /proc/meminfo&lt;br /&gt;
&lt;br /&gt;
 % tail -n 5 /proc/meminfo&lt;br /&gt;
 HugePages_Total:  1054&lt;br /&gt;
 HugePages_Free:   1054&lt;br /&gt;
 HugePages_Rsvd:      0&lt;br /&gt;
 HugePages_Surp:      0&lt;br /&gt;
 Hugepagesize:     2048 kB&lt;br /&gt;
&lt;br /&gt;
= Using large page reservation =&lt;br /&gt;
&lt;br /&gt;
To use your large page reservation you need to add an option to your guest command line.  &amp;#039;-mem-path &amp;lt;path/to/hugetlbfs/mount/point&amp;gt;&amp;#039;  If you followed the above commands, then you would add &amp;#039;-mem-path /hugetlbfs&amp;#039;&lt;br /&gt;
&lt;br /&gt;
= Checking large page usage =&lt;br /&gt;
&lt;br /&gt;
After launching your guest with large pages, you can check that your guest is using the large pages by sampling the HugePages_Free value from /proc/meminfo.  This value should go down as your guest pages in memory.&lt;/div&gt;</summary>
		<author><name>ShaharMintz</name></author>
	</entry>
</feed>