From: Paolo Bonzini <pbonzini@redhat.com>
To: Richard Henderson <rth@twiddle.net>,
"Emilio G. Cota" <cota@braap.org>,
qemu-devel@nongnu.org
Cc: "Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Murilo Opsfelder Araujo" <muriloo@linux.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v2 08/12] cpus: always call seqlock_write in cpu_update_icount
Date: Tue, 11 Sep 2018 14:55:58 +0200 [thread overview]
Message-ID: <23bf97d3-d2af-24ea-17e2-9186453dc4de@redhat.com> (raw)
In-Reply-To: <9ef6906f-7fbc-1b41-b5f3-3fd5c9a87e5b@twiddle.net>
On 11/09/2018 14:53, Richard Henderson wrote:
>>
>> -#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);
>> -#ifndef CONFIG_ATOMIC64
>> seqlock_write_unlock(&timers_state.vm_clock_seqlock,
>> &timers_state.vm_clock_lock);
>> -#endif
> I don't understand this. Surely you either want atomic64_set,
> or an actual atomic64_add, but no extra lock when CONFIG_ATOMIC64.
Even though writes of qemu_icount can safely race with reads in
qemu_icount_raw, qemu_icount is also read by icount_adjust, which runs
in the I/O thread. Therefore, writes do need protection of the
vm_clock_lock; for simplicity Emilio's patch protects it with both
seqlock+spinlock, which we already do for hosts that lack 64-bit atomics.
The bug actually predated the introduction of vm_clock_lock;
cpu_update_icount would have needed the BQL before the spinlock was
introduced.
The above could have been a commit message, by the way. :)
Paolo
next prev parent reply other threads:[~2018-09-11 13:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-10 23:27 [Qemu-devel] [PATCH v2 00/12] i386 + x86_64 mttcg Emilio G. Cota
2018-09-10 23:27 ` [Qemu-devel] [PATCH v2 01/12] cacheinfo: add i/d cache_linesize_log Emilio G. Cota
2018-09-11 12:16 ` Richard Henderson
2018-09-11 12:57 ` Paolo Bonzini
2018-09-10 23:27 ` [Qemu-devel] [PATCH v2 02/12] util: add atomic64 Emilio G. Cota
2018-09-11 12:43 ` Richard Henderson
2018-09-11 20:43 ` Emilio G. Cota
2018-09-10 23:27 ` [Qemu-devel] [PATCH v2 03/12] tests: add atomic64-bench Emilio G. Cota
2018-09-10 23:27 ` [Qemu-devel] [PATCH v2 04/12] qsp: use atomic64 accessors Emilio G. Cota
2018-09-10 23:27 ` [Qemu-devel] [PATCH v2 05/12] test-rcu-list: access n_reclaims and n_nodes_removed with atomic64 Emilio G. Cota
2018-09-10 23:27 ` [Qemu-devel] [PATCH v2 06/12] atomic: fix comment s/x64_64/x86_64/ Emilio G. Cota
2018-09-11 12:50 ` Richard Henderson
2018-09-10 23:27 ` [Qemu-devel] [PATCH v2 07/12] cpus: initialize timers_state.vm_clock_lock Emilio G. Cota
2018-09-11 12:50 ` Richard Henderson
2018-09-10 23:27 ` [Qemu-devel] [PATCH v2 08/12] cpus: always call seqlock_write in cpu_update_icount Emilio G. Cota
2018-09-11 12:53 ` Richard Henderson
2018-09-11 12:55 ` Paolo Bonzini [this message]
2018-09-10 23:27 ` [Qemu-devel] [PATCH v2 09/12] cpus: access .qemu_icount with atomic64 Emilio G. Cota
2018-09-10 23:27 ` [Qemu-devel] [PATCH v2 10/12] cpus: access .qemu_icount_bias " Emilio G. Cota
2018-09-10 23:27 ` [Qemu-devel] [PATCH v2 11/12] target/i386/translate: use thread-local storage in !user-mode Emilio G. Cota
2018-09-11 12:57 ` Richard Henderson
2018-09-10 23:27 ` [Qemu-devel] [PATCH v2 12/12] configure: enable mttcg for i386 and x86_64 Emilio G. Cota
2018-09-11 12:58 ` Richard Henderson
2018-09-11 13:00 ` [Qemu-devel] [PATCH v2 00/12] i386 + x86_64 mttcg 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=23bf97d3-d2af-24ea-17e2-9186453dc4de@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=muriloo@linux.ibm.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.