linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Barry Song <21cnbao@gmail.com>
Cc: akpm@linux-foundation.org, Liam.Howlett@oracle.com,
	anshuman.khandual@arm.com, david@redhat.com, dev.jain@arm.com,
	jannh@google.com, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, lokeshgidra@google.com, osalvador@suse.de,
	ryan.roberts@arm.com, surenb@google.com, v-songbaohua@oppo.com,
	vbabka@suse.cz, zhengtangquan@oppo.com
Subject: Re: [PATCH v2] mm: madvise: use walk_page_range_vma() instead of walk_page_range()
Date: Mon, 9 Jun 2025 12:12:17 +0100	[thread overview]
Message-ID: <4f1edbf8-eb6a-4081-8b49-c9d1a5f85748@lucifer.local> (raw)
In-Reply-To: <20250609105513.10901-1-21cnbao@gmail.com>

On Mon, Jun 09, 2025 at 10:55:13PM +1200, Barry Song wrote:
> > Yeah dear god I missed this oops!
> >
> > Yeah Barry - could you revert this change for the guard region bits please? So
> > this is intentional as we do not want anything non-mm to have access to
> > install_pte.
>
> All my fault! I wrote a multi-process/thread test to issue lots of madvise
> calls, but it looks like I missed INSTALL_GUARD.
>
> Thanks, Ryan & Lorenzo! Does Andrew prefer to pick up the fix below, or
> would it be better to send a new version? He’s handled fixes like this in
> the past—happy to resend if needed.

I'm totally fine with this thanks!

I can't speak for Andrew of course but he highlighted at LSF/MM his
preference for incremental fixes like this so I would say this is probably
his preference also :)

>
> From: Barry Song <v-songbaohua@oppo.com>
> Date: Mon, 9 Jun 2025 22:42:13 +1200
> Subject: [PATCH] mm: madvise: revert the walk_page_range_vma change for
>  MADV_GUARD_INSTALL
>
> Fix the broken MADV_GUARD_INSTALL reported by Ryan.
>  # guard-regions.c:719:split_merge:Expected madvise(ptr, 10 * page_size,
>  MADV_GUARD_INSTALL) (-1) == 0 (0)
>
> Reported-by: Ryan Roberts <ryan.roberts@arm.com>
> Closes: https://lore.kernel.org/linux-mm/671f8164-a90b-48d7-9446-359eb9493500@arm.com/
> Signed-off-by: Barry Song <v-songbaohua@oppo.com>
> ---
>  mm/madvise.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/madvise.c b/mm/madvise.c
> index 8382614b71d1..381eedde8f6d 100644
> --- a/mm/madvise.c
> +++ b/mm/madvise.c
> @@ -1141,7 +1141,7 @@ static long madvise_guard_install(struct vm_area_struct *vma,
>  		unsigned long nr_pages = 0;
>
>  		/* Returns < 0 on error, == 0 if success, > 0 if zap needed. */
> -		err = walk_page_range_vma(vma, start, end,
> +		err = walk_page_range_mm(vma->vm_mm, start, end,
>  					 &guard_install_walk_ops, &nr_pages);

Actually ack that only the install needs it, we can keep this fix for the
remove, as that doesn't of course use .install_pte().

Also it's kind of neat to only use the internal one in the instance we need
that and the 'public' interface when we don't.

>  		if (err < 0)
>  			return err;
> --
> 2.39.3 (Apple Git-146)
>

I also did actually test this this time :P and can confirm it fixes the issue.


      parent reply	other threads:[~2025-06-09 11:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-05  8:31 Barry Song
2025-06-05  9:14 ` Harry Yoo
2025-06-05  9:20 ` Dev Jain
2025-06-05 14:12 ` Vlastimil Babka
2025-06-05 14:20   ` Lorenzo Stoakes
2025-06-09  9:52 ` Ryan Roberts
2025-06-09 10:22   ` Lorenzo Stoakes
2025-06-09 10:55     ` Barry Song
2025-06-09 11:04       ` Ryan Roberts
2025-06-09 11:12       ` Lorenzo Stoakes [this message]

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=4f1edbf8-eb6a-4081-8b49-c9d1a5f85748@lucifer.local \
    --to=lorenzo.stoakes@oracle.com \
    --cc=21cnbao@gmail.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=david@redhat.com \
    --cc=dev.jain@arm.com \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lokeshgidra@google.com \
    --cc=osalvador@suse.de \
    --cc=ryan.roberts@arm.com \
    --cc=surenb@google.com \
    --cc=v-songbaohua@oppo.com \
    --cc=vbabka@suse.cz \
    --cc=zhengtangquan@oppo.com \
    /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