Re: [PATCH v2 2/4] mm: gup: allow long-term pins of CMA-allocated HugeTLB folios

From: Michal Hocko

Date: Tue Dec 01 2026 - 15:54:31 EST


On Tue 01-12-26 12:28:31, Andrew Morton wrote:
> On Tue, 1 Dec 2026 11:50:01 +0100 "David Hildenbrand (Arm)" <david@xxxxxxxxxx> wrote:
>
> > On 12/1/26 11:38, Michal Hocko wrote:
> > > On Tue 01-12-26 10:26:03, David Hildenbrand wrote:
> > >> On 12/1/26 10:12, Michal Hocko wrote:
> > >>>
> > >>> Sorry to chime in this late but I just learned about this change
> > >>> recently. I have to say I am quite surprised that long term pins
> > >>> failed on their own cmas. Is there any actual usecase to require those
> > >>> to work out there?
> > >>>
> > >>> I have no objections to the patch but I want to learn about why nobody
> > >>> cared until just now.
> > >>
> > >> I previously had reports from people using hugetlb_cma for backing VMs and just
> > >> wanting to use vfio for device-passthrough.
> > >
> > > OK, so there is an explicit request behind that. So probably good to
> > > have that mentioned in the changelog so that we have that for future
> > > reference.
> >
> > I remember a discussion at LPC about that, where people also raised the demand
> > for PMD allocations from hugetlb areas [2], which apparently in combination
> > makes that easier to hit for some workloads.
> >
> > Yes, we should highlight that in the commit message.
>
> I did this to the changelog:
>
> --- a/txt/mm-gup-allow-long-term-pins-of-cma-allocated-hugetlb-folios.txt
> +++ b/txt/mm-gup-allow-long-term-pins-of-cma-allocated-hugetlb-folios.txt
> @@ -12,6 +12,10 @@ through HPG_cma. Allow them to be pinned even in ZONE_MOVABLE, since
> memory blocks overlapping boot-time CMA areas cannot be offlined.
> Ordinary movable allocations that borrow CMA memory remain unpinnable.
>
> +One use case is VMs backed by hugetlb_cma whose users want VFIO device
> +passthrough. VFIO needs long-term pins of guest memory; currently those
> +pins can fail or unnecessarily migrate the HugeTLB folios out of CMA.
> +

Thanks Andrew!

> Link: https://patch.msgid.link/295af6601ce79f2c2b3dc4352a3279f0e6ac513e.1794907279.git.zhengqi.arch@xxxxxxxxxxxxx
> Fixes: cf11e85fc08c ("mm: hugetlb: optionally allocate gigantic hugepages using cma")
> Signed-off-by: Qi Zheng <zhengqi.arch@xxxxxxxxxxxxx>
>
>
> > [2] https://lkml.kernel.org/r/cover.1792651104.git.zhengqi.arch@xxxxxxxxxxxxx

--
Michal Hocko
SUSE Labs