Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 223c28d5 authored by Vinayak Menon's avatar Vinayak Menon
Browse files

mm: fix the use of ALLOC_CMA



Movable allocations are allowed to allocate from CMA areas
only when __GFP_CMA is set in the gfp mask of the request.
But ALLOC_CMA is set in alloc_flags for all movable requests.
This can make zone_watermark_ok take incorrect decision.
Fix this by adding ALLOC_CMA only when request is of type
__GFP_CMA.

Change-Id: I15531968021c71cfbedd01d12307a203f0b408ca
Signed-off-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
parent baf1f2ae
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -3798,7 +3798,8 @@ gfp_to_alloc_flags(gfp_t gfp_mask)
		alloc_flags |= ALLOC_HARDER;

#ifdef CONFIG_CMA
	if (gfpflags_to_migratetype(gfp_mask) == MIGRATE_MOVABLE)
	if ((gfpflags_to_migratetype(gfp_mask) == MIGRATE_MOVABLE) &&
				(gfp_mask & __GFP_CMA))
		alloc_flags |= ALLOC_CMA;
#endif
	return alloc_flags;
@@ -4278,7 +4279,8 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order,
	if (should_fail_alloc_page(gfp_mask, order))
		return false;

	if (IS_ENABLED(CONFIG_CMA) && ac->migratetype == MIGRATE_MOVABLE)
	if (IS_ENABLED(CONFIG_CMA) && ac->migratetype == MIGRATE_MOVABLE &&
			(gfp_mask & __GFP_CMA))
		*alloc_flags |= ALLOC_CMA;

	return true;