qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Warner Losh <imp@bsdimp.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, Riku Voipio <riku.voipio@iki.fi>,
	 Laurent Vivier <laurent@vivier.eu>,
	Kyle Evans <kevans@freebsd.org>,
	 Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH v4 1/3] bsd-user: Always use mmap_find_vma_aligned() in target_mmap()
Date: Sat, 8 Mar 2025 10:33:02 -0700	[thread overview]
Message-ID: <CANCZdfoe6ezPCb07mRyyEsv0GO1MJFDDaR4rGRW+cEJVmROcCA@mail.gmail.com> (raw)
In-Reply-To: <20250308122842.76377-2-philmd@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]

On Sat, Mar 8, 2025 at 5:28 AM Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:

> Massage target_mmap(): calculate alignment once, then
> unconditionally call mmap_find_vma_aligned().
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  bsd-user/mmap.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>

Reviewed-by: Warner Losh <imp@bsdimp.com>

Here I get why you have a new variable since it's a  little easier to read.

Warner


> diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c
> index 346f2cefd32..dfa6e728ab5 100644
> --- a/bsd-user/mmap.c
> +++ b/bsd-user/mmap.c
> @@ -489,13 +489,12 @@ 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;
> +
>          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);
> +        alignment = (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT;
> +        start = mmap_find_vma_aligned(real_start, host_len, alignment);
>          if (start == (abi_ulong)-1) {
>              errno = ENOMEM;
>              goto fail;
> --
> 2.47.1
>
>

[-- Attachment #2: Type: text/html, Size: 2470 bytes --]

  reply	other threads:[~2025-03-08 17:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-08 12:28 [PATCH v4 0/3] user: Extract common MMAP API to 'user/mmap.h' Philippe Mathieu-Daudé
2025-03-08 12:28 ` [PATCH v4 1/3] bsd-user: Always use mmap_find_vma_aligned() in target_mmap() Philippe Mathieu-Daudé
2025-03-08 17:33   ` Warner Losh [this message]
2025-03-08 12:28 ` [PATCH v4 2/3] bsd-user: Propagate alignment argument to mmap_find_vma() Philippe Mathieu-Daudé
2025-03-08 17:31   ` Warner Losh
2025-03-08 12:28 ` [PATCH v4 3/3] user: Extract common MMAP API to 'user/mmap.h' Philippe Mathieu-Daudé
2025-03-09 12:10 ` [PATCH v4 0/3] " 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=CANCZdfoe6ezPCb07mRyyEsv0GO1MJFDDaR4rGRW+cEJVmROcCA@mail.gmail.com \
    --to=imp@bsdimp.com \
    --cc=kevans@freebsd.org \
    --cc=laurent@vivier.eu \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=riku.voipio@iki.fi \
    /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).