ANDROID: Add vendor hook for precondition check of use_cma_first

This commit introduce a precondition check for judging if enter
use_cma_first path which could keep the behaviour unchanged unless
when told explicitly.

Bug: 286444744
Test: build pass
Change-Id: I039760ca82bb2228c30fd62d083ea32a7abdd007
Signed-off-by: zhaoyang.huang <zhaoyang.huang@unisoc.com>
This commit is contained in:
zhaoyang.huang
2023-06-08 09:43:50 +08:00
committed by Treehugger Robot
parent 0a52bf2972
commit 43bb029673
3 changed files with 17 additions and 5 deletions

View File

@@ -430,6 +430,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_event);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_group);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rmqueue_smallest_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_one_page_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_use_cma_first_check);
/*
* For type visibility
*/

View File

@@ -177,6 +177,9 @@ DECLARE_HOOK(android_vh_free_one_page_bypass,
TP_PROTO(struct page *page, struct zone *zone, int order, int migratetype,
int fpi_flags, bool *bypass),
TP_ARGS(page, zone, order, migratetype, fpi_flags, bypass));
DECLARE_HOOK(android_vh_use_cma_first_check,
TP_PROTO(bool *use_cma_first_check),
TP_ARGS(use_cma_first_check));
#endif /* _TRACE_HOOK_MM_H */
/* This part must be outside protection */

View File

@@ -3878,13 +3878,21 @@ struct page *rmqueue_buddy(struct zone *preferred_zone, struct zone *zone,
* allocating from CMA base on judging zone_watermark_ok again
* to see if the latest check got pass via the help of CMA
*/
if (alloc_flags & ALLOC_CMA &&
use_cma_first(zone, order, alloc_flags))
page = __rmqueue_cma(zone, order, migratetype,
alloc_flags);
if (alloc_flags & ALLOC_CMA) {
bool use_cma_first_check = false;
bool try_cma;
trace_android_vh_use_cma_first_check(&use_cma_first_check);
try_cma = use_cma_first_check ?
use_cma_first(zone, order, alloc_flags) :
migratetype == MIGRATE_MOVABLE;
if (try_cma)
page = __rmqueue_cma(zone, order, migratetype,
alloc_flags);
}
if (!page)
page = __rmqueue(zone, order, migratetype,
alloc_flags);
alloc_flags);
}
if (!page) {
spin_unlock_irqrestore(&zone->lock, flags);