From: Wei Yang <richard.weiyang@gmail.com>
To: Barry Song <21cnbao@gmail.com>
Cc: Wei Yang <richard.weiyang@gmail.com>,
akpm@linux-foundation.org, david@kernel.org,
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,
lance.yang@linux.dev, linux-mm@kvack.org
Subject: Re: [Patch v2] mm/huge_memory: use end_folio to terminate anonymous folio remapping
Date: Mon, 15 Dec 2025 11:57:30 +0000 [thread overview]
Message-ID: <20251215115730.v462lhxeqrofjtfj@master> (raw)
In-Reply-To: <CAGsJ_4yPnv_G0vciNLabA_kn=0k=RP6kBpuD04btj3HM_zarTA@mail.gmail.com>
On Mon, Dec 15, 2025 at 05:15:17PM +0800, Barry Song wrote:
>On Mon, Dec 15, 2025 at 4:43 PM Wei Yang <richard.weiyang@gmail.com> wrote:
>>
>> On Mon, Dec 15, 2025 at 10:31:15AM +0800, Barry Song wrote:
>> >On Mon, Dec 15, 2025 at 8:49 AM Wei Yang <richard.weiyang@gmail.com> wrote:
>> >>
>> >> After splitting a large folio, it is necessary to remap the resulting
>> >> anonymous folios.
>> >>
>> >> The current implementation determines the end of the remapping process
>> >> by counting the number of pages that have been processed.
>> >>
>> >> Since the final folio in the sequence, end_folio, is already known and
>> >> tracked, this commit refactors the remapping loop to leverage end_folio
>> >> as the termination marker.
>> >>
>> >> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> >> Cc: Zi Yan <ziy@nvidia.com>
>> >>
>> >> ---
>> >> v2: move folio assignment in loop
>> >> ---
>> >> mm/huge_memory.c | 13 ++++---------
>> >> 1 file changed, 4 insertions(+), 9 deletions(-)
>> >>
>> >> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> >> index 40cf59301c21..fe812d9c7807 100644
>> >> --- a/mm/huge_memory.c
>> >> +++ b/mm/huge_memory.c
>> >> @@ -3423,20 +3423,15 @@ bool unmap_huge_pmd_locked(struct vm_area_struct *vma, unsigned long addr,
>> >> return __discard_anon_folio_pmd_locked(vma, addr, pmdp, folio);
>> >> }
>> >>
>> >> -static void remap_page(struct folio *folio, unsigned long nr, int flags)
>> >> +static void remap_page(struct folio *folio, struct folio *end_folio, int flags)
>> >> {
>> >
>> >Do we actually see an improvement in readability or performance?
>> >The existing code feels a bit more readable to me; nr is clearly
>> >the number of pages :-)
>> >
>>
>> Hi, Barry,
>>
>> Thanks for your review.
>>
>> Currently end_folio has been used in __folio_split() and
>> __folio_freeze_and_split_unmapped() as a termination marker. So continue to
>> use end_folio here as a termination marker looks consistent and improves
>> readability to me.
>
>In both cases the variables are temporary, and they look fine within their
>own self-documented contexts.
>
>Now that we’re crossing two functions in the context of remap_page(), this
>doesn’t seem to be the case, though.
>
Thanks for your feedback.
>>
>> But yeah, this is my personal preference. If it is not the case, I am fine to
>> keep as it is now. :-)
>
>I personally find the existing code clearer, but I’m also okay if
>others like your new approach more.
>
Thanks
>Thanks
>Barry
--
Wei Yang
Help you, Help me
next prev parent reply other threads:[~2025-12-15 11:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 0:48 Wei Yang
2025-12-15 2:31 ` Barry Song
2025-12-15 8:43 ` Wei Yang
2025-12-15 9:15 ` Barry Song
2025-12-15 11:57 ` Wei Yang [this message]
2025-12-18 9:58 ` David Hildenbrand (Red Hat)
2025-12-18 15:28 ` Wei Yang
2025-12-19 14:26 ` David Hildenbrand (Red Hat)
2025-12-20 0:33 ` Wei Yang
2025-12-15 3:19 ` wang lian
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=20251215115730.v462lhxeqrofjtfj@master \
--to=richard.weiyang@gmail.com \
--cc=21cnbao@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--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=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