QEMU-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] spapr: Fix VSMT mode when it is not supported by the kernel
@ 2019-11-08 15:40 Laurent Vivier
  2019-11-08 16:47 ` Greg Kurz
  0 siblings, 1 reply; 4+ messages in thread
From: Laurent Vivier @ 2019-11-08 15:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Lukáš Doktor, Juan Quintela, Greg Kurz,
	Dr . David Alan Gilbert, qemu-ppc, clg, David Gibson

Commit 29cb4187497d sets by default the VSMT to smp_threads,
but older kernels (< 4.13) don't support that.

We can reasonably restore previous behavior with this kernel
to allow to run QEMU as before.

If VSMT is not supported, VSMT will be set to MAX(8, smp_threads)
as it is done for previous machine types (< pseries-4.2)

Fixes: 29cb4187497d ("spapr: Set VSMT to smp_threads by default")
Cc: groug@kaod.org
Reported-by: Lukáš Doktor <ldoktor@redhat.com>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 hw/ppc/spapr.c       | 2 +-
 target/ppc/kvm.c     | 5 +++++
 target/ppc/kvm_ppc.h | 6 ++++++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 94f9d27096af..f6c8ad1eda32 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2522,7 +2522,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
             goto out;
         }
         /* In this case, spapr->vsmt has been set by the command line */
-    } else if (!smc->smp_threads_vsmt) {
+    } else if (!smc->smp_threads_vsmt || !kvmppc_check_smt_possible()) {
         /*
          * Default VSMT value is tricky, because we need it to be as
          * consistent as possible (for migration), but this requires
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 7d2e8969ac5f..40ed59881167 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -2060,6 +2060,11 @@ void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
     }
 }
 
+bool kvmppc_check_smt_possible(void)
+{
+    return kvm_enabled() && cap_ppc_smt_possible;
+}
+
 int kvmppc_smt_threads(void)
 {
     return cap_ppc_smt ? cap_ppc_smt : 1;
diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index 98bd7d5da6d6..c9629a416b0b 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -27,6 +27,7 @@ void kvmppc_enable_h_page_init(void);
 void kvmppc_set_papr(PowerPCCPU *cpu);
 int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr);
 void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy);
+bool kvmppc_check_smt_possible(void);
 int kvmppc_smt_threads(void);
 void kvmppc_hint_smt_possible(Error **errp);
 int kvmppc_set_smt_threads(int smt);
@@ -159,6 +160,11 @@ static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
 {
 }
 
+static inline bool kvmppc_check_smt_possible(void)
+{
+    return false;
+}
+
 static inline int kvmppc_smt_threads(void)
 {
     return 1;
-- 
2.21.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] spapr: Fix VSMT mode when it is not supported by the kernel
  2019-11-08 15:40 [PATCH] spapr: Fix VSMT mode when it is not supported by the kernel Laurent Vivier
@ 2019-11-08 16:47 ` Greg Kurz
  2019-11-08 17:03   ` Laurent Vivier
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kurz @ 2019-11-08 16:47 UTC (permalink / raw)
  To: Laurent Vivier
  Cc: Lukáš Doktor, Juan Quintela, qemu-devel,
	Dr . David Alan Gilbert, qemu-ppc, clg, David Gibson

On Fri,  8 Nov 2019 16:40:35 +0100
Laurent Vivier <lvivier@redhat.com> wrote:

> Commit 29cb4187497d sets by default the VSMT to smp_threads,
> but older kernels (< 4.13) don't support that.
> 
> We can reasonably restore previous behavior with this kernel
> to allow to run QEMU as before.
> 
> If VSMT is not supported, VSMT will be set to MAX(8, smp_threads)
> as it is done for previous machine types (< pseries-4.2)
> 

It is usually _bad_ to base the machine behavior on host capabilities.
What happens if we migrate between an older kernel and a recent one ?

I understand this is to fix tests/migration-test on older kernels.
Couldn't this be achieved with migration-test doing some introspection
and maybe pass vsmt=8 on the QEMU command line ?

> Fixes: 29cb4187497d ("spapr: Set VSMT to smp_threads by default")
> Cc: groug@kaod.org
> Reported-by: Lukáš Doktor <ldoktor@redhat.com>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>  hw/ppc/spapr.c       | 2 +-
>  target/ppc/kvm.c     | 5 +++++
>  target/ppc/kvm_ppc.h | 6 ++++++
>  3 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 94f9d27096af..f6c8ad1eda32 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -2522,7 +2522,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
>              goto out;
>          }
>          /* In this case, spapr->vsmt has been set by the command line */
> -    } else if (!smc->smp_threads_vsmt) {
> +    } else if (!smc->smp_threads_vsmt || !kvmppc_check_smt_possible()) {
>          /*
>           * Default VSMT value is tricky, because we need it to be as
>           * consistent as possible (for migration), but this requires
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index 7d2e8969ac5f..40ed59881167 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -2060,6 +2060,11 @@ void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
>      }
>  }
>  
> +bool kvmppc_check_smt_possible(void)
> +{
> +    return kvm_enabled() && cap_ppc_smt_possible;
> +}
> +
>  int kvmppc_smt_threads(void)
>  {
>      return cap_ppc_smt ? cap_ppc_smt : 1;
> diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
> index 98bd7d5da6d6..c9629a416b0b 100644
> --- a/target/ppc/kvm_ppc.h
> +++ b/target/ppc/kvm_ppc.h
> @@ -27,6 +27,7 @@ void kvmppc_enable_h_page_init(void);
>  void kvmppc_set_papr(PowerPCCPU *cpu);
>  int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr);
>  void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy);
> +bool kvmppc_check_smt_possible(void);
>  int kvmppc_smt_threads(void);
>  void kvmppc_hint_smt_possible(Error **errp);
>  int kvmppc_set_smt_threads(int smt);
> @@ -159,6 +160,11 @@ static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
>  {
>  }
>  
> +static inline bool kvmppc_check_smt_possible(void)
> +{
> +    return false;
> +}
> +
>  static inline int kvmppc_smt_threads(void)
>  {
>      return 1;



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] spapr: Fix VSMT mode when it is not supported by the kernel
  2019-11-08 16:47 ` Greg Kurz
