[PATCH v17 07/16] accel/tcg: Collect TB jit statistics

Richard Henderson posted 16 patches 2 years, 4 months ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, "Dr. David Alan Gilbert" <dave@treblig.org>, Peter Xu <peterx@redhat.com>, David Hildenbrand <david@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Laurent Vivier <laurent@vivier.eu>, Nicholas Piggin <npiggin@gmail.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, "Cédric Le Goater" <clg@kaod.org>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>
[PATCH v17 07/16] accel/tcg: Collect TB jit statistics
Posted by Richard Henderson 2 years, 4 months ago
Collect items like input and output code size, guest instruction count,
intermediate ops, spills, etc.

Signed-off-by: Vanderson M. do Rosario <vandersonmr2@gmail.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Fei Wu <fei2.wu@intel.com>
[rth: Consolidated at the end of translation.]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 accel/tcg/translate-all.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 6e64ae2dbe..ad4538f169 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -557,6 +557,27 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
         return tb;
     }
 
+    /* Record JIT statistics, if required. */
+    if (unlikely(tb_stats_enabled & TB_STATS_JIT)) {
+        TBStatistics *s = tb->tb_stats;
+        if (s) {
+            s->code.num_tcg_ops += tcg_ctx->orig_nb_ops;
+            s->code.num_tcg_ops_opt += tcg_ctx->nb_ops;
+            s->code.temps += tcg_ctx->nb_temps;
+            s->code.deleted_ops += tcg_ctx->nb_deleted_ops;
+            s->code.spills += tcg_ctx->nb_spills;
+
+            s->code.num_guest_inst += tb->icount;
+            s->code.in_len += tb->size;
+            s->code.out_len += tb->tc.size;
+            s->code.search_out_len += search_size;
+            s->translations.total += 1;
+            if (tb_page_addr1(tb) != -1) {
+                s->translations.spanning += 1;
+            }
+        }
+    }
+
     /*
      * Insert TB into the corresponding region tree before publishing it
      * through QHT. Otherwise rewinding happened in the TB might fail to
-- 
2.34.1


Re: [PATCH v17 07/16] accel/tcg: Collect TB jit statistics
Posted by Philippe Mathieu-Daudé 2 years, 4 months ago
On 3/10/23 20:30, Richard Henderson wrote:
> Collect items like input and output code size, guest instruction count,
> intermediate ops, spills, etc.
> 
> Signed-off-by: Vanderson M. do Rosario <vandersonmr2@gmail.com>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Signed-off-by: Fei Wu <fei2.wu@intel.com>
> [rth: Consolidated at the end of translation.]
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   accel/tcg/translate-all.c | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>