qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>,
	qemu-devel@nongnu.org, pbonzini@redhat.com, mst@redhat.com
Cc: peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PATCH 1/2] memory: Align and add helper for comparing MemoryRegionSections
Date: Tue, 13 Aug 2019 14:58:53 +0200	[thread overview]
Message-ID: <f87ef58d-a549-54cf-4a3a-8e4712c699e1@redhat.com> (raw)
In-Reply-To: <20190813102936.32195-2-dgilbert@redhat.com>

Hi David,

On 8/13/19 12:29 PM, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> MemoryRegionSection includes an Int128 'size' field;
> on some platforms the compiler causes an alignment of this to
> a 128bit boundary, leaving 8 bytes of dead space.
> This deadspace can be filled with junk.
> 
> Move the size field to the top avoiding unnecsssary alignment

"unnecessary"

This is enough change to be in its own commit.

---

> and provide an 'eq' routine to safely compare MRS's.

This is another change, and should be squashed in the next patch IMO.
Doesn't Clang warn about unused 'static inline' btw?

> 
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
>  include/exec/memory.h | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index 606250172a..ce62e847bd 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -487,15 +487,27 @@ static inline FlatView *address_space_to_flatview(AddressSpace *as)
>   * @nonvolatile: this section is non-volatile
>   */
>  struct MemoryRegionSection {
> +    Int128 size;
>      MemoryRegion *mr;
>      FlatView *fv;
>      hwaddr offset_within_region;
> -    Int128 size;
>      hwaddr offset_within_address_space;
>      bool readonly;
>      bool nonvolatile;
>  };
>  
> +static inline bool MemoryRegionSection_eq(MemoryRegionSection *a,
> +                                          MemoryRegionSection *b)
> +{
> +    return a->mr == b->mr &&
> +           a->fv == b->fv &&
> +           a->offset_within_region == b->offset_within_region &&
> +           a->offset_within_address_space == b->offset_within_address_space &&
> +           int128_eq(a->size, b->size) &&
> +           a->readonly == b->readonly &&
> +           a->nonvolatile == b->nonvolatile;
> +}
> +
>  /**
>   * memory_region_init: Initialize a memory region
>   *
> 


  reply	other threads:[~2019-08-13 13:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-13 10:29 [Qemu-devel] [PATCH 0/2] Fix MemoryRegionSection alignment and comparison Dr. David Alan Gilbert (git)
2019-08-13 10:29 ` [Qemu-devel] [PATCH 1/2] memory: Align and add helper for comparing MemoryRegionSections Dr. David Alan Gilbert (git)
2019-08-13 12:58   ` Philippe Mathieu-Daudé [this message]
2019-08-14 17:25     ` Dr. David Alan Gilbert
2019-08-14 17:35       ` Philippe Mathieu-Daudé
2019-08-14 17:44         ` Dr. David Alan Gilbert
2019-08-13 10:29 ` [Qemu-devel] [PATCH 2/2] vhost: Fix memory region section comparison Dr. David Alan Gilbert (git)
2019-08-13 12:06 ` [Qemu-devel] [PATCH 0/2] Fix MemoryRegionSection alignment and comparison 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=f87ef58d-a549-54cf-4a3a-8e4712c699e1@redhat.com \
    --to=philmd@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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).