]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: domain: Simplify non-VFIO memLockLimit calculation for PPC64
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Tue, 5 Mar 2019 12:46:06 +0000 (09:46 -0300)
committerErik Skultety <eskultet@redhat.com>
Thu, 7 Mar 2019 14:15:02 +0000 (15:15 +0100)
@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>
src/qemu/qemu_domain.c

index 1487268a89d5946b80bee50d600bed41e8524c07..099097fe625088f8655540afeb2529b172f10475 100644 (file)
@@ -10378,7 +10378,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;
 
@@ -10444,15 +10444,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;
     }