From: Pedro Falcato <pfalcato@suse.de>
To: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>, Zi Yan <ziy@nvidia.com>,
"Liam R. Howlett" <liam@infradead.org>,
Lorenzo Stoakes <ljs@kernel.org>,
Vlastimil Babka <vbabka@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
linux-mm@kvack.org
Subject: Re: [PATCH v2 2/4] mm: mprotect: use walk_page_range_vma() in mprotect_fixup()
Date: Thu, 18 Jun 2026 12:52:42 +0100 [thread overview]
Message-ID: <ajPbpLBqYc8uTyUJ@pedro-suse> (raw)
In-Reply-To: <20260618092845.3905740-3-wangkefeng.wang@huawei.com>
On Thu, Jun 18, 2026 at 05:28:43PM +0800, Kefeng Wang wrote:
> In mprotect_fixup(), the PROT_NONE PFN permission check uses
> walk_page_range() to walk the page table. Fortunately, the caller
> always passes start/end that falls within a single VMA, the
> do_mprotect_pkey() iterates per-VMA via for_each_vma_range(),
> and setup_arg_pages() passes the whole VMA.
>
> Note, walk_page_test() isn't called in walk_page_range_vma(),
> however, prot_none_test() in prot_none_walk_ops always return 0,
> so it's safe to replace walk_page_range() with walk_page_range_vma()
> to eliminate an unnecessary find_vma() lookup, also remove
> unneeded prot_none_test() too.
Again, I strongly prefer walk_page_range_vma() to be consistent with
walk_page_range() and others. But the change itself (apart from that)
is fairly uncontroversial, LGTM.
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
> Reviewed-by: Zi Yan <ziy@nvidia.com>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> mm/mprotect.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/mm/mprotect.c b/mm/mprotect.c
> index 9cbf932b028c..b1595450e241 100644
> --- a/mm/mprotect.c
> +++ b/mm/mprotect.c
> @@ -708,16 +708,9 @@ static int prot_none_hugetlb_entry(pte_t *pte, unsigned long hmask,
> 0 : -EACCES;
> }
>
> -static int prot_none_test(unsigned long addr, unsigned long next,
> - struct mm_walk *walk)
> -{
> - return 0;
> -}
> -
> static const struct mm_walk_ops prot_none_walk_ops = {
> .pte_entry = prot_none_pte_entry,
> .hugetlb_entry = prot_none_hugetlb_entry,
> - .test_walk = prot_none_test,
> .walk_lock = PGWALK_WRLOCK,
> };
>
> @@ -753,7 +746,7 @@ mprotect_fixup(struct vma_iterator *vmi, struct mmu_gather *tlb,
> !vma_flags_test_any_mask(&new_vma_flags, VMA_ACCESS_FLAGS)) {
> pgprot_t new_pgprot = vm_get_page_prot(newflags);
>
> - error = walk_page_range(current->mm, start, end,
> + error = walk_page_range_vma(vma, start, end,
> &prot_none_walk_ops, &new_pgprot);
> if (error)
> return error;
> --
> 2.27.0
>
>
>
--
Pedro
next prev parent reply other threads:[~2026-06-18 12:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-18 9:28 [PATCH v2 0/4] mm: convert to walk_page_range_vma() to eliminate find_vma() Kefeng Wang
2026-06-18 9:28 ` [PATCH v2 1/4] mm: mincore: use walk_page_range_vma() in do_mincore() Kefeng Wang
2026-06-18 11:34 ` David Hildenbrand (Arm)
2026-06-18 11:49 ` Pedro Falcato
2026-06-18 12:58 ` David Hildenbrand (Arm)
2026-06-18 13:01 ` Kefeng Wang
2026-06-18 15:02 ` Pedro Falcato
2026-06-18 9:28 ` [PATCH v2 2/4] mm: mprotect: use walk_page_range_vma() in mprotect_fixup() Kefeng Wang
2026-06-18 11:52 ` Pedro Falcato [this message]
2026-06-18 9:28 ` [PATCH v2 3/4] mm: mlock: use walk_page_range_vma() in mlock_vma_pages_range() Kefeng Wang
2026-06-18 11:53 ` Pedro Falcato
2026-06-18 9:28 ` [PATCH v2 4/4] mm: migrate_device: use walk_page_range_vma() in migrate_vma_collect() Kefeng Wang
2026-06-18 11:53 ` Pedro Falcato
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=ajPbpLBqYc8uTyUJ@pedro-suse \
--to=pfalcato@suse.de \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=wangkefeng.wang@huawei.com \
--cc=ziy@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.