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

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