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

From: David Hildenbrand (Arm)

Date: Thu Nov 26 2026 - 08:07:27 EST


On 11/25/26 22:49, Usama Arif wrote:
>
>
> On 25/11/2026 07: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[].
>>
>
> Is spending the workload to protect the dump the right way round for this
> option? kdump.rst describes it as
>
> This reservation method is intended for systems that can't afford to
> sacrifice enough memory for standard crashkernel reservation and where
> less reliable and possibly incomplete kdump is preferable to no kdump at
> all.
>
> so the dump is the part the admin has already agreed to give up.

We have in there:

"This option increases the risk of a kdump failure: DMA transfers configured by
the first kernel may end up corrupting the second kernel's memory."

... but I recall some discussions about short-term vs. long-term vs. cma
discussions.

Ah: https://lore.kernel.org/all/ZWJllXCN0SDIELrX@xxxxxxxxxxxxx/

"User pages for RDMA, should be pinned with FOLL_LONGTERM and that
would migrate them away from the CMA area.

But you're right that DMA to user pages pinned without
FOLL_LONGTERM would still be possible. Would this be a problem in
practice? Do you see any way around it?
"

And later (me):

https://lore.kernel.org/all/04904e86-5b5f-4aa1-a120-428dac119189@xxxxxxxxxx/

"What does "short" mean? At least in theory, long-term pinning is
forbidden for MIGRATE_CMA, so we should not have such pages mapped into
an iommu where DMA can happily keep going on for quite a while.

But that assumes that our old kernel is not buggy, and doesn't end up
mapping these pages into an IOMMU where DMA will just continue. I recall
that DRM might currently be a problem, described here [1]."


And in the end, we settled for the 10s wait, crossing our fingers that it will
be alright :)

--
Cheers,

David