mirror of https://gitee.com/openkylin/libvirt.git
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>
This commit is contained in:
parent
a6aedcf39b
commit
cf7c521287
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue