From: "Emilio G. Cota" <cota@braap.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/4] cpus: protect TimerState writes with a spinlock
Date: Fri, 31 Aug 2018 18:07:44 -0400 [thread overview]
Message-ID: <20180831220744.GB18048@flamenco> (raw)
In-Reply-To: <20180820150903.1224-4-pbonzini@redhat.com>
On Mon, Aug 20, 2018 at 17:09:02 +0200, Paolo Bonzini wrote:
> In the next patch, we will need to write cpu_ticks_offset from any
> thread, even outside the BQL. Currently, it is protected by the BQL
> just because cpu_enable_ticks and cpu_disable_ticks happen to hold it,
> but the critical sections are well delimited and it's easy to remove
> the BQL dependency.
>
> Add a spinlock that matches vm_clock_seqlock, and hold it when writing
> to the TimerState. This also lets us fix cpu_update_icount when 64-bit
> atomics are not available.
>
> Fields of TiemrState are reordered to avoid padding.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> cpus.c | 72 ++++++++++++++++++++++++++++++++++++++--------------------
> 1 file changed, 47 insertions(+), 25 deletions(-)
>
> diff --git a/cpus.c b/cpus.c
> index 680706aefa..63ddd4fd21 100644
> --- a/cpus.c
> +++ b/cpus.c
(snip)
> @@ -244,11 +250,15 @@ void cpu_update_icount(CPUState *cpu)
> int64_t executed = cpu_get_icount_executed(cpu);
> cpu->icount_budget -= executed;
>
> -#ifdef CONFIG_ATOMIC64
> +#ifndef CONFIG_ATOMIC64
> + seqlock_write_lock(&timers_state.vm_clock_seqlock,
> + &timers_state.vm_clock_lock);
> +#endif
> atomic_set__nocheck(&timers_state.qemu_icount,
> timers_state.qemu_icount + executed);
> -#else /* FIXME: we need 64bit atomics to do this safely */
> - timers_state.qemu_icount += executed;
> +#ifndef CONFIG_ATOMIC64
> + seqlock_write_unlock(&timers_state.vm_clock_seqlock,
> + &timers_state.vm_clock_lock);
> #endif
I'm puzzled by this hunk. Why are we only adding the seqlock_write
if !CONFIG_ATOMIC64, if we always read .qemu_icount with seqlock_read?
Thanks,
Emilio
next prev parent reply other threads:[~2018-08-31 22:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-20 15:08 [Qemu-devel] [PATCH 0/4] cpus: improve seqlock usage for timers_state, allow cpu_get_ticks out of BQL Paolo Bonzini
2018-08-20 15:09 ` [Qemu-devel] [PATCH 1/4] cpus: protect all icount computation with seqlock Paolo Bonzini
2018-08-31 22:03 ` Emilio G. Cota
2018-08-20 15:09 ` [Qemu-devel] [PATCH 2/4] seqlock: add QemuLockable support Paolo Bonzini
2018-08-20 15:09 ` [Qemu-devel] [PATCH 3/4] cpus: protect TimerState writes with a spinlock Paolo Bonzini
2018-08-28 7:23 ` [Qemu-devel] [3/4] " Pavel Dovgalyuk
2018-09-09 23:39 ` Paolo Bonzini
2018-09-10 5:36 ` Pavel Dovgalyuk
2018-09-10 12:59 ` Paolo Bonzini
2018-09-11 6:00 ` Pavel Dovgalyuk
2018-09-11 9:31 ` Paolo Bonzini
2018-10-08 7:09 ` Pavel Dovgalyuk
2018-10-08 11:24 ` Paolo Bonzini
2018-08-31 22:07 ` Emilio G. Cota [this message]
2018-09-09 23:39 ` [Qemu-devel] [PATCH 3/4] " Paolo Bonzini
2018-08-20 15:09 ` [Qemu-devel] [PATCH 4/4] cpus: allow cpu_get_ticks out of BQL Paolo Bonzini
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=20180831220744.GB18048@flamenco \
--to=cota@braap.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).