qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: Re: [PATCH v3 1/3] bsd-user: Always use mmap_find_vma_aligned() in target_mmap()
Date: Fri, 7 Mar 2025 08:03:51 -0800	[thread overview]
Message-ID: <ebe5736b-7903-4763-8c4f-48a697b27df2@linaro.org> (raw)
In-Reply-To: <20250307130951.4816-2-philmd@linaro.org>

On 3/7/25 05:09, Philippe Mathieu-Daudé wrote:
> Massage target_mmap(): calculate alignment once, then
> unconditionally call mmap_find_vma_aligned().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   bsd-user/mmap.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c
> index 346f2cefd32..28d7e387a20 100644
> --- a/bsd-user/mmap.c
> +++ b/bsd-user/mmap.c
> @@ -489,13 +489,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
>        * before we truncate the length for mapping files below.
>        */
>       if (!(flags & MAP_FIXED)) {
> +        abi_ulong alignment = 0;
> +
>           host_len = len + offset - host_offset;
>           host_len = HOST_PAGE_ALIGN(host_len);
> -        if ((flags & MAP_ALIGNMENT_MASK) != 0)
> -            start = mmap_find_vma_aligned(real_start, host_len,
> -                (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT);
> -        else
> -            start = mmap_find_vma(real_start, host_len);
> +        if ((flags & MAP_ALIGNMENT_MASK) != 0) {
> +            alignment = (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT;
> +        }

No need for the if -- (0 & mask) >> shift == 0.

Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


  reply	other threads:[~2025-03-07 16:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-07 13:09 [PATCH v3 0/3] user: Extract common MMAP API to 'user/mmap.h' Philippe Mathieu-Daudé
2025-03-07 13:09 ` [PATCH v3 1/3] bsd-user: Always use mmap_find_vma_aligned() in target_mmap() Philippe Mathieu-Daudé
2025-03-07 16:03   ` Richard Henderson [this message]
2025-03-09 23:21   ` Warner Losh
2025-03-07 13:09 ` [PATCH v3 2/3] bsd-user: Propagate alignment argument to mmap_find_vma() Philippe Mathieu-Daudé
2025-03-07 16:08   ` Richard Henderson
2025-03-07 16:17     ` Philippe Mathieu-Daudé
2025-03-09 23:20   ` Warner Losh
2025-03-07 13:09 ` [PATCH v3 3/3] user: Extract common MMAP API to 'user/mmap.h' Philippe Mathieu-Daudé

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=ebe5736b-7903-4763-8c4f-48a697b27df2@linaro.org \
    --to=richard.henderson@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).