diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 5bba711af63e..8e4bb3950cca 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -314,3 +314,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_scmi_timeout_sync); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_new_ilb); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_force_compatible_pre); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_force_compatible_post); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_balance_anon_file_reclaim); diff --git a/include/trace/hooks/vmscan.h b/include/trace/hooks/vmscan.h index a2118ff6901d..b6b77d9895cd 100644 --- a/include/trace/hooks/vmscan.h +++ b/include/trace/hooks/vmscan.h @@ -25,6 +25,9 @@ DECLARE_HOOK(android_vh_tune_inactive_ratio, DECLARE_HOOK(android_vh_do_shrink_slab, TP_PROTO(struct shrinker *shrinker, struct shrink_control *shrinkctl, int priority), TP_ARGS(shrinker, shrinkctl, priority)); +DECLARE_RESTRICTED_HOOK(android_rvh_set_balance_anon_file_reclaim, + TP_PROTO(bool *balance_anon_file_reclaim), + TP_ARGS(balance_anon_file_reclaim), 1); #endif /* _TRACE_HOOK_VMSCAN_H */ /* This part must be outside protection */ #include diff --git a/mm/vmscan.c b/mm/vmscan.c index 0fef8daa52f6..d23a602e7d15 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2272,6 +2272,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, enum scan_balance scan_balance; unsigned long ap, fp; enum lru_list lru; + bool balance_anon_file_reclaim = false; /* If we have no swap space, do not bother scanning anon pages. */ if (!sc->may_swap || mem_cgroup_get_nr_swap_pages(memcg) <= 0) { @@ -2310,11 +2311,15 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, goto out; } + trace_android_rvh_set_balance_anon_file_reclaim(&balance_anon_file_reclaim); + /* * If there is enough inactive page cache, we do not reclaim - * anything from the anonymous working right now. + * anything from the anonymous working right now. But when balancing + * anon and page cache files for reclaim, allow swapping of anon pages + * even if there are a number of inactive file cache pages. */ - if (sc->cache_trim_mode) { + if (!balance_anon_file_reclaim && sc->cache_trim_mode) { scan_balance = SCAN_FILE; goto out; }