ANDROID: mm: add vendor_hook for mglru shrink

We want to perform a certain amount of reclaim operations on a non-root memcg, but in should_abort_scan,
the condition !root_reclaim(sc) causes unnecessary loop retries even if the nr_to_reclaim condition is met.
The call stack is as follows:
shrink_zones
shrink_node
shrink_node_memcgs
shrink_lruvec
lru_gen_shrink_lruvec
try_to_shrink_lruvec
should_abort_scan
if (!root_reclaim(sc))
	retry once more

The hook function: trace_android_vh_mglru_should_abort_scan is added to identify the intent to reclaim a specific memcg
and bypass the !root_reclaim(sc) condition.

Bug: 365008739
Change-Id: I297986dde2bf8ffe937cff3ffc814da92067029a
Signed-off-by: yipeng xiang <yipengxiang@honor.corp-partner.google.com>
This commit is contained in:
yipeng xiang 2024-09-06 16:04:51 +08:00
parent c0e21888b2
commit 4105548575
3 changed files with 9 additions and 1 deletions

View File

@ -335,6 +335,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_read_done);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_modify_scan_control);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_should_continue_reclaim);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_file_is_tiny_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mglru_should_abort_scan);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_signal);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_folio_look_around_ref);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_look_around);

View File

@ -58,6 +58,9 @@ DECLARE_HOOK(android_vh_should_continue_reclaim,
DECLARE_HOOK(android_vh_file_is_tiny_bypass,
TP_PROTO(bool file_is_tiny, bool *bypass),
TP_ARGS(file_is_tiny, bypass));
DECLARE_HOOK(android_vh_mglru_should_abort_scan,
TP_PROTO(u64 *ext, bool *bypass),
TP_ARGS(ext, bypass));
DECLARE_HOOK(android_vh_rebalance_anon_lru_bypass,
TP_PROTO(bool *bypass),
TP_ARGS(bypass));

View File

@ -5486,9 +5486,13 @@ static bool should_abort_scan(struct lruvec *lruvec, struct scan_control *sc)
{
int i;
enum zone_watermarks mark;
bool bypass = false;
#ifdef CONFIG_ANDROID_VENDOR_OEM_DATA
trace_android_vh_mglru_should_abort_scan(&sc->android_vendor_data1, &bypass);
#endif
/* don't abort memcg reclaim to ensure fairness */
if (!root_reclaim(sc))
if (!root_reclaim(sc) && !bypass)
return false;
if (sc->nr_reclaimed >= max(sc->nr_to_reclaim, compact_gap(sc->order)))