In MGLRU, swappiness=200 favors anon reclaim, while swappiness=1 favors file reclaim. Swappiness=0 allows only file reclaim, while swappiness=201 allows only anon reclaim. Thus, swappiness=1 and swappiness=200 are counterparts for file and anon reclaim, respectively. Before this patchset, get_type_to_scan() always returned LRU_GEN_ANON for swappiness=200 and LRU_GEN_FILE for swappiness=1. For swappiness=200, file_factor is set to 0 at higher reclaim priorities. Similarly, for swappiness=1, anon_factor is set to 0 at higher reclaim priorities. This makes the two settings behave similarly, although the thresholds differ slightly based on testing. This allows file pages to be reclaimed more aggressively and benefits workloads that prioritize file reclaim by using swappiness=1. Signed-off-by: Barry Song (Xiaomi) --- mm/vmscan.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index abefd91f5b95..a9b97d23838b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4955,7 +4955,11 @@ static void lru_gen_balance_scan(struct lruvec *lruvec, struct scan_control *sc, anon_weight = nr[LRU_GEN_ANON] + nr[LRU_GEN_FILE] / size_bias; file_weight = nr[LRU_GEN_FILE] + nr[LRU_GEN_ANON] / size_bias; - anon_factor = (u64)swappiness * refault_rate[LRU_GEN_FILE] * anon_weight; + if (swappiness == MIN_SWAPPINESS + 1) + anon_factor = sc->priority <= AGING_PRIORITY ? + refault_rate[LRU_GEN_FILE] * anon_weight : 0; + else + anon_factor = (u64)swappiness * refault_rate[LRU_GEN_FILE] * anon_weight; if (swappiness == MAX_SWAPPINESS) file_factor = sc->priority < AGING_PRIORITY ? refault_rate[LRU_GEN_ANON] * file_weight : 0; -- 2.39.3 (Apple Git-146)