ANDROID: mm: vmscan: support equal reclaim for anon and file pages

When performing memory reclaim, support treating anonymous and
file backed pages equally. Swapping anonymous pages out to memory
can be efficient enough to justify treating anonymous and file backed
pages equally.
Create a vendor hook inside of get_scan_count so that equal reclaim of
anon and file pages can be enabled inside of the trace hook based on
certain conditions.

Bug: 175415908
Change-Id: Idac2f1468371549d20dd3e5652c7382dc3d7d9cf
Signed-off-by: Sudarshan Rajagopalan <sudaraja@codeaurora.org>
This commit is contained in:
Sudarshan Rajagopalan 2021-06-01 04:05:01 -07:00 committed by Suren Baghdasaryan
parent 4a819fbf90
commit 2699fa478d
3 changed files with 11 additions and 2 deletions

View File

@ -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);

View File

@ -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 <trace/define_trace.h>

View File

@ -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;
}