Blame SOURCES/kvm-spapr-Adjust-default-VSMT-value-for-better-migration.patch

4a2fec
From 11a953b475cd0c30c661e8ce4cf4518405792b75 Mon Sep 17 00:00:00 2001
4a2fec
From: David Gibson <dgibson@redhat.com>
4a2fec
Date: Fri, 19 Jan 2018 04:04:58 +0100
4a2fec
Subject: [PATCH 18/21] spapr: Adjust default VSMT value for better migration
4a2fec
 compatibility
4a2fec
4a2fec
RH-Author: David Gibson <dgibson@redhat.com>
4a2fec
Message-id: <20180119040458.5629-5-dgibson@redhat.com>
4a2fec
Patchwork-id: 78679
4a2fec
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 4/4] spapr: Adjust default VSMT value for better migration compatibility
4a2fec
Bugzilla: 1529243
4a2fec
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4a2fec
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
4a2fec
From: David Gibson <david@gibson.dropbear.id.au>
4a2fec
4a2fec
fa98fbfc "PC: KVM: Support machine option to set VSMT mode" introduced the
4a2fec
"vsmt" parameter for the pseries machine type, which controls the spacing
4a2fec
of the vcpu ids of thread 0 for each virtual core.  This was done to bring
4a2fec
some consistency and stability to how that was done, while still allowing
4a2fec
backwards compatibility for migration and otherwise.
4a2fec
4a2fec
The default value we used for vsmt was set to the max of the host's
4a2fec
advertised default number of threads and the number of vthreads per vcore
4a2fec
in the guest.  This was done to continue running without extra parameters
4a2fec
on older KVM versions which don't allow the VSMT value to be changed.
4a2fec
4a2fec
Unfortunately, even that smaller than before leakage of host configuration
4a2fec
into guest visible configuration still breaks things.  Specifically a guest
4a2fec
with 4 (or less) vthread/vcore will get a different vsmt value when
4a2fec
running on a POWER8 (vsmt==8) and POWER9 (vsmt==4) host.  That means the
4a2fec
vcpu ids don't line up so you can't migrate between them, though you should
4a2fec
be able to.
4a2fec
4a2fec
Long term we really want to make vsmt == smp_threads for sufficiently
4a2fec
new machine types.  However, that means that qemu will then require a
4a2fec
sufficiently recent KVM (one which supports changing VSMT) - that's still
4a2fec
not widely enough deployed to be really comfortable to do.
4a2fec
4a2fec
In the meantime we need some default that will work as often as
4a2fec
possible.  This patch changes that default to 8 in all circumstances.
4a2fec
This does change guest visible behaviour (including for existing
4a2fec
machine versions) for many cases - just not the most common/important
4a2fec
case.
4a2fec
4a2fec
Following is case by case justification for why this is still the least
4a2fec
worst option.  Note that any of the old behaviours can still be duplicated
4a2fec
after this patch, it's just that it requires manual intervention by
4a2fec
setting the vsmt property on the command line.
4a2fec
4a2fec
KVM HV on POWER8 host:
4a2fec
   This is the overwhelmingly common case in production setups, and is
4a2fec
   unchanged by design.  POWER8 hosts will advertise a default VSMT mode
4a2fec
   of 8, and > 8 vthreads/vcore isn't permitted
4a2fec
4a2fec
KVM HV on POWER7 host:
4a2fec
   Will break, but POWER7s allowing KVM were never released to the public.
4a2fec
4a2fec
KVM HV on POWER9 host:
4a2fec
   Not yet released to the public, breaking this now will reduce other
4a2fec
   breakage later.
4a2fec
4a2fec
KVM HV on PowerPC 970:
4a2fec
   Will theoretically break it, but it was barely supported to begin with
4a2fec
   and already required various user visible hacks to work.  Also so old
4a2fec
   that I just don't care.
4a2fec
4a2fec
TCG:
4a2fec
   This is the nastiest one; it means migration of TCG guests (without
4a2fec
   manual vsmt setting) will break.  Since TCG is rarely used in production
4a2fec
   I think this is worth it for the other benefits.  It does also remove
4a2fec
   one more barrier to TCG<->KVM migration which could be interesting for
4a2fec
   debugging applications.
4a2fec
4a2fec
KVM PR:
4a2fec
   As with TCG, this will break migration of existing configurations,
4a2fec
   without adding extra manual vsmt options.  As with TCG, it is rare in
4a2fec
   production so I think the benefits outweigh breakages.
4a2fec
4a2fec
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4a2fec
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
Reviewed-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
4a2fec
Reviewed-by: Greg Kurz <groug@kaod.org>
4a2fec
(cherry picked from commit 8904e5a75005fe579c28806003892d8ae4a27dfa)
4a2fec
4a2fec
Signed-off-by: David Gibson <dgibson@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 hw/ppc/spapr.c | 11 ++++++++---
4a2fec
 1 file changed, 8 insertions(+), 3 deletions(-)
4a2fec
4a2fec
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
4a2fec
index 1086b5a..2bb3b61 100644
4a2fec
--- a/hw/ppc/spapr.c
4a2fec
+++ b/hw/ppc/spapr.c
4a2fec
@@ -2254,9 +2254,14 @@ static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp)
4a2fec
         }
4a2fec
         /* In this case, spapr->vsmt has been set by the command line */
4a2fec
     } else {
4a2fec
-        /* Choose a VSMT mode that may be higher than necessary but is
4a2fec
-         * likely to be compatible with hosts that don't have VSMT. */
4a2fec
-        spapr->vsmt = MAX(kvm_smt, smp_threads);
4a2fec
+        /*
4a2fec
+         * Default VSMT value is tricky, because we need it to be as
4a2fec
+         * consistent as possible (for migration), but this requires
4a2fec
+         * changing it for at least some existing cases.  We pick 8 as
4a2fec
+         * the value that we'd get with KVM on POWER8, the
4a2fec
+         * overwhelmingly common case in production systems.
4a2fec
+         */
4a2fec
+        spapr->vsmt = 8;
4a2fec
     }
4a2fec
 
4a2fec
     /* KVM: If necessary, set the SMT mode: */
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec