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, anon_factor is set to 0 for swappiness=1 at higher reclaim priorities, making the two settings behave similarly, although the thresholds are slightly different. 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 81e81d69e67e..6d5a823667e0 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -5113,7 +5113,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 <= DEF_PRIORITY / 2 ? + 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 < DEF_PRIORITY / 2 ? refault_rate[LRU_GEN_ANON] * file_weight : 0; -- 2.34.1