Skip to contentSkip to conversation

hw/ppc/spapr: Test whether TCG is enabled with tcg_enabled()

PATCH In review Philippe Mathieu-Daudé 7 participants 8 messages Jun 20, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/ppc/spapr: Test whether TCG is enabled with tcg_enabled()

Although the PPC target only supports the TCG and KVM accelerators, QEMU supports more. We can no assume that '!kvm == tcg', so test for the correct accelerator. This also eases code review, because here we don't care about KVM, we really want to test for TCG.

---
 hw/ppc/spapr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr.c +1 -1
index dcb7f1c70a..c4b666587b 100644
@@ -2524,7 +2524,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
     int ret;
     unsigned int smp_threads = ms->smp.threads;
 
-    if (!kvm_enabled() && (smp_threads > 1)) {
+    if (tcg_enabled() && (smp_threads > 1)) {
         error_setg(errp, "TCG cannot support more than 1 thread/core "
                    "on a pseries machine");
         return;
Signature · 1 line
2.38.1
#1 lore raw
Quoted 7 lines · Philippe Mathieu-Daudé

Although the PPC target only supports the TCG and KVM accelerators, QEMU supports more. We can no assume that '!kvm == tcg', so test for the correct accelerator. This also eases code review, because here we don't care about KVM, we really want to test for TCG.

I don't remember anymore, but what about qtest ? It is usually the forgotten case in these kind of tests... so much complexity :-)

Ciao,

Claudio

Quoted 17 lines
---
 hw/ppc/spapr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr.c +1 -1
index dcb7f1c70a..c4b666587b 100644
@@ -2524,7 +2524,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
     int ret;
     unsigned int smp_threads = ms->smp.threads;
 
-    if (!kvm_enabled() && (smp_threads > 1)) {
+    if (tcg_enabled() && (smp_threads > 1)) {
         error_setg(errp, "TCG cannot support more than 1 thread/core "
                    "on a pseries machine");
         return;
Reviewed-by
#2 lore raw
Quoted 11 lines · On Tue, 20 Jun 2023 09:55:49 +0200 Claudio Fontana <[email protected]> wrote:
Quoted 7 lines · Philippe Mathieu-Daudé

Although the PPC target only supports the TCG and KVM accelerators, QEMU supports more. We can no assume that '!kvm == tcg', so test for the correct accelerator. This also eases code review, because here we don't care about KVM, we really want to test for TCG.

I don't remember anymore, but what about qtest ? It is usually the forgotten case in these kind of tests... so much complexity :-)

This check was added with TCG in mind because it is a known limitation. I don't see any reason to prevent qtest from being used with the rest of this function though.

Quoted 17 lines

Ciao,

Claudio

Quoted 12 lines
---
 hw/ppc/spapr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr.c +0 -0
index dcb7f1c70a..c4b666587b 100644
@@ -2524,7 +2524,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
     int ret;
     unsigned int smp_threads = ms->smp.threads;
 
Quoted 2 lines

hw/ppc/spapr.c static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp) · line 2527

Quoted 2 lines
hw/ppc/spapr.c +1 -1
-    if (!kvm_enabled() && (smp_threads > 1)) {
+    if (tcg_enabled() && (smp_threads > 1)) {

Bonjour Philippe,

Please drop the unneeded parens in the second check.

With this fixed,

Cheers,

--
Greg

Quoted 4 lines
Quoted 3 lines
hw/ppc/spapr.c +0 -0
         error_setg(errp, "TCG cannot support more than 1 thread/core "
                    "on a pseries machine");
         return;
Signature · 1 line
Greg
#3 lore raw
Quoted 10 lines · Greg Kurz
Quoted 7 lines · On Tue, 20 Jun 2023 09:55:49 +0200 Claudio Fontana <[email protected]> wrote:
Quoted 6 lines · Philippe Mathieu-Daudé

Although the PPC target only supports the TCG and KVM accelerators, QEMU supports more. We can no assume that '!kvm == tcg', so test for the correct accelerator. This also eases code review, because here we don't care about KVM, we really want to test for TCG.

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

I don't remember anymore, but what about qtest ? It is usually the forgotten case in these kind of tests... so much complexity :-)

Good to think about this, since such changes indeed usually break, qtests :)

Quoted 3 lines

This check was added with TCG in mind because it is a known limitation. I don't see any reason to prevent qtest from being used with the rest of this function though.

We don't have any CPU core when using qtest accelerator, so this check is irrelevant IMHO (not reachable with '-accel qtest').

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
---
  hw/ppc/spapr.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr.c +0 -0
index dcb7f1c70a..c4b666587b 100644
@@ -2524,7 +2524,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
      int ret;
      unsigned int smp_threads = ms->smp.threads;
 
Quoted 6 lines
Quoted 2 lines

hw/ppc/spapr.c static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp) · line 2527

Quoted 2 lines
hw/ppc/spapr.c +1 -1
-    if (!kvm_enabled() && (smp_threads > 1)) {
+    if (tcg_enabled() && (smp_threads > 1)) {

Bonjour Philippe,

Please drop the unneeded parens in the second check.

I wanted to do that but then thought someone would ask me to do one change at once ;)

Quoted 3 lines

With this fixed,

Thanks!

Reviewed-by on v1 1/1
#4 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 16 lines · Philippe Mathieu-Daudé

Although the PPC target only supports the TCG and KVM accelerators, QEMU supports more. We can no assume that '!kvm == tcg', so test for the correct accelerator. This also eases code review, because here we don't care about KVM, we really want to test for TCG.

---
  hw/ppc/spapr.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr.c +0 -0
index dcb7f1c70a..c4b666587b 100644

hw/ppc/spapr.c static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp) · line 2529

Quoted 7 lines
hw/ppc/spapr.c +1 -1
@@ -2524,7 +2524,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
      int ret;
      unsigned int smp_threads = ms->smp.threads;
 
-    if (!kvm_enabled() && (smp_threads > 1)) {
+    if (tcg_enabled() && (smp_threads > 1)) {
          error_setg(errp, "TCG cannot support more than 1 thread/core "
                     "on a pseries machine");
Quoted 1 line
hw/ppc/spapr.c +0 -0
          return;
Reviewed-by on v1 1/1
#5 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

Although the PPC target only supports the TCG and KVM accelerators, QEMU supports more. We can no assume that '!kvm == tcg', so test for the correct accelerator. This also eases code review, because here we don't care about KVM, we really want to test for TCG.

Quoted 9 lines
---
  hw/ppc/spapr.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr.c +0 -0
index dcb7f1c70a..c4b666587b 100644

hw/ppc/spapr.c static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp) · line 2530

Quoted 8 lines
hw/ppc/spapr.c +1 -1
@@ -2524,7 +2524,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
      int ret;
      unsigned int smp_threads = ms->smp.threads;
 
-    if (!kvm_enabled() && (smp_threads > 1)) {
+    if (tcg_enabled() && (smp_threads > 1)) {
          error_setg(errp, "TCG cannot support more than 1 thread/core "
                     "on a pseries machine");
          return;

Nick,

You might want to include this patch in the series adding SMT support to pseries/spapr :

https://patchew.org/QEMU/[email protected]/

C.

Reviewed-by on v1 1/1
#6 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

Although the PPC target only supports the TCG and KVM accelerators, QEMU supports more. We can no assume that '!kvm == tcg', so test for the correct accelerator. This also eases code review, because here we don't care about KVM, we really want to test for TCG.

Quoted 17 lines
---
 hw/ppc/spapr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr.c +1 -1
index dcb7f1c70a..c4b666587b 100644
@@ -2524,7 +2524,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
     int ret;
     unsigned int smp_threads = ms->smp.threads;
 
-    if (!kvm_enabled() && (smp_threads > 1)) {
+    if (tcg_enabled() && (smp_threads > 1)) {
         error_setg(errp, "TCG cannot support more than 1 thread/core "
                    "on a pseries machine");
         return;
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#7 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé

Although the PPC target only supports the TCG and KVM accelerators, QEMU supports more. We can no assume that

Typo: -> can not assume

Regards,
BALATON Zoltan

Quoted 23 lines

'!kvm == tcg', so test for the correct accelerator. This also eases code review, because here we don't care about KVM, we really want to test for TCG.

---
hw/ppc/spapr.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr.c +1 -1
index dcb7f1c70a..c4b666587b 100644
@@ -2524,7 +2524,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
    int ret;
    unsigned int smp_threads = ms->smp.threads;
 
-    if (!kvm_enabled() && (smp_threads > 1)) {
+    if (tcg_enabled() && (smp_threads > 1)) {
        error_setg(errp, "TCG cannot support more than 1 thread/core "
                   "on a pseries machine");
        return;