Blame SOURCES/kvm-spapr-Allow-some-cases-where-we-can-t-set-VSMT-mode-.patch

4a2fec
From 689db60fc3f20c8aea0d5f382eb7d4de87e6bb3f Mon Sep 17 00:00:00 2001
4a2fec
From: David Gibson <dgibson@redhat.com>
4a2fec
Date: Fri, 19 Jan 2018 04:04:57 +0100
4a2fec
Subject: [PATCH 17/21] spapr: Allow some cases where we can't set VSMT mode in
4a2fec
 the kernel
4a2fec
4a2fec
RH-Author: David Gibson <dgibson@redhat.com>
4a2fec
Message-id: <20180119040458.5629-4-dgibson@redhat.com>
4a2fec
Patchwork-id: 78678
4a2fec
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 3/4] spapr: Allow some cases where we can't set VSMT mode in the kernel
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
At present if we require a vsmt mode that's not equal to the kernel's
4a2fec
default, and the kernel doesn't let us change it (e.g. because it's an old
4a2fec
kernel without support) then we always fail.
4a2fec
4a2fec
But in fact we can cope with the kernel having a different vsmt as long as
4a2fec
  a) it's >= the actual number of vthreads/vcore (so that guest threads
4a2fec
     that are supposed to be on the same core act like it)
4a2fec
  b) it's a submultiple of the requested vsmt mode (so that guest threads
4a2fec
     spaced by the vsmt value will act like they're on different cores)
4a2fec
4a2fec
Allowing this case gives us a bit more freedom to adjust the vsmt behaviour
4a2fec
without breaking existing cases.
4a2fec
4a2fec
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4a2fec
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
Tested-by: Greg Kurz <groug@kaod.org>
4a2fec
Reviewed-by: Greg Kurz <groug@kaod.org>
4a2fec
(cherry picked from commit 1f20f2e0ee61d91abff4e86ed1cda1b5244647d3)
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 | 26 +++++++++++++++++++-------
4a2fec
 1 file changed, 19 insertions(+), 7 deletions(-)
4a2fec
4a2fec
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
4a2fec
index 5233366..1086b5a 100644
4a2fec
--- a/hw/ppc/spapr.c
4a2fec
+++ b/hw/ppc/spapr.c
4a2fec
@@ -2263,17 +2263,29 @@ static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp)
4a2fec
     if (kvm_enabled() && (spapr->vsmt != kvm_smt)) {
4a2fec
         ret = kvmppc_set_smt_threads(spapr->vsmt);
4a2fec
         if (ret) {
4a2fec
+            /* Looks like KVM isn't able to change VSMT mode */
4a2fec
             error_setg(&local_err,
4a2fec
                        "Failed to set KVM's VSMT mode to %d (errno %d)",
4a2fec
                        spapr->vsmt, ret);
4a2fec
-            if (!vsmt_user) {
4a2fec
-                error_append_hint(&local_err, "On PPC, a VM with %d threads/"
4a2fec
-                             "core on a host with %d threads/core requires "
4a2fec
-                             " the use of VSMT mode %d.\n",
4a2fec
-                             smp_threads, kvm_smt, spapr->vsmt);
4a2fec
+            /* We can live with that if the default one is big enough
4a2fec
+             * for the number of threads, and a submultiple of the one
4a2fec
+             * we want.  In this case we'll waste some vcpu ids, but
4a2fec
+             * behaviour will be correct */
4a2fec
+            if ((kvm_smt >= smp_threads) && ((spapr->vsmt % kvm_smt) == 0)) {
4a2fec
+                warn_report_err(local_err);
4a2fec
+                local_err = NULL;
4a2fec
+                goto out;
4a2fec
+            } else {
4a2fec
+                if (!vsmt_user) {
4a2fec
+                    error_append_hint(&local_err,
4a2fec
+                                      "On PPC, a VM with %d threads/core"
4a2fec
+                                      " on a host with %d threads/core"
4a2fec
+                                      " requires the use of VSMT mode %d.\n",
4a2fec
+                                      smp_threads, kvm_smt, spapr->vsmt);
4a2fec
+                }
4a2fec
+                kvmppc_hint_smt_possible(&local_err);
4a2fec
+                goto out;
4a2fec
             }
4a2fec
-            kvmppc_hint_smt_possible(&local_err);
4a2fec
-            goto out;
4a2fec
         }
4a2fec
     }
4a2fec
     /* else TCG: nothing to do currently */
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec