[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aAHUluy7T32ZlYg7@debian>
Date: Thu, 17 Apr 2025 21:27:02 -0700
From: Fan Ni <nifan.cxl@...il.com>
To: Muchun Song <muchun.song@...ux.dev>
Cc: Fan Ni <nifan.cxl@...il.com>,
Sidhartha Kumar <sidhartha.kumar@...cle.com>, willy@...radead.org,
mcgrof@...nel.org, a.manzanares@...sung.com, dave@...olabs.net,
akpm@...ux-foundation.org, david@...hat.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] mm/hugetlb: Refactor __unmap_hugepage_range() to
take folio instead of page
On Fri, Apr 18, 2025 at 11:03:59AM +0800, Muchun Song wrote:
>
>
> > On Apr 18, 2025, at 00:34, Fan Ni <nifan.cxl@...il.com> wrote:
> >
> > On Thu, Apr 17, 2025 at 12:21:55PM -0400, Sidhartha Kumar wrote:
> >> On 4/17/25 11:43 AM, nifan.cxl@...il.com wrote:
> >>> From: Fan Ni <fan.ni@...sung.com>
> >>>
> >>> The function __unmap_hugepage_range() has two kinds of users:
> >>> 1) unmap_hugepage_range(), which passes in the head page of a folio.
> >>> Since unmap_hugepage_range() already takes folio and there are no other
> >>> uses of the folio struct in the function, it is natural for
> >>> __unmap_hugepage_range() to take folio also.
> >>> 2) All other uses, which pass in NULL pointer.
> >>>
> >>> In both cases, we can pass in folio. Refactor __unmap_hugepage_range() to
> >>> take folio.
> >>>
> >>> Signed-off-by: Fan Ni <fan.ni@...sung.com>
> >>> ---
> >>>
> >>> Question: If the change in the patch makes sense, should we try to convert all
> >>> "page" uses in __unmap_hugepage_range() to folio?
> >>>
> >>
> >> For this to be correct, we have to ensure that the pte in:
> >>
> >> page = pte_page(pte);
> >>
> >> only refers to the pte of a head page. pte comes from:
> >>
> >> pte = huge_ptep_get(mm, address, ptep);
> >>
> >> and in the for loop above:
> >>
> >> for (; address < end; address += sz)
> >>
> >> address is incremented by the huge page size so I think address here only
> >> points to head pages of hugetlb folios and it would make sense to convert
> >> page to folio here.
> >>
> >
> > Thanks Sidhartha for reviewing the series. I have similar understanding and
> > wanted to get confirmation from experts in this area.
>
> I think your understanding is right. BTW, you forgot to update definition of
> __unmap_hugepage_range() under !CONFIG_HUGETLB_PAGE case.
>
Thanks Muchun. You are right, we need to update that.
Hi Andrew,
I see you picked this patch up, should I send a v2 for the series to fix the
issue mentioned above?
The fix is simple as below.
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index d6c503dd2f7d..ebaf95231934 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -452,7 +452,7 @@ static inline long hugetlb_change_protection(
static inline void __unmap_hugepage_range(struct mmu_gather *tlb,
struct vm_area_struct *vma, unsigned long start,
- unsigned long end, struct page *ref_page,
+ unsigned long end, struct folio *ref_folio,
zap_flags_t zap_flags)
{
BUG();
Fan
> >
> > Thanks.
> > Fan
>
Powered by blists - more mailing lists