From: Wei Yang <richard.weiyang@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Wei Yang <richard.weiyang@gmail.com>,
akpm@linux-foundation.org, david@redhat.com,
lorenzo.stoakes@oracle.com, ziy@nvidia.com,
baolin.wang@linux.alibaba.com, Liam.Howlett@oracle.com,
npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com,
baohua@kernel.org, lance.yang@linux.dev, linux-mm@kvack.org
Subject: Re: [PATCH] mm/khugepaged: use map_anon_folio_pmd() in collapse_huge_page()
Date: Sun, 5 Oct 2025 02:55:43 +0000 [thread overview]
Message-ID: <20251005025543.wumnymjkerg3srxq@master> (raw)
In-Reply-To: <aOHOaYG6gjnfrsmR@casper.infradead.org>
On Sun, Oct 05, 2025 at 02:48:25AM +0100, Matthew Wilcox wrote:
>On Sat, Oct 04, 2025 at 09:25:23AM +0000, Wei Yang wrote:
>> +void map_anon_folio_pmd(struct folio *folio, pmd_t *pmd,
>> + struct vm_area_struct *vma, unsigned long haddr, bool in_pf);
>
>It's generally a bad idea to have a 'bool' flag like this because it's
>not immediately obvious in the callers what 'true' means.
>
>> -static void map_anon_folio_pmd(struct folio *folio, pmd_t *pmd,
>> - struct vm_area_struct *vma, unsigned long haddr)
>> +void map_anon_folio_pmd(struct folio *folio, pmd_t *pmd,
>> + struct vm_area_struct *vma, unsigned long haddr, bool in_pf)
>> {
>> pmd_t entry;
>>
>> @@ -1228,11 +1228,13 @@ static void map_anon_folio_pmd(struct folio *folio, pmd_t *pmd,
>> folio_add_lru_vma(folio, vma);
>> set_pmd_at(vma->vm_mm, haddr, pmd, entry);
>> update_mmu_cache_pmd(vma, haddr, pmd);
>> - add_mm_counter(vma->vm_mm, MM_ANONPAGES, HPAGE_PMD_NR);
>> - count_vm_event(THP_FAULT_ALLOC);
>> - count_mthp_stat(HPAGE_PMD_ORDER, MTHP_STAT_ANON_FAULT_ALLOC);
>> - count_memcg_event_mm(vma->vm_mm, THP_FAULT_ALLOC);
>> deferred_split_folio(folio, false);
>> + if (in_pf) {
>> + add_mm_counter(vma->vm_mm, MM_ANONPAGES, HPAGE_PMD_NR);
>> + count_vm_event(THP_FAULT_ALLOC);
>> + count_mthp_stat(HPAGE_PMD_ORDER, MTHP_STAT_ANON_FAULT_ALLOC);
>> + count_memcg_event_mm(vma->vm_mm, THP_FAULT_ALLOC);
>> + }
>> }
>
>And it's really not necessary here. There's probably better naming
>available, but a good pattern to follow here would be:
>
>void map_anon_folio_pmd_nopf(struct folio *folio, pmd_t *pmd,
> struct vm_area_struct *vma, unsigned long haddr)
>{
>...
>}
>
>static void map_anon_folio_pmd_pf(struct folio *folio, pmd_t *pmd,
> struct vm_area_struct *vma, unsigned long haddr)
>{
> map_anon_folio_pmd_nopf(folio, pmd, vma, haddr);
> add_mm_counter(vma->vm_mm, MM_ANONPAGES, HPAGE_PMD_NR);
> count_vm_event(THP_FAULT_ALLOC);
> count_mthp_stat(HPAGE_PMD_ORDER, MTHP_STAT_ANON_FAULT_ALLOC);
> count_memcg_event_mm(vma->vm_mm, THP_FAULT_ALLOC);
>}
Thanks for the comment.
Will adjust it.
--
Wei Yang
Help you, Help me
prev parent reply other threads:[~2025-10-05 2:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-04 9:25 Wei Yang
2025-10-04 14:26 ` Dev Jain
2025-10-05 0:04 ` Wei Yang
2025-10-05 0:09 ` Wei Yang
2025-10-05 1:48 ` Matthew Wilcox
2025-10-05 2:55 ` Wei Yang [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=20251005025543.wumnymjkerg3srxq@master \
--to=richard.weiyang@gmail.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=npache@redhat.com \
--cc=ryan.roberts@arm.com \
--cc=willy@infradead.org \
--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