[PATCH] accel/tcg: Add CPU_LOG_EXEC tracing for cpu_io_recompile()

Peter Maydell posted 1 patch 3 years, 6 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20201013122658.4620-1-peter.maydell@linaro.org
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <rth@twiddle.net>
accel/tcg/translate-all.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] accel/tcg: Add CPU_LOG_EXEC tracing for cpu_io_recompile()
Posted by Peter Maydell 3 years, 6 months ago
When using -icount, it's useful for the CPU_LOG_EXEC logging
to include information about when cpu_io_recompile() was
called, because it alerts the reader of the log that the
tracing of a previous TB execution may not actually
correspond to an actually executed instruction. For instance
if you're using -icount and also -singlestep then a guest
instruction that makes an IO access appears in two
"Trace" lines, once in a TB that triggers the cpu_io_recompile()
and then again in the TB that actually executes.

(This is a similar reason to why the "Stopped execution of
TB chain before..." logging in cpu_tb_exec() is helpful
when trying to track execution flow in the logs.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 accel/tcg/translate-all.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index d76097296df..4572b4901fb 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -2267,6 +2267,10 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
         tb_destroy(tb);
     }
 
+    qemu_log_mask_and_addr(CPU_LOG_EXEC, tb->pc,
+                           "cpu_io_recompile: rewound execution of TB to "
+                           TARGET_FMT_lx "\n", tb->pc);
+
     /* TODO: If env->pc != tb->pc (i.e. the faulting instruction was not
      * the first in the TB) then we end up generating a whole new TB and
      *  repeating the fault, which is horribly inefficient.
-- 
2.20.1


Re: [PATCH] accel/tcg: Add CPU_LOG_EXEC tracing for cpu_io_recompile()
Posted by Richard Henderson 3 years, 6 months ago
On 10/13/20 5:26 AM, Peter Maydell wrote:
> When using -icount, it's useful for the CPU_LOG_EXEC logging
> to include information about when cpu_io_recompile() was
> called, because it alerts the reader of the log that the
> tracing of a previous TB execution may not actually
> correspond to an actually executed instruction. For instance
> if you're using -icount and also -singlestep then a guest
> instruction that makes an IO access appears in two
> "Trace" lines, once in a TB that triggers the cpu_io_recompile()
> and then again in the TB that actually executes.
> 
> (This is a similar reason to why the "Stopped execution of
> TB chain before..." logging in cpu_tb_exec() is helpful
> when trying to track execution flow in the logs.)
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Thanks, queued to tcg-next.


r~

> ---
>  accel/tcg/translate-all.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
> index d76097296df..4572b4901fb 100644
> --- a/accel/tcg/translate-all.c
> +++ b/accel/tcg/translate-all.c
> @@ -2267,6 +2267,10 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
>          tb_destroy(tb);
>      }
>  
> +    qemu_log_mask_and_addr(CPU_LOG_EXEC, tb->pc,
> +                           "cpu_io_recompile: rewound execution of TB to "
> +                           TARGET_FMT_lx "\n", tb->pc);
> +
>      /* TODO: If env->pc != tb->pc (i.e. the faulting instruction was not
>       * the first in the TB) then we end up generating a whole new TB and
>       *  repeating the fault, which is horribly inefficient.
>