All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] target/i386/cpu: Misc cleanup for warning message
@ 2024-03-27 10:39 Zhao Liu
  2024-03-27 10:39 ` [PATCH 1/3] target/i386/host-cpu: Consolidate the use of warn_report_once() Zhao Liu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Zhao Liu @ 2024-03-27 10:39 UTC (permalink / raw
  To: Paolo Bonzini; +Cc: qemu-devel, Zhao Liu

From: Zhao Liu <zhao1.liu@intel.com>

Hi Paolo and list,

In i386, there're 2 cases useing static variables to implement warning
only once.

So consolidate the use of warn_report_once() in i386 part. (Based on
the commit 5012e522aca1 "Update version for v9.0.0-rc1 release")

Thanks and Best Regards,
Zhao
---
Zhao Liu (3):
  target/i386/host-cpu: Consolidate the use of warn_report_once()
  target/i386/cpu: Consolidate the use of warn_report_once()
  target/i386/cpu: Merge the warning and error messages for AMD HT check

 target/i386/cpu.c      | 13 +++++--------
 target/i386/host-cpu.c | 11 ++++-------
 2 files changed, 9 insertions(+), 15 deletions(-)

-- 
2.34.1



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

* [PATCH 1/3] target/i386/host-cpu: Consolidate the use of warn_report_once()
  2024-03-27 10:39 [PATCH 0/3] target/i386/cpu: Misc cleanup for warning message Zhao Liu
@ 2024-03-27 10:39 ` Zhao Liu
  2024-03-27 10:39 ` [PATCH 2/3] target/i386/cpu: " Zhao Liu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Zhao Liu @ 2024-03-27 10:39 UTC (permalink / raw
  To: Paolo Bonzini; +Cc: qemu-devel, Zhao Liu

From: Zhao Liu <zhao1.liu@intel.com>

Use warn_report_once() to get rid of the static local variable "warned".

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 target/i386/host-cpu.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/target/i386/host-cpu.c b/target/i386/host-cpu.c
index 92ecb7254b83..280e427c017c 100644
--- a/target/i386/host-cpu.c
+++ b/target/i386/host-cpu.c
@@ -55,18 +55,15 @@ static uint32_t host_cpu_adjust_phys_bits(X86CPU *cpu)
 {
     uint32_t host_phys_bits = host_cpu_phys_bits();
     uint32_t phys_bits = cpu->phys_bits;
-    static bool warned;
 
     /*
      * Print a warning if the user set it to a value that's not the
      * host value.
      */
-    if (phys_bits != host_phys_bits && phys_bits != 0 &&
-        !warned) {
-        warn_report("Host physical bits (%u)"
-                    " does not match phys-bits property (%u)",
-                    host_phys_bits, phys_bits);
-        warned = true;
+    if (phys_bits != host_phys_bits && phys_bits != 0) {
+        warn_report_once("Host physical bits (%u)"
+                         " does not match phys-bits property (%u)",
+                         host_phys_bits, phys_bits);
     }
 
     if (cpu->host_phys_bits) {
-- 
2.34.1



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

* [PATCH 2/3] target/i386/cpu: Consolidate the use of warn_report_once()
  2024-03-27 10:39 [PATCH 0/3] target/i386/cpu: Misc cleanup for warning message Zhao Liu
  2024-03-27 10:39 ` [PATCH 1/3] target/i386/host-cpu: Consolidate the use of warn_report_once() Zhao Liu
