From: Dev Jain <dev.jain@arm.com>
To: Kefeng Wang <wangkefeng.wang@huawei.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
linux-mm@kvack.org
Cc: Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Ryan Roberts <ryan.roberts@arm.com>,
Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
Liam.Howlett@oracle.com,
Sidhartha Kumar <sidhartha.kumar@oracle.com>
Subject: Re: [PATCH v2 2/3] mm: mprotect: avoid unnecessary struct page accessing if pte_protnone()
Date: Wed, 15 Oct 2025 13:02:45 +0530 [thread overview]
Message-ID: <1562a70d-6778-41cb-be30-c83ca7eab373@arm.com> (raw)
In-Reply-To: <20251014113349.2618158-3-wangkefeng.wang@huawei.com>
On 14/10/25 5:03 pm, Kefeng Wang wrote:
> If the pte_protnone() is true, we could avoid unnecessary struct page
> accessing and reduce cache footprint when scanning page tables for prot
> numa, the performance test of pmbench memory accessing benchmark
> should be benifit, see more commit a818f5363a0e ("autonuma: reduce cache
> footprint when scanning page tables").
>
> Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
Thanks.
> mm/mprotect.c | 29 ++++++++++++-----------------
> 1 file changed, 12 insertions(+), 17 deletions(-)
>
> diff --git a/mm/mprotect.c b/mm/mprotect.c
> index bb59a42809b8..7affa88a6de7 100644
> --- a/mm/mprotect.c
> +++ b/mm/mprotect.c
> @@ -118,18 +118,13 @@ static int mprotect_folio_pte_batch(struct folio *folio, pte_t *ptep,
> return folio_pte_batch_flags(folio, NULL, ptep, &pte, max_nr_ptes, flags);
> }
>
> -static bool prot_numa_skip(struct vm_area_struct *vma, unsigned long addr,
> - pte_t oldpte, pte_t *pte, int target_node,
> - struct folio *folio)
> +static bool prot_numa_skip(struct vm_area_struct *vma, int target_node,
> + struct folio *folio)
> {
> bool ret = true;
> bool toptier;
> int nid;
>
> - /* Avoid TLB flush if possible */
> - if (pte_protnone(oldpte))
> - goto skip;
> -
> if (!folio)
> goto skip;
>
> @@ -307,23 +302,23 @@ static long change_pte_range(struct mmu_gather *tlb,
> struct page *page;
> pte_t ptent;
>
> + /* Already in the desired state. */
> + if (prot_numa && pte_protnone(oldpte))
> + continue;
> +
> page = vm_normal_page(vma, addr, oldpte);
> if (page)
> folio = page_folio(page);
> +
Unrelated change but I guess this is needed since we usually leave a line
before starting a comment.
> /*
> * Avoid trapping faults against the zero or KSM
> * pages. See similar comment in change_huge_pmd.
> */
> - if (prot_numa) {
> - int ret = prot_numa_skip(vma, addr, oldpte, pte,
> - target_node, folio);
> - if (ret) {
> -
> - /* determine batch to skip */
> - nr_ptes = mprotect_folio_pte_batch(folio,
> - pte, oldpte, max_nr_ptes, /* flags = */ 0);
> - continue;
> - }
> + if (prot_numa & prot_numa_skip(vma, target_node, folio)) {
Why not "&&" instead of "&"?
> + /* determine batch to skip */
> + nr_ptes = mprotect_folio_pte_batch(folio,
> + pte, oldpte, max_nr_ptes, /* flags = */ 0);
> + continue;
> }
>
> nr_ptes = mprotect_folio_pte_batch(folio, pte, oldpte, max_nr_ptes, flags);
next prev parent reply other threads:[~2025-10-15 7:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 11:33 [PATCH v2 0/3] mm: some optimizations for prot numa Kefeng Wang
2025-10-14 11:33 ` [PATCH v2 1/3] mm: mprotect: always skip dma pinned folio in prot_numa_skip() Kefeng Wang
2025-10-14 22:20 ` Barry Song
2025-10-14 11:33 ` [PATCH v2 2/3] mm: mprotect: avoid unnecessary struct page accessing if pte_protnone() Kefeng Wang
2025-10-14 12:13 ` David Hildenbrand
2025-10-15 7:32 ` Dev Jain [this message]
2025-10-15 8:50 ` Kefeng Wang
2025-10-14 11:33 ` [PATCH v2 3/3] mm: huge_memory: use folio_skip_prot_numa() for pmd folio Kefeng Wang
2025-10-15 7:30 ` Dev Jain
2025-10-15 9:21 ` Kefeng Wang
2025-10-15 9:54 ` David Hildenbrand
2025-10-15 11:04 ` Kefeng Wang
2025-10-15 11:30 ` David Hildenbrand
2025-10-15 12:37 ` Kefeng Wang
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=1562a70d-6778-41cb-be30-c83ca7eab373@arm.com \
--to=dev.jain@arm.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=lance.yang@linux.dev \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=ryan.roberts@arm.com \
--cc=sidhartha.kumar@oracle.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox