ANDROID: mm/memory.c: allow do_swap_page() to allocate from CMA

When __GFP_CMA was introduced in [1] it did not add __GFP_CMA for
swap cache allocations. Originally that was fixed as a separate
patch in [2], however in the later ACK kernels (6.1 and 6.6) this
fix was squashed with new a change introducing hooks in [3].
Combining such changes is wrong, so separating __GFP_CMA changes
into its own patch here.
By adding __GFP_CMA flags for do_swap_page() allocations we allow
swap-in page allocations to use CMA area.

[1] https://android-review.googlesource.com/c/kernel/common/+/3458307
[2] https://android-review.googlesource.com/c/kernel/common/+/2068987
[3] https://android-review.googlesource.com/c/kernel/common/+/3009322

Fixes: 9223cbec5b ("ANDROID: cma: redirect page allocation to CMA")
Bug: 417417101
Change-Id: I5f2249823cf0370c938794ad0f779c293565f2d5
Signed-off-by: ying zuxin <11154159@vivo.com>
This commit is contained in:
ying zuxin
2025-05-21 11:27:01 +08:00
committed by Treehugger Robot
parent 14abb0c187
commit aefca998d5

View File

@@ -4040,8 +4040,8 @@ static struct folio *__alloc_swap_folio(struct vm_fault *vmf)
struct folio *folio;
swp_entry_t entry;
folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma,
vmf->address, false);
folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE | __GFP_CMA,
0, vma, vmf->address, false);
if (!folio)
return NULL;
@@ -4351,7 +4351,8 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
folio->private = NULL;
}
} else {
folio = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE,
folio = swapin_readahead(entry,
GFP_HIGHUSER_MOVABLE | __GFP_CMA,
vmf);
swapcache = folio;
}