All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Emilio G. Cota" <cota@braap.org>, qemu-devel@nongnu.org
Cc: "Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
	"Richard Henderson" <rth@twiddle.net>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [Qemu-devel] [PATCH 1/4] hw/i386/pc: hold the BQL when calling cpu_get_ticks
Date: Tue, 14 Aug 2018 08:37:49 +0200	[thread overview]
Message-ID: <54ac7b1f-7430-453f-cbba-b7fef74d3187@redhat.com> (raw)
In-Reply-To: <20180814013801.26036-2-cota@braap.org>

On 14/08/2018 03:37, Emilio G. Cota wrote:
> Signed-off-by: Emilio G. Cota <cota@braap.org>
> ---
>  hw/i386/pc.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 83a444472b..7371cd9960 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -158,7 +158,18 @@ static uint64_t ioportF0_read(void *opaque, hwaddr addr, unsigned size)
>  /* TSC handling */
>  uint64_t cpu_get_tsc(CPUX86State *env)
>  {
> -    return cpu_get_ticks();
> +    uint64_t ret;
> +    bool locked;
> +
> +    locked = qemu_mutex_iothread_locked();
> +    if (!locked) {
> +        qemu_mutex_lock_iothread();
> +    }
> +    ret = cpu_get_ticks();
> +    if (!locked) {
> +        qemu_mutex_unlock_iothread();
> +    }
> +    return ret;
>  }
>  
>  /* IRQ handling */
> 

We could use a spinlock for the rare case of timers_state.cpu_ticks_prev
> ticks (or even, on 64-bit, a seqlock+spinlock).  I'll give it a shot.

Paolo

  reply	other threads:[~2018-08-14  6:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-14  1:37 [Qemu-devel] [PATCH 0/4] x86_64 mttcg Emilio G. Cota
2018-08-14  1:37 ` [Qemu-devel] [PATCH 1/4] hw/i386/pc: hold the BQL when calling cpu_get_ticks Emilio G. Cota
2018-08-14  6:37   ` Paolo Bonzini [this message]
2018-08-14  1:37 ` [Qemu-devel] [PATCH 2/4] cpus: assert that the BQL is held in cpu_get_ticks Emilio G. Cota
2018-08-14  1:38 ` [Qemu-devel] [PATCH 3/4] target/i386/translate: use thread-local storage in !user-mode Emilio G. Cota
2018-08-14  6:31   ` Paolo Bonzini
2018-08-14  7:34     ` Emilio G. Cota
2018-08-14  1:38 ` [Qemu-devel] [PATCH 4/4] configure: enable mttcg for x86_64 Emilio G. Cota

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=54ac7b1f-7430-453f-cbba-b7fef74d3187@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=cota@braap.org \
    --cc=crosthwaite.peter@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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.