public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: David Hildenbrand <david@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	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>, Dev Jain <dev.jain@arm.com>,
	Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
	<Liam.Howlett@oracle.com>
Subject: Re: [PATCH 3/3] mm: huge_memory: use prot_numa_skip() for pmd folio
Date: Tue, 14 Oct 2025 14:10:56 +0800	[thread overview]
Message-ID: <c4feff94-ea84-4610-a836-e1f2ebf800a9@huawei.com> (raw)
In-Reply-To: <c31abe19-f13c-49e7-b305-d899536ce9bb@redhat.com>



On 2025/10/13 23:58, David Hildenbrand wrote:
> On 13.10.25 14:15, Kefeng Wang wrote:
>> The prot_numa_skip() checks should be suitable for pmd folio too,
>> which helps to avoid unnecessary pmd change and folio migration
>> attempts.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>>   mm/huge_memory.c | 21 +++++++--------------
>>   mm/internal.h    |  2 ++
>>   mm/mprotect.c    |  2 +-
>>   3 files changed, 10 insertions(+), 15 deletions(-)
>>
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index 1b81680b4225..feca5a19104a 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -2395,8 +2395,7 @@ int change_huge_pmd(struct mmu_gather *tlb, 
>> struct vm_area_struct *vma,
>>   #endif
>>       if (prot_numa) {
>> -        struct folio *folio;
>> -        bool toptier;
>> +        int target_node = NUMA_NO_NODE;
>>           /*
>>            * Avoid trapping faults against the zero page. The read-only
>>            * data is likely to be read-cached on the local CPU and
>> @@ -2408,19 +2407,13 @@ int change_huge_pmd(struct mmu_gather *tlb, 
>> struct vm_area_struct *vma,
>>           if (pmd_protnone(*pmd))
>>               goto unlock;
>> -        folio = pmd_folio(*pmd);
>> -        toptier = node_is_toptier(folio_nid(folio));
>> -        /*
>> -         * Skip scanning top tier node if normal numa
>> -         * balancing is disabled
>> -         */
>> -        if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_NORMAL) &&
>> -            toptier)
>> -            goto unlock;
>> +        /* Get target node for single threaded private VMAs */
>> +        if (!(vma->vm_flags & VM_SHARED) &&
>> +            atomic_read(&vma->vm_mm->mm_users) == 1)
>> +            target_node = numa_node_id();
> 
> Wondering if we should move that hunk into prot_numa_skip() as well.
> 
> I'd assume numa_node_id() is not particularly expensive?

There is a atomic read, it may be expensive for 512 times atomic read
for change_pte_range().

> 
> While at it, I think we should then rename prot_numa_skip() to
> prot_numa_skip_folio() or better "folio_skip_prot_numa()", making folio 
> the first parameter.
> 

OK, will change it.



  reply	other threads:[~2025-10-14  6:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-13 12:15 [PATCH 0/3] mm: some optimizations for prot numa Kefeng Wang
2025-10-13 12:15 ` [PATCH 1/3] mm: mprotect: always skip dma pinned folio in prot_numa_skip() Kefeng Wang
2025-10-13 15:12   ` Sidhartha Kumar
2025-10-13 15:49   ` David Hildenbrand
2025-10-14  1:42   ` Lance Yang
2025-10-13 12:15 ` [PATCH 2/3] mm: mprotect: avoid unnecessary struct page accessing if pte_protnone() Kefeng Wang
2025-10-13 15:22   ` Sidhartha Kumar
2025-10-13 15:53   ` David Hildenbrand
2025-10-14  6:06     ` Kefeng Wang
2025-10-14  7:16       ` David Hildenbrand
2025-10-14  8:02         ` Kefeng Wang
2025-10-14  8:56           ` David Hildenbrand
2025-10-14  9:19             ` Kefeng Wang
2025-10-13 12:15 ` [PATCH 3/3] mm: huge_memory: use prot_numa_skip() for pmd folio Kefeng Wang
2025-10-13 15:41   ` Sidhartha Kumar
2025-10-13 15:58   ` David Hildenbrand
2025-10-14  6:10     ` Kefeng Wang [this message]
2025-10-14  7:24       ` David Hildenbrand

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=c4feff94-ea84-4610-a836-e1f2ebf800a9@huawei.com \
    --to=wangkefeng.wang@huawei.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=dev.jain@arm.com \
    --cc=lance.yang@linux.dev \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=ryan.roberts@arm.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