From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
Peter Crosthwaite <crosthwaite.peter@gmail.com>,
qemu-devel@nongnu.org, Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v6 3/7] trace: [tcg] Delay changes to dynamic state when translating
Date: Thu, 12 Jan 2017 22:25:00 +0100 [thread overview]
Message-ID: <205320cf-f0c9-536e-8220-7e18ffe08725@redhat.com> (raw)
In-Reply-To: <8760lkt6gf.fsf@ac.upc.edu>
On 12/01/2017 20:37, Lluís Vilanova wrote:
> Stefan Hajnoczi writes:
>
>> On Tue, Jan 10, 2017 at 05:31:37PM +0100, Paolo Bonzini wrote:
>>> On 09/01/2017 18:01, Stefan Hajnoczi wrote:
>>>> Or use a simpler scheme:
>>>>
>>>> struct CPUState {
>>>> ...
>>>> uint32_t dstate_update_count;
>>>> };
>>>>
>>>> In trace_event_set_vcpu_state_dynamic():
>>>>
>>>> if (state) {
>>>> trace_events_enabled_count++;
>>>> set_bit(vcpu_id, vcpu->trace_dstate_delayed);
>>>> atomic_inc(&vcpu->dstate_update_count, 1);
>>>> (*ev->dstate)++;
>>>> } ...
>>>>
>>>> In cpu_exec() and friends:
>>>>
>>>> last_dstate_update_count = atomic_read(&vcpu->dstate_update_count);
>>>>
>>>> tb = tb_find(cpu, last_tb, tb_exit);
>>>> cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc);
>>>>
>>>> /* apply and disable delayed dstate changes */
>>>> if (unlikely(atomic_read(&cpu->dstate_update_count) != last_dstate_update_count)) {
>>>> bitmap_copy(cpu->trace_dstate, cpu->trace_dstate_delayed,
>>>> trace_get_vcpu_event_count());
>>>> }
>>>>
>>>> (You'll need to adjust the details but the update counter approach
>>>> should be workable.)
>>>
>>> Would it work to use async_run_on_cpu?
>
>> I think so.
>
> AFAIU we cannot use async_run_on_cpu(), since we need to reset the local
> variable "last_tb" to avoid chaining TBs with different dstates, and we cannot
> use cpu_loop_exit() inside the callback.
async_run_on_cpu would run as soon as the currently executing TB
finishes, and would leave cpu_exec completely, so there would be no
chaining.
Paolo
> To make it work, we'd need to add some new boolean flag on the vCPU to control
> when to reset "last_tb", and then we're just as good as implementing the async
> work "protocol" manually for this specific case.
>
> What I'll do is fix the race condition by simplifying that code (haven't looked
> at the problem yet).
>
>
> Thanks,
> Lluis
>
next prev parent reply other threads:[~2017-01-12 21:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-28 18:40 [Qemu-devel] [PATCH v6 0/7] trace: [tcg] Optimize per-vCPU tracing states with separate TB caches Lluís Vilanova
2016-12-28 18:41 ` [Qemu-devel] [PATCH v6 1/7] exec: [tcg] Refactor flush of per-CPU virtual TB cache Lluís Vilanova
2017-01-10 20:07 ` Richard Henderson
2016-12-28 18:41 ` [Qemu-devel] [PATCH v6 2/7] trace: Make trace_get_vcpu_event_count() inlinable Lluís Vilanova
2017-01-10 20:08 ` Richard Henderson
2017-01-12 18:14 ` Lluís Vilanova
2016-12-28 18:41 ` [Qemu-devel] [PATCH v6 3/7] trace: [tcg] Delay changes to dynamic state when translating Lluís Vilanova
2017-01-09 17:01 ` Stefan Hajnoczi
2017-01-10 16:31 ` Paolo Bonzini
2017-01-11 16:16 ` Stefan Hajnoczi
2017-01-12 19:37 ` Lluís Vilanova
2017-01-12 21:25 ` Paolo Bonzini [this message]
2017-01-13 20:08 ` Lluís Vilanova
2016-12-28 18:41 ` [Qemu-devel] [PATCH v6 4/7] exec: [tcg] Use different TBs according to the vCPU's dynamic tracing state Lluís Vilanova
2017-01-10 20:10 ` Richard Henderson
2016-12-28 18:41 ` [Qemu-devel] [PATCH v6 5/7] trace: [tcg] Do not generate TCG code to trace dinamically-disabled events Lluís Vilanova
2016-12-28 18:41 ` [Qemu-devel] [PATCH v6 6/7] trace: [tcg, trivial] Re-align generated code Lluís Vilanova
2017-01-12 11:19 ` Michael Tokarev
2017-01-12 18:46 ` Lluís Vilanova
2016-12-28 18:41 ` [Qemu-devel] [PATCH v6 7/7] trace: [trivial] Statically enable all guest events Lluís Vilanova
2017-01-09 17:04 ` [Qemu-devel] [PATCH v6 0/7] trace: [tcg] Optimize per-vCPU tracing states with separate TB caches 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=205320cf-f0c9-536e-8220-7e18ffe08725@redhat.com \
--to=pbonzini@redhat.com \
--cc=crosthwaite.peter@gmail.com \
--cc=ehabkost@redhat.com \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).