Re: [PATCH] mm/cma: reject long-term pins of HugeTLB folios overlapping crashkernel CMA

From: Jiri Bohac

Date: Fri Nov 27 2026 - 12:43:48 EST


On Wed, Nov 25, 2026 at 11:43:40PM +0100, David Hildenbrand (Arm) wrote:
> On 11/25/26 16:51, Sang-Heon Jeon wrote:
> > crashkernel=size,cma uses existing hugetlb_cma memory, so
> > crashk_cma_ranges[] may contain HugeTLB folios. HugeTLB folios allocated
> > from hugetlb_cma can be long-term pinned without being migrated.
> >
> > After a crash, the crash kernel uses the memory in crashk_cma_ranges[],
> > but a device can still write to a long-term pinned folio.
> >
> > So reject long-term pins of HugeTLB folios overlapping
> > crashk_cma_ranges[].
> >
> > Signed-off-by: Sang-Heon Jeon <ekffu200098@xxxxxxxxx>
> > ---
> > The above scenario is only possible with the two patches below applied.
> > Currently only linux-next, which is targeting v7.5, has both of them.
> >
> > "mm/hugetlb: allow crashkernel to reuse hugetlb CMA memory" (kexec-next)
>
> I think that's a real problem with this thing.
>
> The solution is not to disallow long-term pinning. :/

This patch does not disallow or break the long-term pinning. It just makes
sure the pages are migrated away from the CMA before get_user_pages pins them.

As has always been the case prior to
"mm: gup: allow long-term pins of CMA-allocated HugeTLB folios"
(in mm-unstable), which introduces an exception for hugetlb CMA
and allows the pinning without migration.

And this exception breaks the assumption that CMA does not
contain long-term pinned pages. The short delay prior to kexec
when CMA is used for crashkernel is there to wait for pending DMA
into short-term pinned pages, not long-term pinned ones.

Including
"mm: gup: allow long-term pins of CMA-allocated HugeTLB folios"
without this followup breaks this assumption, which we discussed
during the merge of the crashkernel CMA patchset.


--
Jiri Bohac <jbohac@xxxxxxx>
SUSE Labs, Prague, Czechia