From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Liu Ping Fan <pingfank@linux.vnet.ibm.com>,
qemu-devel <qemu-devel@nongnu.org>, kvm <kvm@vger.kernel.org>,
Marcelo Tosatti <mtosatti@redhat.com>
Subject: Re: [PATCH 3/5] memory: Flush coalesced MMIO on mapping and state changes
Date: Mon, 25 Jun 2012 12:15:11 +0200 [thread overview]
Message-ID: <4FE83A2F.8010201@siemens.com> (raw)
In-Reply-To: <4FE827EA.6000603@redhat.com>
On 2012-06-25 10:57, Avi Kivity wrote:
> On 06/25/2012 10:01 AM, Jan Kiszka wrote:
>> Flush pending coalesced MMIO before performing mapping or state changes
>> that could affect the event orderings or route the buffered requests to
>> a wrong region.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> In addition, we also have to
>
> Yes, we do.
>
>>
>> void memory_region_transaction_begin(void)
>> {
>> + qemu_flush_coalesced_mmio_buffer();
>> ++memory_region_transaction_depth;
>> }
>
> Why is this needed?
>
>>
>> @@ -1109,6 +1110,9 @@ void memory_region_sync_dirty_bitmap(MemoryRegion *mr)
>>
>> void memory_region_set_readonly(MemoryRegion *mr, bool readonly)
>> {
>> + if (!QTAILQ_EMPTY(&mr->coalesced)) {
>> + qemu_flush_coalesced_mmio_buffer();
>> + }
>
> The readonly attribute is inherited by subregions and alias targets, so
> this check is insufficient. See render_memory_region(). Need to flush
> unconditionally.
>
>> if (mr->readonly != readonly) {
>> mr->readonly = readonly;
>> memory_region_update_topology(mr);
>> @@ -1117,6 +1121,9 @@ void memory_region_set_readonly(MemoryRegion *mr, bool readonly)
>>
>> void memory_region_rom_device_set_readable(MemoryRegion *mr, bool readable)
>> {
>> + if (!QTAILQ_EMPTY(&mr->coalesced)) {
>> + qemu_flush_coalesced_mmio_buffer();
>> + }
>
> This property is not inherited, but let's flush unconditionally just the
> same, to reduce fragility.
>
>> @@ -1219,6 +1228,9 @@ void memory_region_add_eventfd(MemoryRegion *mr,
>> };
>> unsigned i;
>>
>> + if (!QTAILQ_EMPTY(&mr->coalesced)) {
>> + qemu_flush_coalesced_mmio_buffer();
>> + }
>
> Ditto. It's possible that an eventfd overlays a subregion which has
> coalescing enabled. It's not really defined what happens in this case,
> and such code and its submitter should be perma-nacked, but let's play
> it safe here since there isn't much to be gained by avoiding the flush.
> This code is a very slow path anyway, including and rcu and/or srcu
> synchronization, and a rebuild of the dispatch radix tree (trees when we
> dma-enable this code).
>
>> for (i = 0; i < mr->ioeventfd_nb; ++i) {
>> if (memory_region_ioeventfd_before(mrfd, mr->ioeventfds[i])) {
>> break;
>> @@ -1249,6 +1261,9 @@ void memory_region_del_eventfd(MemoryRegion *mr,
>> };
>> unsigned i;
>>
>> + if (!QTAILQ_EMPTY(&mr->coalesced)) {
>> + qemu_flush_coalesced_mmio_buffer();
>> + }
>
> Same.
OK.
>
> The repetitiveness of this code suggests a different way of doing this:
> make every API call be its own subtransaction and perform the flush in
> memory_region_begin_transaction() (maybe that's the answer to my
> question above).
So you want me to wrap the core of those services in
begin/commit_transaction instead? Just to be sure I got the idea.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2012-06-25 10:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-25 7:00 [PATCH 0/5] kvm: Get coalesced MMIO flushing out of the hot-path Jan Kiszka
2012-06-25 7:00 ` [PATCH 1/5] i82378: Remove bogus MMIO coalescing Jan Kiszka
2012-06-25 7:11 ` Hervé Poussineau
2012-06-25 7:15 ` Andreas Färber
2012-06-25 7:00 ` [PATCH 2/5] memory: Flush coalesced MMIO on selected region access Jan Kiszka
2012-06-25 8:36 ` Avi Kivity
2012-06-25 7:01 ` [PATCH 3/5] memory: Flush coalesced MMIO on mapping and state changes Jan Kiszka
2012-06-25 8:40 ` [Qemu-devel] " Andreas Färber
2012-06-25 8:57 ` Avi Kivity
2012-06-25 10:15 ` Jan Kiszka [this message]
2012-06-25 10:26 ` Jan Kiszka
2012-06-25 11:01 ` Avi Kivity
2012-06-25 11:13 ` Jan Kiszka
2012-06-25 7:01 ` [PATCH 4/5] VGA: Flush coalesced MMIO on related MMIO/PIO accesses Jan Kiszka
2012-06-25 7:01 ` [PATCH 5/5] kvm: Stop flushing coalesced MMIO on vmexit Jan Kiszka
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=4FE83A2F.8010201@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pingfank@linux.vnet.ibm.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).