Blame SOURCES/libvirt-qemu-domain-Simplify-non-VFIO-memLockLimit-calculation-for-PPC64.patch

9c6c51
From 18f38f4aee3a3472f5e50786ee221d8d397bc6a8 Mon Sep 17 00:00:00 2001
9c6c51
Message-Id: <18f38f4aee3a3472f5e50786ee221d8d397bc6a8@dist-git>
9c6c51
From: Daniel Henrique Barboza <danielhb413@gmail.com>
9c6c51
Date: Fri, 3 May 2019 13:54:50 +0200
9c6c51
Subject: [PATCH] qemu: domain: Simplify non-VFIO memLockLimit calculation for
9c6c51
 PPC64
9c6c51
9c6c51
@passthroughLimit is being calculated even if @usesVFIO is false. After
9c6c51
that, an if-else conditional is used to check if we're going to sum it
9c6c51
up with @baseLimit.
9c6c51
9c6c51
This patch initializes @passthroughLimit to zero and always returns
9c6c51
@memKB = @baseLimit + @passthroughLimit. The conditional is then used to
9c6c51
calculate @passthroughLimit if @usesVFIO == true. This results in some
9c6c51
cycles being spared for the @usesVFIO == false scenario, but the real
9c6c51
motivation is to make the code simpler to add an alternative formula to
9c6c51
calculate @passthroughLimit for NVLink2.
9c6c51
9c6c51
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
9c6c51
Reviewed-by: Erik Skultety <eskultet@redhat.com>
9c6c51
(cherry picked from commit cf7c5212876b2403de5b0fafedec33af4439526e)
9c6c51
9c6c51
https: //bugzilla.redhat.com/show_bug.cgi?id=1505998
9c6c51
Signed-off-by: Erik Skultety <eskultet@redhat.com>
9c6c51
Message-Id: <a6380e14dfb1c8cb463f5e3eb25bda78dc9d7dd8.1556884442.git.eskultet@redhat.com>
9c6c51
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
9c6c51
---
9c6c51
 src/qemu/qemu_domain.c | 13 +++++--------
9c6c51
 1 file changed, 5 insertions(+), 8 deletions(-)
9c6c51
9c6c51
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
9c6c51
index cc2a896a07..d936090d87 100644
9c6c51
--- a/src/qemu/qemu_domain.c
9c6c51
+++ b/src/qemu/qemu_domain.c
9c6c51
@@ -9840,7 +9840,7 @@ qemuDomainGetMemLockLimitBytes(virDomainDefPtr def)
9c6c51
         unsigned long long maxMemory;
9c6c51
         unsigned long long memory;
9c6c51
         unsigned long long baseLimit;
9c6c51
-        unsigned long long passthroughLimit;
9c6c51
+        unsigned long long passthroughLimit = 0;
9c6c51
         size_t nPCIHostBridges = 0;
9c6c51
         bool usesVFIO = false;
9c6c51
 
9c6c51
@@ -9906,15 +9906,12 @@ qemuDomainGetMemLockLimitBytes(virDomainDefPtr def)
9c6c51
          * kiB pages, less still if the guest is mapped with hugepages (unlike
9c6c51
          * the default 32-bit DMA window, DDW windows can use large IOMMU
9c6c51
          * pages). 8 MiB is for second and further level overheads, like (b) */
9c6c51
-        passthroughLimit = MAX(2 * 1024 * 1024 * nPCIHostBridges,
9c6c51
-                               memory +
9c6c51
-                               memory / 512 * nPCIHostBridges + 8192);
9c6c51
-
9c6c51
         if (usesVFIO)
9c6c51
-            memKB = baseLimit + passthroughLimit;
9c6c51
-        else
9c6c51
-            memKB = baseLimit;
9c6c51
+            passthroughLimit = MAX(2 * 1024 * 1024 * nPCIHostBridges,
9c6c51
+                                   memory +
9c6c51
+                                   memory / 512 * nPCIHostBridges + 8192);
9c6c51
 
9c6c51
+        memKB = baseLimit + passthroughLimit;
9c6c51
         goto done;
9c6c51
     }
9c6c51
 
9c6c51
-- 
9c6c51
2.21.0
9c6c51