All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lluís Vilanova" <vilanova@ac.upc.edu>
To: Richard Henderson <rth@twiddle.net>
Cc: Richard Henderson <richard.henderson@linaro.org>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 4/7] tcg: Add support for "inlining" regions of code
Date: Tue, 26 Sep 2017 19:31:25 +0300	[thread overview]
Message-ID: <87poadto9u.fsf@frigg.lan> (raw)
In-Reply-To: <87ingki0je.fsf@frigg.lan> ("Lluís Vilanova"'s message of "Fri, 15 Sep 2017 15:55:33 +0300")

Lluís Vilanova writes:

> Richard Henderson writes:
>> On 09/14/2017 08:20 AM, Lluís Vilanova wrote:
>>> Richard Henderson writes:
>>> 
>>>> On 09/10/2017 09:27 AM, Lluís Vilanova wrote:
>>>>> TCG BBLs and instructions have multiple exit points from where to raise
>>>>> tracing events, but some of the necessary information in the generic
>>>>> disassembly infrastructure is not available until after generating these
>>>>> exit points.
>>>>> 
>>>>> This patch adds support for "inline points" (where the tracing code will
>>>>> be placed), and "inline regions" (which identify the TCG code that must
>>>>> be inlined). The TCG compiler will basically copy each inline region to
>>>>> any inline points that reference it.
>>> 
>>>> I am not keen on this.
>>> 
>>>> Is there a reason you can't just emit the tracing code at the appropriate place
>>>> to begin with?  Perhaps I have to wait to see how this is used...
>>> 
>>> As I tried to briefly explain on next patch, the main problem without inlining
>>> is that we will see guest_tb_after_trans twice on the trace for each TB in
>>> conditional instructions on the guest, since they have two exit points (which we
>>> capture when emitting goto_tb in TCG).

>> Without seeing the code, I suspect this is because you didn't examine the
>> argument to tcg_gen_exit_tb.  You can tell when goto_tb must have been emitted
>> and avoid logging twice.

> The generated tracing code for 'guest_*_after' must be right before the
> "goto_tb" opcode at the end of a TB (AFAIU generated by
> tcg_gen_lookup_and_goto_ptr()), and we have two of those when decoding a guest
> conditional jump.

> If we couple this with the semantics of the trace_*_tcg functions (trace the
> event at translation time, and generate TCG code to trace the event at execution
> time), we get the case I described (we don't want to call trace_tb_after_tcg()
> or trace_insn_after_tcg() twice for the same TB or instruction).

> That is, unless I've missed something.


> The only alternative I can think of is changing tracetool to offer an additional
> API that provides separate functions for translation-time tracing and
> execution-time generation. So from this:

>   static inline void trace_event_tcg(CPUState *cpu, TCGv_env env, ...)
>   {
>       trace_event_trans(cpu, ...);
>       if (trace_event_get_vcpu_state(cpu, EVENT_EXEC)) {
>           gen_helper_trace_event_exec(env, ...);
>       }
>   }

> We can extend it into this:

>   static inline void gen_trace_event_exec(TCGv_env env, ...)
>       if (trace_event_get_vcpu_state(cpu, EVENT_EXEC)) {
>           gen_helper_trace_event_exec(env, ...);
>       }
>   }
>   static inline void trace_event_tcg(CPUState *cpu, TCGv_env env, ...)
>   {
>       trace_event_trans(cpu, ...);
>       gen_trace_event_exec(env, ...);
>   }

Richard, do you prefer to keep the "TCG inline" feature or switch the internal
tracing API to this second approach?


Thanks,
  Lluis

  reply	other threads:[~2017-09-26 16:31 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-10 16:11 [Qemu-devel] [PATCH 0/7] trace: Add guest code events Lluís Vilanova
2017-09-10 16:15 ` [Qemu-devel] [PATCH 1/7] trace: Add event "guest_bbl_before" Lluís Vilanova
2017-09-13 16:59   ` Richard Henderson
2017-09-14 14:21     ` Lluís Vilanova
2017-09-10 16:19 ` [Qemu-devel] [PATCH 2/7] trace: Add event "guest_inst_before" Lluís Vilanova
2017-09-13 17:02   ` Richard Henderson
2017-09-14 14:40     ` Lluís Vilanova
2017-09-10 16:23 ` [Qemu-devel] [PATCH 3/7] trace: Add event "guest_inst_info_before" Lluís Vilanova
2017-09-13 17:07   ` Richard Henderson
2017-09-14 14:59     ` Lluís Vilanova
2017-09-14 16:12       ` Richard Henderson
2017-09-10 16:27 ` [Qemu-devel] [PATCH 4/7] tcg: Add support for "inlining" regions of code Lluís Vilanova
2017-09-13 17:09   ` Richard Henderson
2017-09-14 15:20     ` Lluís Vilanova
2017-09-14 16:15       ` Richard Henderson
2017-09-15 12:55         ` Lluís Vilanova
2017-09-26 16:31           ` Lluís Vilanova [this message]
2017-09-26 16:52             ` Richard Henderson
2017-09-10 16:31 ` [Qemu-devel] [PATCH 5/7] trace: Add event "guest_bbl_after" Lluís Vilanova
2017-09-13 17:34   ` Richard Henderson
2017-09-14 15:20     ` Lluís Vilanova
2017-09-14 16:16       ` Richard Henderson
2017-09-10 16:35 ` [Qemu-devel] [PATCH 6/7] trace: Add event "guest_inst_after" Lluís Vilanova
2017-09-13 18:01   ` Richard Henderson
2017-09-14 16:23     ` Lluís Vilanova
2017-09-10 16:39 ` [Qemu-devel] [PATCH 7/7] trace: Add event "guest_inst_info_after" Lluís Vilanova
2017-09-13 18:03   ` Richard Henderson
2017-09-10 16:45 ` [Qemu-devel] [PATCH 0/7] trace: Add guest code events no-reply
2017-09-13 14:36   ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87poadto9u.fsf@frigg.lan \
    --to=vilanova@ac.upc.edu \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=rth@twiddle.net \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.