Re: [PATCH v3 5/5] qemu: Introduce memoryBacking/discard

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

 



On Thu, Apr 19, 2018 at 04:00:27PM +0200, Michal Privoznik wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1480668

QEMU has this new feature memory-backend-file.discard-data=yes
which is a nifty optimization. Basically, when qemu is quitting
or on memory hotplug it calls munmap() and close() on the file
that is backing the memory. However, this does not mean kernel
won't stop touching that part of memory. It still might. With
this feature enabled we tell kernel: "we don't need this memory
nor data stored in it". This makes kernel drop the memory
immediately without trying to sync memory with the mapped file.

Unfortunately, this cannot be turned on by default because we
can't be sure when users really don't care about what happens to
data after qemu dies. So it has to be opt-in. As usual, there are
three places where one can configure memory attributes. This
patch adds the feature to all of them.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
docs/formatdomain.html.in                    | 40 +++++++++++++++++++++++++---
docs/schemas/cputypes.rng                    |  5 ++++
docs/schemas/domaincommon.rng                | 10 +++++++
src/conf/domain_conf.c                       | 39 +++++++++++++++++++++++++--
src/conf/domain_conf.h                       |  3 +++
src/conf/numa_conf.c                         | 27 +++++++++++++++++++
src/conf/numa_conf.h                         |  3 +++
src/libvirt_private.syms                     |  1 +
src/qemu/qemu_command.c                      | 27 ++++++++++++++++---
tests/qemuxml2argvdata/hugepages-pages7.args |  3 ++-
tests/qemuxml2argvdata/hugepages-pages7.xml  |  4 +--
tests/qemuxml2argvtest.c                     |  3 ++-
12 files changed, 152 insertions(+), 13 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 5e99884dc5..d40536d06f 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1016,6 +1016,7 @@
    &lt;source type="file|anonymous"/&gt;
    &lt;access mode="shared|private"/&gt;
    &lt;allocation mode="immediate|ondemand"/&gt;
+    &lt;discard/&gt;
  &lt;/memoryBacking&gt;
  ...
&lt;/domain&gt;

@@ -1063,11 +1064,21 @@
        suitable for the specific environment at the same time to mitigate
        the risks described above. <span class="since">Since 1.0.6</span></dd>
       <dt><code>source</code></dt>
-       <dd>In this attribute you can switch to file memorybacking or keep default anonymous.</dd>
+       <dd>In this attribute you can switch to file memorybacking or keep
+         default anonymous.</dd>
       <dt><code>access</code></dt>
-       <dd>Specify if memory is shared or private. This can be overridden per numa node by <code>memAccess</code></dd>
+       <dd>Specify if memory is shared or private. This can be overridden per
+         numa node by <code>memAccess</code></dd>
       <dt><code>allocation</code></dt>

Unrelated trivial changes can be pushed separately.

       <dd>Specify when allocate the memory</dd>
+       <dt><code>discard</code></dt>
+       <dd>When set an supported by hypervisor the memory

s/an/and/

+         content is discarded just before guest shuts down (or
+         when DIMM module is unplugged). Please note that this is
+         just an optimization and is not guaranteed to work in
+         all cases (e.g. when hypervisor crashes).
+         <span class="since">Since 4.3.0</span> (QEMU/KVM only)
+       </dd>
    </dl>


@@ -1606,7 +1617,7 @@
&lt;cpu&gt;
  ...
  &lt;numa&gt;
-    &lt;cell id='0' cpus='0-3' memory='512000' unit='KiB'/&gt;
+    &lt;cell id='0' cpus='0-3' memory='512000' unit='KiB' discard='yes'/&gt;
    &lt;cell id='1' cpus='4-7' memory='512000' unit='KiB' memAccess='shared'/&gt;
  &lt;/numa&gt;
  ...
@@ -1632,6 +1643,13 @@
      <code>memAccess</code> can control whether the memory is to be
      mapped as "shared" or "private".  This is valid only for
      hugepages-backed memory and nvdimm modules.
+
+      Each <code>cell</code> element can have an optional
+      attribute <code>discard</code> which fine tunes the discard

'optional discard attribute' sounds better to me than 'optional
attribute discard', but it doesn't matter

+      feature for given numa node as described under
+      <a href="#elementsMemoryBacking">Memory Backing</a>.
+      Accepted values are <code>yes</code> and <code>no</code>.
+      <span class='since'>Since 4.3.0</span>
    </p>

    <p>

The rest looks good to me, but you might want Peter's opinion as well.

Jano

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux