qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] memory: update coalesced_range on transaction_commit
Date: Wed, 28 Nov 2018 11:03:53 +0100	[thread overview]
Message-ID: <c6bc70d3-7fdb-5c38-3846-10b36830a446@redhat.com> (raw)
In-Reply-To: <20181128.181700.1038782556965887223.atsushi.nemoto@sord.co.jp>

On 28/11/18 10:17, Atsushi Nemoto wrote:
> The e1000 driver calls memory_region_add_coalescing but
> kvm_coalesce_mmio_region never been called for those regions.
> 
> Update coalesced_range on memory_region_transaction_commit to fix this.
> 
> It seems very old bug since memory region API
> was merged on commit 093bc2cd885e ("Hierarchical memory region API").
> 
> Signed-off-by: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>
> ---
>  memory.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/memory.c b/memory.c
> index d14c6dec1d..f773b0be50 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1021,6 +1021,8 @@ void memory_region_transaction_begin(void)
>      ++memory_region_transaction_depth;
>  }
>  
> +static void memory_region_update_coalesced_range_as(MemoryRegion *mr, AddressSpace *as);
> +
>  void memory_region_transaction_commit(void)
>  {
>      AddressSpace *as;
> @@ -1038,6 +1040,7 @@ void memory_region_transaction_commit(void)
>              QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
>                  address_space_set_flatview(as);
>                  address_space_update_ioeventfds(as);
> +                memory_region_update_coalesced_range_as(NULL, as);
>              }
>              memory_region_update_pending = false;
>              ioeventfd_update_pending = false;
> @@ -2142,7 +2145,7 @@ static void memory_region_update_coalesced_range_as(MemoryRegion *mr, AddressSpa
>  
>      view = address_space_get_flatview(as);
>      FOR_EACH_FLAT_RANGE(fr, view) {
> -        if (fr->mr == mr) {
> +        if (fr->mr == mr || (!mr && !QTAILQ_EMPTY(&fr->mr->coalesced))) {
>              section = (MemoryRegionSection) {
>                  .fv = view,
>                  .offset_within_address_space = int128_get64(fr->addr.start),

I'm worried that coalesced_io_del would be skipped when the region is
deleted.  I think the right place to add the coalesced_io_{add,del}
calls is address_space_update_topology_pass.

Let me test an alternative fix and post it; thanks for the report in the
meanwhile!

Paolo

> @@ -2152,7 +2155,7 @@ static void memory_region_update_coalesced_range_as(MemoryRegion *mr, AddressSpa
>              MEMORY_LISTENER_CALL(as, coalesced_io_del, Reverse, &section,
>                                   int128_get64(fr->addr.start),
>                                   int128_get64(fr->addr.size));
> -            QTAILQ_FOREACH(cmr, &mr->coalesced, link) {
> +            QTAILQ_FOREACH(cmr, &fr->mr->coalesced, link) {
>                  tmp = addrrange_shift(cmr->addr,
>                                        int128_sub(fr->addr.start,
>                                                   int128_make64(fr->offset_in_region)));
> 

  reply	other threads:[~2018-11-28 10:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28  9:17 [Qemu-devel] [PATCH] memory: update coalesced_range on transaction_commit Atsushi Nemoto
2018-11-28 10:03 ` Paolo Bonzini [this message]
2018-11-28 16:30 ` Paolo Bonzini
2018-11-29  4:02   ` Atsushi Nemoto

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=c6bc70d3-7fdb-5c38-3846-10b36830a446@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=atsushi.nemoto@sord.co.jp \
    --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).