render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From 18f38f4aee3a3472f5e50786ee221d8d397bc6a8 Mon Sep 17 00:00:00 2001
Message-Id: <18f38f4aee3a3472f5e50786ee221d8d397bc6a8@dist-git>
From: Daniel Henrique Barboza <danielhb413@gmail.com>
Date: Fri, 3 May 2019 13:54:50 +0200
Subject: [PATCH] qemu: domain: Simplify non-VFIO memLockLimit calculation for
 PPC64

@passthroughLimit is being calculated even if @usesVFIO is false. After
that, an if-else conditional is used to check if we're going to sum it
up with @baseLimit.

This patch initializes @passthroughLimit to zero and always returns
@memKB = @baseLimit + @passthroughLimit. The conditional is then used to
calculate @passthroughLimit if @usesVFIO == true. This results in some
cycles being spared for the @usesVFIO == false scenario, but the real
motivation is to make the code simpler to add an alternative formula to
calculate @passthroughLimit for NVLink2.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
(cherry picked from commit cf7c5212876b2403de5b0fafedec33af4439526e)

https: //bugzilla.redhat.com/show_bug.cgi?id=1505998
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Message-Id: <a6380e14dfb1c8cb463f5e3eb25bda78dc9d7dd8.1556884442.git.eskultet@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
---
 src/qemu/qemu_domain.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index cc2a896a07..d936090d87 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9840,7 +9840,7 @@ qemuDomainGetMemLockLimitBytes(virDomainDefPtr def)
         unsigned long long maxMemory;
         unsigned long long memory;
         unsigned long long baseLimit;
-        unsigned long long passthroughLimit;
+        unsigned long long passthroughLimit = 0;
         size_t nPCIHostBridges = 0;
         bool usesVFIO = false;
 
@@ -9906,15 +9906,12 @@ qemuDomainGetMemLockLimitBytes(virDomainDefPtr def)
          * kiB pages, less still if the guest is mapped with hugepages (unlike
          * the default 32-bit DMA window, DDW windows can use large IOMMU
          * pages). 8 MiB is for second and further level overheads, like (b) */
-        passthroughLimit = MAX(2 * 1024 * 1024 * nPCIHostBridges,
-                               memory +
-                               memory / 512 * nPCIHostBridges + 8192);
-
         if (usesVFIO)
-            memKB = baseLimit + passthroughLimit;
-        else
-            memKB = baseLimit;
+            passthroughLimit = MAX(2 * 1024 * 1024 * nPCIHostBridges,
+                                   memory +
+                                   memory / 512 * nPCIHostBridges + 8192);
 
+        memKB = baseLimit + passthroughLimit;
         goto done;
     }
 
-- 
2.21.0