<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 19, 2022 at 4:08 AM Milan Zamazal <<a href="mailto:mzamazal@redhat.com">mzamazal@redhat.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> Not sure whether you already know this, but I had a hard time<br>
> differentiating the two concepts:<br>
> 1. memlock hard limit(shown by prlimit): the hard limit for locked host<br>
> memory<br>
> 2. memtune hard limit(memtune->hard_limit): the hard limit for in-use host<br>
> memory, this memory can be swapped out.<br>
<br>
No, I didn't know it, thank you for pointing this out.  Indeed, 2. is<br>
what both the libvirt and kernel documentation seem to say, although not<br>
so clearly.<br>
<br>
But when I add <memtune> with <hard_limit> to the domain XML and then<br>
start the VM, I can see the limit shown by `prlimit -l' is increased<br>
accordingly.  This is good for my use case, but does it match what you<br>
say about the two concepts?</blockquote><div>memtune->hard_limit(hard limit of in-use memory) actually takes effect via cgroup,</div><div>you can check the value by:</div><div># virsh memtune uefi1 <br>hard_limit     : 134217728<br>soft_limit     : unlimited<br>swap_hard_limit: unlimited<br># cat /sys/fs/cgroup/memory/machine.slice/machine-qemu\\x2d6\\x2duefi1.scope/libvirt/memory.limit_in_bytes <br>137438953472<br></div><div><br></div><div>When vm starts with memtune->hard_limit set in domain XML, memlock hard limit(</div><div>hard_limit of locked memory, shown by 'prlimit -l')will be set to the value of</div><div>memtune->hard_limit. This's probably because memlock hard limit must be less </div><div>than memtune->hard_limit.</div><div><br></div></div></div>