@ 2024-03-27 10:39 ` Zhao Liu
  2024-03-27 10:39 ` [PATCH 3/3] target/i386/cpu: Merge the warning and error messages for AMD HT check Zhao Liu
  2024-04-17  8:34 ` [PATCH 0/3] target/i386/cpu: Misc cleanup for warning message Paolo Bonzini
  3 siblings, 0 replies; 5+ messages in thread
From: Zhao Liu @ 2024-03-27 10:39 UTC (permalink / raw
  To: Paolo Bonzini; +Cc: qemu-devel, Zhao Liu

From: Zhao Liu <zhao1.liu@intel.com>

The difference between error_printf() and error_report() is the latter
may contain more information, such as the name of the program
("qemu-system-x86_64").

Thus its variant error_report_once() and warn_report()'s variant
warn_report_once() can be used here to print the information only once
without a static local variable "ht_warned".

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 target/i386/cpu.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 33760a2ee163..0487469d75f3 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -7230,7 +7230,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
     X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
     CPUX86State *env = &cpu->env;
     Error *local_err = NULL;
-    static bool ht_warned;
     unsigned requested_lbr_fmt;
 
 #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
@@ -7453,13 +7452,11 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
      */
     if (IS_AMD_CPU(env) &&
         !(env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_TOPOEXT) &&
-        cs->nr_threads > 1 && !ht_warned) {
-            warn_report("This family of AMD CPU doesn't support "
-                        "hyperthreading(%d)",
-                        cs->nr_threads);
-            error_printf("Please configure -smp options properly"
-                         " or try enabling topoext feature.\n");
-            ht_warned = true;
+        cs->nr_threads > 1) {
+            warn_report_once("This family of AMD CPU doesn't support "
+                             "hyperthreading(%d).", cs->nr_threads);
+            error_report_once("Please configure -smp options properly"
+                              " or try enabling topoext feature.");
     }
 
 #ifndef CONFIG_USER_ONLY
-- 
2.34.1



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

* [PATCH 3/3] target/i386/cpu: Merge the warning and error messages for AMD HT check
  2024-03-27 10:39 [PATCH 0/3] target/i386/cpu: Misc cleanup for warning message Zhao Liu
  2024-03-27 10:39 ` [PATCH 1/3] target/i386/host-cpu: Consolidate the use of warn_report_once() Zhao Liu
  2024-03-27 10:39 ` [PATCH 2/3] target/i386/cpu: " Zhao Liu
@ 2024-03-27 10:39 ` Zhao Liu
  2024-04-17  8:34 ` [PATCH 0/3] target/i386/cpu: Misc cleanup for warning message Paolo Bonzini
  3 siblings, 0 replies; 5+ messages in thread
From: Zhao Liu @ 2024-03-27 10:39 UTC (permalink / raw
  To: Paolo Bonzini; +Cc: qemu-devel, Zhao Liu

From: Zhao Liu <zhao1.liu@intel.com>

Currently, the difference between warn_report_once() and
error_report_once() is the former has the "warning:" prefix, while the
latter does not have a similar level prefix.

At the meantime, considering that there is no error handling logic here,
and the purpose of error_report_once() is only to prompt the user with
an abnormal message, there is no need to use an error-level message here,
and instead we can just use a warning.

Therefore, downgrade the message in error_report_once() to warning, and
merge it into the previous warn_report_once().

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 target/i386/cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 0487469d75f3..ec2787197d42 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -7454,9 +7454,9 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
         !(env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_TOPOEXT) &&
         cs->nr_threads > 1) {
             warn_report_once("This family of AMD CPU doesn't support "
-                             "hyperthreading(%d).", cs->nr_threads);
-            error_report_once("Please configure -smp options properly"
-                              " or try enabling topoext feature.");
+                             "hyperthreading(%d). Please configure -smp "
+                             "options properly or try enabling topoext "
+                             "feature.", cs->nr_threads);
     }
 
 #ifndef CONFIG_USER_ONLY
-- 
2.34.1



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

* Re: [PATCH 0/3] target/i386/cpu: Misc cleanup for warning message
  2024-03-27 10:39 [PATCH 0/3] target/i386/cpu: Misc cleanup for warning message Zhao Liu
                   ` (2 preceding siblings ...)
  2024-03-27 10:39 ` [PATCH 3/3] target/i386/cpu: Merge the warning and error messages for AMD HT check Zhao Liu
@ 2024-04-17  8:34 ` Paolo Bonzini
  3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2024-04-17  8:34 UTC (permalink / raw
  To: Zhao Liu; +Cc: qemu-devel, Zhao Liu

Queued, thanks.

Paolo



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

end of thread, other threads:[~2024-04-17  9:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-27 10:39 [PATCH 0/3] target/i386/cpu: Misc cleanup for warning message Zhao Liu
2024-03-27 10:39 ` [PATCH 1/3] target/i386/host-cpu: Consolidate the use of warn_report_once() Zhao Liu
2024-03-27 10:39 ` [PATCH 2/3] target/i386/cpu: " Zhao Liu
2024-03-27 10:39 ` [PATCH 3/3] target/i386/cpu: Merge the warning and error messages for AMD HT check Zhao Liu
2024-04-17  8:34 ` [PATCH 0/3] target/i386/cpu: Misc cleanup for warning message Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.