@ 2019-11-08 17:03   ` Laurent Vivier
  2019-11-08 17:23     ` Greg Kurz
  0 siblings, 1 reply; 4+ messages in thread
From: Laurent Vivier @ 2019-11-08 17:03 UTC (permalink / raw)
  To: Greg Kurz
  Cc: Lukáš Doktor, Juan Quintela, qemu-devel,
	Dr . David Alan Gilbert, qemu-ppc, clg, David Gibson

On 08/11/2019 17:47, Greg Kurz wrote:
> On Fri,  8 Nov 2019 16:40:35 +0100
> Laurent Vivier <lvivier@redhat.com> wrote:
> 
>> Commit 29cb4187497d sets by default the VSMT to smp_threads,
>> but older kernels (< 4.13) don't support that.
>>
>> We can reasonably restore previous behavior with this kernel
>> to allow to run QEMU as before.
>>
>> If VSMT is not supported, VSMT will be set to MAX(8, smp_threads)
>> as it is done for previous machine types (< pseries-4.2)
>>
> 
> It is usually _bad_ to base the machine behavior on host capabilities.

This is already the case, statically: your patch guesses the kernel
always support VSMT. So you can't start the machine (and thus can't
migrate it to/from).

> What happens if we migrate between an older kernel and a recent one ?

I think migration is supported correctly only if parameters are
explicitly set. So this is not our case.

> I understand this is to fix tests/migration-test on older kernels.
> Couldn't this be achieved with migration-test doing some introspection
> and maybe pass vsmt=8 on the QEMU command line ?

It could be a little bit complicated to instrospect this.
We could also set by default vsmt=8 at the test level.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] spapr: Fix VSMT mode when it is not supported by the kernel
  2019-11-08 17:03   ` Laurent Vivier
@ 2019-11-08 17:23     ` Greg Kurz
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kurz @ 2019-11-08 17:23 UTC (permalink / raw)
  To: Laurent Vivier
  Cc: Lukáš Doktor, Juan Quintela, qemu-devel,
	Dr . David Alan Gilbert, qemu-ppc, clg, David Gibson

On Fri, 8 Nov 2019 18:03:08 +0100
Laurent Vivier <lvivier@redhat.com> wrote:

> On 08/11/2019 17:47, Greg Kurz wrote:
> > On Fri,  8 Nov 2019 16:40:35 +0100
> > Laurent Vivier <lvivier@redhat.com> wrote:
> > 
> >> Commit 29cb4187497d sets by default the VSMT to smp_threads,
> >> but older kernels (< 4.13) don't support that.
> >>
> >> We can reasonably restore previous behavior with this kernel
> >> to allow to run QEMU as before.
> >>
> >> If VSMT is not supported, VSMT will be set to MAX(8, smp_threads)
> >> as it is done for previous machine types (< pseries-4.2)
> >>
> > 
> > It is usually _bad_ to base the machine behavior on host capabilities.
> 
> This is already the case, statically: your patch guesses the kernel
> always support VSMT. So you can't start the machine (and thus can't
> migrate it to/from).
> 

Failing to start the machine is okay. The thing we want to avoid is
to successfully start the guest and discover later on we cannot
migrate it.

> > What happens if we migrate between an older kernel and a recent one ?
> 
> I think migration is supported correctly only if parameters are
> explicitly set. So this is not our case.
> 

Hence my suggestion to introspect...

> > I understand this is to fix tests/migration-test on older kernels.
> > Couldn't this be achieved with migration-test doing some introspection
> > and maybe pass vsmt=8 on the QEMU command line ?
> 
> It could be a little bit complicated to instrospect this.

... ah, you likely know migration-test better than I do :)

> We could also set by default vsmt=8 at the test level.
> 

This would mean that we don't test an exact default setup, but this
would still test most of the migration paths. I guess this could be
an acceptable trade-off only if 'make check' must *really* support
older kernels.

> Thanks,
> Laurent
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08 15:40 [PATCH] spapr: Fix VSMT mode when it is not supported by the kernel Laurent Vivier
2019-11-08 16:47 ` Greg Kurz
2019-11-08 17:03   ` Laurent Vivier
2019-11-08 17:23     ` Greg Kurz

QEMU-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/qemu-devel/0 qemu-devel/git/0.git
	git clone --mirror https://lore.kernel.org/qemu-devel/1 qemu-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 qemu-devel qemu-devel/ https://lore.kernel.org/qemu-devel \
		qemu-devel@nongnu.org
	public-inbox-index qemu-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.nongnu.qemu-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git