[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e61b8931-521f-44b4-a78d-4988ad7c70b5@lucifer.local>
Date: Mon, 9 Jun 2025 11:22:48 +0100
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Ryan Roberts <ryan.roberts@....com>
Cc: Barry Song <21cnbao@...il.com>, linux-mm@...ck.org,
akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
Barry Song <v-songbaohua@...o.com>,
Anshuman Khandual <anshuman.khandual@....com>,
David Hildenbrand <david@...hat.com>,
Oscar Salvador <osalvador@...e.de>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>,
Vlastimil Babka <vbabka@...e.cz>, Jann Horn <jannh@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
Lokesh Gidra <lokeshgidra@...gle.com>, Dev Jain <dev.jain@....com>,
Tangquan Zheng <zhengtangquan@...o.com>
Subject: Re: [PATCH v2] mm: madvise: use walk_page_range_vma() instead of
walk_page_range()
Andrew - could you drop this patch until this is fixed? Whoops!
On Mon, Jun 09, 2025 at 10:52:47AM +0100, Ryan Roberts wrote:
> On 05/06/2025 09:31, Barry Song wrote:
> > From: Barry Song <v-songbaohua@...o.com>
> >
> > We've already found the VMA within madvise_walk_vmas() before calling
> > specific madvise behavior functions like madvise_free_single_vma().
> > So calling walk_page_range() and doing find_vma() again seems
> > unnecessary. It also prevents potential optimizations in those madvise
> > callbacks, particularly the use of dedicated per-VMA locking.
>
> FYI it looks like this patch breaks all the guard-region mm selftests with:
>
> # guard-regions.c:719:split_merge:Expected madvise(ptr, 10 * page_size,
> MADV_GUARD_INSTALL) (-1) == 0 (0)
>
> Am I the only one that runs these things? :)
I normally do :) the one time I don't... :P
>
> [...]
>
> > mm/madvise.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> >
>
> [...]
>
> > @@ -1160,7 +1160,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_mm(vma->vm_mm, start, end,
> > + err = walk_page_range_vma(vma, start, end,
> > &guard_install_walk_ops, &nr_pages);
>
> IIRC walk_page_range_mm() is an internal API that allows the install_pte()
> callback, and the other (public) APIs explicitly disallow it, so presumably
> walk_page_range_vma() is now returning an error due to install_pte != NULL?
>
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.
I'll maybe have a think about this in terms of whether we want to do this a
different way but for now this will fix the issue and get the patch in.
Otherwise patch is ok AFAICT...
With that fixed feel free to propagate tag to a v2.
> Thanks,
> Ryan
>
> > if (err < 0)
> > return err;
> > @@ -1244,7 +1244,7 @@ static long madvise_guard_remove(struct vm_area_struct *vma,
> > if (!is_valid_guard_vma(vma, /* allow_locked = */true))
> > return -EINVAL;
> >
> > - return walk_page_range(vma->vm_mm, start, end,
> > + return walk_page_range_vma(vma, start, end,
> > &guard_remove_walk_ops, NULL);
> > }
> >
>
Powered by blists - more mailing lists