[PATCH] accel/tcg: Do not dump NaN statistics

Philippe Mathieu-Daudé posted 1 patch 4 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250710111303.8917-1-philmd@linaro.org
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>
accel/tcg/monitor.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
[PATCH] accel/tcg: Do not dump NaN statistics
Posted by Philippe Mathieu-Daudé 4 months, 1 week ago
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/monitor.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
index e7ed7281a4b..778b12613f4 100644
--- a/accel/tcg/monitor.c
+++ b/accel/tcg/monitor.c
@@ -19,7 +19,7 @@
 #include "tcg/tcg.h"
 #include "internal-common.h"
 #include "tb-context.h"
-
+#include <math.h>
 
 static void dump_drift_info(GString *buf)
 {
@@ -57,6 +57,7 @@ static void print_qht_statistics(struct qht_stats hst, GString *buf)
     uint32_t hgram_opts;
     size_t hgram_bins;
     char *hgram;
+    double avg;
 
     if (!hst.head_buckets) {
         return;
@@ -73,9 +74,13 @@ static void print_qht_statistics(struct qht_stats hst, GString *buf)
         hgram_opts |= QDIST_PR_NODECIMAL;
     }
     hgram = qdist_pr(&hst.occupancy, 10, hgram_opts);
-    g_string_append_printf(buf, "TB hash occupancy   %0.2f%% avg chain occ. "
-                           "Histogram: %s\n",
-                           qdist_avg(&hst.occupancy) * 100, hgram);
+    avg = qdist_avg(&hst.occupancy);
+    if (!isnan(avg)) {
+        g_string_append_printf(buf, "TB hash occupancy   "
+                                    "%0.2f%% avg chain occ. "
+                                    "Histogram: %s\n",
+                               avg * 100, hgram);
+    }
     g_free(hgram);
 
     hgram_opts = QDIST_PR_BORDER | QDIST_PR_LABELS;
@@ -87,9 +92,12 @@ static void print_qht_statistics(struct qht_stats hst, GString *buf)
         hgram_opts |= QDIST_PR_NODECIMAL | QDIST_PR_NOBINRANGE;
     }
     hgram = qdist_pr(&hst.chain, hgram_bins, hgram_opts);
-    g_string_append_printf(buf, "TB hash avg chain   %0.3f buckets. "
-                           "Histogram: %s\n",
-                           qdist_avg(&hst.chain), hgram);
+    avg = qdist_avg(&hst.chain);
+    if (!isnan(avg)) {
+        g_string_append_printf(buf, "TB hash avg chain   %0.3f buckets. "
+                                    "Histogram: %s\n",
+                               avg, hgram);
+    }
     g_free(hgram);
 }
 
-- 
2.49.0


Re: [PATCH] accel/tcg: Do not dump NaN statistics
Posted by Philippe Mathieu-Daudé 4 months ago
On 10/7/25 13:13, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   accel/tcg/monitor.c | 22 +++++++++++++++-------
>   1 file changed, 15 insertions(+), 7 deletions(-)

Queued, thanks.

Re: [PATCH] accel/tcg: Do not dump NaN statistics
Posted by Manos Pitsidianakis 4 months, 1 week ago
On Thu, Jul 10, 2025 at 2:13 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  accel/tcg/monitor.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
> index e7ed7281a4b..778b12613f4 100644
> --- a/accel/tcg/monitor.c
> +++ b/accel/tcg/monitor.c
> @@ -19,7 +19,7 @@
>  #include "tcg/tcg.h"
>  #include "internal-common.h"
>  #include "tb-context.h"
> -
> +#include <math.h>
>
>  static void dump_drift_info(GString *buf)
>  {
> @@ -57,6 +57,7 @@ static void print_qht_statistics(struct qht_stats hst, GString *buf)
>      uint32_t hgram_opts;
>      size_t hgram_bins;
>      char *hgram;
> +    double avg;
>
>      if (!hst.head_buckets) {
>          return;
> @@ -73,9 +74,13 @@ static void print_qht_statistics(struct qht_stats hst, GString *buf)
>          hgram_opts |= QDIST_PR_NODECIMAL;
>      }
>      hgram = qdist_pr(&hst.occupancy, 10, hgram_opts);
> -    g_string_append_printf(buf, "TB hash occupancy   %0.2f%% avg chain occ. "
> -                           "Histogram: %s\n",
> -                           qdist_avg(&hst.occupancy) * 100, hgram);
> +    avg = qdist_avg(&hst.occupancy);
> +    if (!isnan(avg)) {
> +        g_string_append_printf(buf, "TB hash occupancy   "
> +                                    "%0.2f%% avg chain occ. "
> +                                    "Histogram: %s\n",
> +                               avg * 100, hgram);
> +    }
>      g_free(hgram);
>
>      hgram_opts = QDIST_PR_BORDER | QDIST_PR_LABELS;
> @@ -87,9 +92,12 @@ static void print_qht_statistics(struct qht_stats hst, GString *buf)
>          hgram_opts |= QDIST_PR_NODECIMAL | QDIST_PR_NOBINRANGE;
>      }
>      hgram = qdist_pr(&hst.chain, hgram_bins, hgram_opts);
> -    g_string_append_printf(buf, "TB hash avg chain   %0.3f buckets. "
> -                           "Histogram: %s\n",
> -                           qdist_avg(&hst.chain), hgram);
> +    avg = qdist_avg(&hst.chain);
> +    if (!isnan(avg)) {
> +        g_string_append_printf(buf, "TB hash avg chain   %0.3f buckets. "
> +                                    "Histogram: %s\n",
> +                               avg, hgram);
> +    }
>      g_free(hgram);
>  }
>
> --
> 2.49.0
>

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>