From: Baoquan He inc_min_seq() open-codes the evictable type check that for_each_evictable_type() already expresses through min_type() and max_type(). Use a shared is_type_evictable() helper so the two cannot drift apart, and rename the done label to advance to make it clear that a skipped rotation still advances min_seq. No functional change. Signed-off-by: Baoquan He --- mm/vmscan.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index be89bc2528a9..257305fe1cce 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2785,6 +2785,11 @@ static bool should_clear_pmd_young(void) #define min_type(swappiness) (!(swappiness)) #define max_type(swappiness) ((swappiness) < SWAPPINESS_ANON_ONLY) +static inline bool is_type_evictable(int type, int swappiness) +{ + return type >= min_type(swappiness) && type <= max_type(swappiness); +} + #define evictable_min_seq(min_seq, swappiness) \ min((min_seq)[min_type(swappiness)], (min_seq)[max_type(swappiness)]) @@ -3976,13 +3981,9 @@ static bool inc_min_seq(struct lruvec *lruvec, int type, int swappiness) int new_gen, old_gen = lru_gen_from_seq(lrugen->min_seq[type]); int target_gen = (old_gen + 1) % MAX_NR_GENS; - /* For file type, skip the check if swappiness is anon only */ - if (type && (swappiness == SWAPPINESS_ANON_ONLY)) - goto done; - - /* For anon type, skip the check if swappiness is zero (file only) */ - if (!type && !swappiness) - goto done; + /* A type that isn't being reclaimed needs no rotation */ + if (!is_type_evictable(type, swappiness)) + goto advance; VM_WARN_ON_ONCE(get_nr_gens(lruvec, type) != MAX_NR_GENS); VM_WARN_ON_ONCE(lru_gen_is_active(lruvec, old_gen) != @@ -4042,7 +4043,7 @@ static bool inc_min_seq(struct lruvec *lruvec, int type, int swappiness) if (!remaining) return false; } -done: +advance: reset_ctrl_pos(lruvec, type, true); WRITE_ONCE(lrugen->min_seq[type], lrugen->min_seq[type] + 1); -- 2.52.0