ANDROID: vendor_hooks:vendor hook for __alloc_pages_slowpath.

add vendor hook in __alloc_pages_slowpath ahead of
__alloc_pages_direct_reclaim and warn_alloc.

Bug: 243629905
Change-Id: Ieacc6cf79823c0bfacfdeec9afb55ed66f40d0b0
Signed-off-by: xiaofeng <xiaofeng5@xiaomi.com>
This commit is contained in:
xiaofeng 2022-08-24 19:34:06 +08:00 committed by Suren Baghdasaryan
parent 60b0f85e24
commit 025b5a487b
3 changed files with 23 additions and 0 deletions

View file

@ -282,3 +282,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_thermal_register);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_thermal_unregister);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_get_thermal_zone_device);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_thermal_power_cap);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_reclaim_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_failure_bypass);

View file

@ -65,6 +65,16 @@ DECLARE_HOOK(android_vh_cache_show,
TP_PROTO(struct seq_file *m, struct slabinfo *sinfo, struct kmem_cache *s),
TP_ARGS(m, sinfo, s));
DECLARE_HOOK(android_vh_alloc_pages_reclaim_bypass,
TP_PROTO(gfp_t gfp_mask, int order, int alloc_flags,
int migratetype, struct page **page),
TP_ARGS(gfp_mask, order, alloc_flags, migratetype, page));
DECLARE_HOOK(android_vh_alloc_pages_failure_bypass,
TP_PROTO(gfp_t gfp_mask, int order, int alloc_flags,
int migratetype, struct page **page),
TP_ARGS(gfp_mask, order, alloc_flags, migratetype, page));
#endif /* _TRACE_HOOK_MM_H */
/* This part must be outside protection */

View file

@ -5265,6 +5265,12 @@ retry:
if (current->flags & PF_MEMALLOC)
goto nopage;
trace_android_vh_alloc_pages_reclaim_bypass(gfp_mask, order,
alloc_flags, ac->migratetype, &page);
if (page)
goto got_pg;
/* Try direct reclaim and then allocating */
page = __alloc_pages_direct_reclaim(gfp_mask, order, alloc_flags, ac,
&did_some_progress);
@ -5380,6 +5386,11 @@ nopage:
goto retry;
}
fail:
trace_android_vh_alloc_pages_failure_bypass(gfp_mask, order,
alloc_flags, ac->migratetype, &page);
if (page)
goto got_pg;
warn_alloc(gfp_mask, ac->nodemask,
"page allocation failure: order:%u", order);
got_pg: