ANDROID: mm: Set __GFP_CMA in do_swap_page() for folio allocations

In the do_swap_page() path, the memory allocations were failing
even if there were free CMA pages. The allocations were not fallbacking
to CMA bucket.

This was due the requested folios were not marked as __GFP_CMA and as
a consequence, the ALLOC_CMA was not set.

```
static inline unsigned int gfp_to_alloc_flags_cma(gfp_t gfp_mask,
						  unsigned int alloc_flags)
{
	/*
	 * If cma_redirect_restricted is true, set ALLOC_CMA only for
	 * movable allocations that have __GFP_CMA.
	 */
	if ((!cma_redirect_restricted() || gfp_mask & __GFP_CMA) &&
	    gfp_migratetype(gfp_mask) == MIGRATE_MOVABLE)
		alloc_flags |= ALLOC_CMA;
	trace_android_vh_alloc_flags_cma_adjust(gfp_mask, &alloc_flags);
	return alloc_flags;
}
```

This was introduced in the change I9d16a9cae1c6c0f6cdb03183038fab095843001e
("BACKPORT: mm: support large folios swap-in for sync io devices")

Bug: 427802573
Bug: 425779146
Bug: 422586344
Bug: 313807618
Test: Built and run kernel
Change-Id: Ied33777bb04198f1e4a69b91f002ae70d0471bb3
Fixes: 988dc02cdd ("BACKPORT: mm: support large folios swap-in for sync io devices")
Signed-off-by: Juan Yescas <jyescas@google.com>
This commit is contained in:
Juan Yescas
2025-06-25 17:53:01 -07:00
parent 1c1f2b7526
commit fe3caa5756

View File

@@ -3962,7 +3962,7 @@ 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,
folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE|__GFP_CMA, 0, vma,
vmf->address, false);
if (!folio)
return NULL;