<div dir="ltr"><span style="font-size:12.8px">I'm also interested in this. Running your 3 commands only gave me 3650 hugepages on a 32 GB system. I wonder if there is a way to have qemu use available hugepages first and then fall back on normal memory once depleted. </span><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 6, 2016 at 2:48 PM, Thomas Lindroth <span dir="ltr"><<a href="mailto:thomas.lindroth@gmail.com" target="_blank">thomas.lindroth@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hugetlbfs requires reservation of huge pages before files can be put on<br>
it. The easiest way of doing that is adding a hugepages argument to the<br>
kernel but that permanently reserves the pages and I don't want to waste<br>
8G of ram all the time. Another way is to dynamically allocate them by<br>
echoing 4096 into /proc/sys/vm/nr_hugepages but if the computer has been<br>
running for more than an hour I'll be lucky to get 20 pages like that.<br>
<br>
The physical ram is too fragmented for dynamic allocation of huge pages<br>
but there is a workaround. The quickest way to defragment a hard drive<br>
is to delete all files and the fastest way to defragment ram is do drop<br>
caches. By running echo 3 > /proc/sys/vm/drop_caches before echo 4096 ><br>
/proc/sys/vm/nr_hugepages the allocation is much more likely to succeed<br>
but not guaranteed. Application memory could still be too fragmented.<br>
For that I would echo 1 > /proc/sys/vm/compact_memory which should<br>
compact all free space into continuous areas. I've never tried to<br>
compact memory because cache dropping is usually enough when using 2M<br>
huge pages.<br>
<br>
Is there no better way of doing this? The kernel could selectively drop<br>
cache pages to make huge pages without dropping all caches and if that<br>
is not enough it could compact only the memory needed. I've looked for<br>
an option like that but I've haven't found anything. The closest thing<br>
I've seen is echo "always" >/sys/kernel/mm/transparent_hugepage/defrag<br>
but that is only for transparent huge pages.<br>
<br>
_______________________________________________<br>
vfio-users mailing list<br>
<a href="mailto:vfio-users@redhat.com">vfio-users@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/vfio-users" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/vfio-users</a><br>
</blockquote></div><br></div>