ANDROID: add vendor_hook to control CMA allocation ratio
CMA first allocation policy for movable makes CMA(Upstream doesn't) area always full. It's good for memory efficiency since it could use up CMA available memory most of time. However, it could cause cma_alloc slow since it causes a lot page migration all the time. Let's add vendor hook for someone who want to restore CMA allocation policy to upstream so they will see less page migration in cma_alloc. If the vendor_hook returns false, the rmqueue_bulk return 0 without filling pcp->lists so get_populated_pcp_list will return NULL. Once get_populated_pcp_list returns NULL, __rmqueue_pcplist will retry the page allocation with original migratetype(currently, original migratetype couldn't be MIGRATE_CMA) so the retrial will find available pages from !MIGRATE_CMA free list. Bug: 231978523 Signed-off-by: Minchan Kim <minchan@google.com> Change-Id: Ia031d9bc6f34085b892a8d9923bf5b9b1794f94a Signed-off-by: Richard Chang <richardycc@google.com> (cherry picked from commit 0ca85e35bf5b4a7ff08f00a060c83e4a82380b64)
This commit is contained in:
committed by
Richard Chang
parent
9fbfb867bd
commit
e3f396c2d4
@@ -274,4 +274,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_free);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_alloc);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_start);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_finish);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_adjust);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_enable_thermal_genl_check);
|
||||
|
||||
@@ -41,6 +41,9 @@ DECLARE_HOOK(android_vh_show_mem,
|
||||
DECLARE_HOOK(android_vh_alloc_pages_slowpath,
|
||||
TP_PROTO(gfp_t gfp_mask, unsigned int order, unsigned long delta),
|
||||
TP_ARGS(gfp_mask, order, delta));
|
||||
DECLARE_HOOK(android_vh_cma_alloc_adjust,
|
||||
TP_PROTO(struct zone *zone, bool *is_cma_alloc),
|
||||
TP_ARGS(zone, is_cma_alloc));
|
||||
DECLARE_HOOK(android_vh_print_slabinfo_header,
|
||||
TP_PROTO(struct seq_file *m),
|
||||
TP_ARGS(m));
|
||||
|
||||
@@ -3101,12 +3101,16 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
|
||||
*/
|
||||
spin_lock(&zone->lock);
|
||||
for (i = 0; i < count; ++i) {
|
||||
struct page *page;
|
||||
struct page *page = NULL;
|
||||
|
||||
if (is_migrate_cma(migratetype))
|
||||
if (is_migrate_cma(migratetype)) {
|
||||
bool is_cma_alloc = true;
|
||||
|
||||
trace_android_vh_cma_alloc_adjust(zone, &is_cma_alloc);
|
||||
if (is_cma_alloc)
|
||||
page = __rmqueue_cma(zone, order, migratetype,
|
||||
alloc_flags);
|
||||
else
|
||||
} else
|
||||
page = __rmqueue(zone, order, migratetype, alloc_flags);
|
||||
|
||||
if (unlikely(page == NULL))
|
||||
|
||||
Reference in New Issue
Block a user