From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: "Lorenzo Stoakes (Oracle)" <ljs@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@kernel.org>, Zi Yan <ziy@nvidia.com>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Nico Pache <npache@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Kiryl Shutsemau <kas@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 10/13] mm/huge_memory: separate out the folio part of zap_huge_pmd()
Date: Sat, 21 Mar 2026 13:59:34 +0800 [thread overview]
Message-ID: <ce065f40-38a6-4601-845a-78021af80f04@linux.alibaba.com> (raw)
In-Reply-To: <6c4db67952f5529da4db102a6149b9050b5dda4e.1774029655.git.ljs@kernel.org>
On 3/21/26 2:07 AM, Lorenzo Stoakes (Oracle) wrote:
> Place the part of the logic that manipulates counters and possibly updates
> the accessed bit of the folio into its own function to make zap_huge_pmd()
> more readable.
>
> Also rename flush_needed to is_present as we only require a flush for
> present entries.
>
> Additionally add comments as to why we're doing what we're doing with
> respect to softleaf entries.
>
> This also lays the ground for further refactoring.
>
> Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
> ---
> mm/huge_memory.c | 61 +++++++++++++++++++++++++++---------------------
> 1 file changed, 35 insertions(+), 26 deletions(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 673d0c4734ad..9ddf38d68406 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -2325,6 +2325,37 @@ static inline void zap_deposited_table(struct mm_struct *mm, pmd_t *pmd)
> mm_dec_nr_ptes(mm);
> }
>
> +static void zap_huge_pmd_folio(struct mm_struct *mm, struct vm_area_struct *vma,
> + pmd_t pmdval, struct folio *folio, bool is_present,
> + bool *has_deposit)
> +{
> + const bool is_device_private = folio_is_device_private(folio);
> +
> + /* Present and device private folios are rmappable. */
> + if (is_present || is_device_private)
> + folio_remove_rmap_pmd(folio, &folio->page, vma);
> +
> + if (folio_test_anon(folio)) {
> + *has_deposit = true;
> + add_mm_counter(mm, MM_ANONPAGES, -HPAGE_PMD_NR);
> + } else {
> + add_mm_counter(mm, mm_counter_file(folio),
> + -HPAGE_PMD_NR);
> +
> + /*
> + * Use flush_needed to indicate whether the PMD entry
> + * is present, instead of checking pmd_present() again.
> + */
> + if (is_present && pmd_young(pmdval) &&
> + likely(vma_has_recency(vma)))
> + folio_mark_accessed(folio);
Nit: these comments were added by me to explain why 'flush_needed' was
used:). Since it has been renamed to the more readable 'is_present',
these comments are now redundant and can be removed.
With that,
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
next prev parent reply other threads:[~2026-03-21 5:59 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 18:14 [PATCH v3 00/13] mm/huge_memory: refactor zap_huge_pmd() Lorenzo Stoakes (Oracle)
2026-03-20 18:07 ` [PATCH v3 01/13] mm/huge_memory: simplify vma_is_specal_huge() Lorenzo Stoakes (Oracle)
2026-03-20 18:07 ` [PATCH v3 02/13] mm/huge: avoid big else branch in zap_huge_pmd() Lorenzo Stoakes (Oracle)
2026-03-20 18:07 ` [PATCH v3 03/13] mm/huge_memory: have zap_huge_pmd return a boolean, add kdoc Lorenzo Stoakes (Oracle)
2026-03-20 18:07 ` [PATCH v3 04/13] mm/huge_memory: handle buggy PMD entry in zap_huge_pmd() Lorenzo Stoakes (Oracle)
2026-03-20 18:07 ` [PATCH v3 05/13] mm/huge_memory: add a common exit path to zap_huge_pmd() Lorenzo Stoakes (Oracle)
2026-03-20 18:07 ` [PATCH v3 06/13] mm/huge_memory: remove unnecessary VM_BUG_ON_PAGE() Lorenzo Stoakes (Oracle)
2026-03-20 18:07 ` [PATCH v3 07/13] mm/huge_memory: deduplicate zap deposited table call Lorenzo Stoakes (Oracle)
2026-03-21 5:39 ` Baolin Wang
2026-03-20 18:07 ` [PATCH v3 08/13] mm/huge_memory: remove unnecessary sanity checks Lorenzo Stoakes (Oracle)
2026-03-20 18:07 ` [PATCH v3 09/13] mm/huge_memory: use mm instead of tlb->mm Lorenzo Stoakes (Oracle)
2026-03-21 5:42 ` Baolin Wang
2026-03-20 18:07 ` [PATCH v3 10/13] mm/huge_memory: separate out the folio part of zap_huge_pmd() Lorenzo Stoakes (Oracle)
2026-03-21 5:59 ` Baolin Wang [this message]
2026-03-23 10:42 ` Lorenzo Stoakes (Oracle)
2026-03-24 12:42 ` Baolin Wang
2026-03-20 18:07 ` [PATCH v3 11/13] mm: add softleaf_is_valid_pmd_entry(), pmd_to_softleaf_folio() Lorenzo Stoakes (Oracle)
2026-03-20 18:07 ` [PATCH v3 12/13] mm/huge_memory: add and use normal_or_softleaf_folio_pmd() Lorenzo Stoakes (Oracle)
2026-03-23 11:24 ` Lorenzo Stoakes (Oracle)
2026-03-20 18:07 ` [PATCH v3 13/13] mm/huge_memory: add and use has_deposited_pgtable() Lorenzo Stoakes (Oracle)
2026-03-23 11:45 ` Lorenzo Stoakes (Oracle)
2026-03-23 12:25 ` Lorenzo Stoakes (Oracle)
2026-03-20 18:42 ` [PATCH v3 00/13] mm/huge_memory: refactor zap_huge_pmd() Andrew Morton
2026-03-23 12:08 ` Lorenzo Stoakes (Oracle)
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=ce065f40-38a6-4601-845a-78021af80f04@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=kas@kernel.org \
--cc=lance.yang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=npache@redhat.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.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