[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [vfio-users] -realtime mlock=off or on?



On Wed, Sep 9, 2015 at 2:53 PM, Blank Field <ihatethisfield gmail com> wrote:

I've noted recently that libvirt adds -realtime mlock=off by default.
But in regular QEMU it's default on.
Moreover, i thought that using mlock is necessary for vfio.
Can someone clarify what is happenning there under the hood?

# /usr/libexec/qemu-kvm -help
...
-realtime [mlock=on|off]
                run qemu with realtime features
                mlock=on|off controls mlock support (default: on)

While that sort of implies that "-realtime" alone might do something, it doesn't appear to, it's just an identifier for options that are realtime-ish.  If you're running in a realtime environment, you don't want your pages to be swapped out and mlock does that, thus mlock=on.  If you want VM density, then you may want swappable VMs, thus mlock=off.

vfio also locks pages, but for other reasons, using other mechanisms, and it happens regardless of this QEMU option.  The short description is that the IOMMU maps physical addresses so VM pages need to be pinned to those physical addresses or else much badness would occur, including guest access to host kernel memory.  So, we can't rely on userspace to decide whether it should mlock the pages and we can't rely that a user's mlock will stick, because they could always munlock them later, so vfio's pinning happens independently, making the mlock QEMU option pretty much useless for a guest while an assigned device is present.  Of course you could always hot-unplug an assigned device and the vfio pinning would go away, and then your mlock setting would take effect.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]