Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: use SWAPPINESS_ANON_ONLY in MGLRU

Using SWAPPINESS_ANON_ONLY instead of MAX_SWAPPINESS + 1 to indicate
reclaiming only from anonymous pages makes the code more readable and
explicit.

Add some comment in the SWAPPINESS_ANON_ONLY context.

Link: https://lkml.kernel.org/r/529db7ae6098ee712b81e4df290622e4e64ac50c.1745225696.git.hezhongkun.hzk@bytedance.com
Signed-off-by: Zhongkun He <hezhongkun.hzk@bytedance.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Yosry Ahmed <yosry.ahmed@linux.dev>
Cc: Yu Zhao <yuzhao@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Zhongkun He and committed by
Andrew Morton
a73dbc85 b4059993

+13 -4
+13 -4
mm/vmscan.c
··· 2705 2705 READ_ONCE((lruvec)->lrugen.min_seq[LRU_GEN_FILE]), \ 2706 2706 } 2707 2707 2708 + /* Get the min/max evictable type based on swappiness */ 2709 + #define min_type(swappiness) (!(swappiness)) 2710 + #define max_type(swappiness) ((swappiness) < SWAPPINESS_ANON_ONLY) 2711 + 2708 2712 #define evictable_min_seq(min_seq, swappiness) \ 2709 - min((min_seq)[!(swappiness)], (min_seq)[(swappiness) <= MAX_SWAPPINESS]) 2713 + min((min_seq)[min_type(swappiness)], (min_seq)[max_type(swappiness)]) 2710 2714 2711 2715 #define for_each_gen_type_zone(gen, type, zone) \ 2712 2716 for ((gen) = 0; (gen) < MAX_NR_GENS; (gen)++) \ ··· 2718 2714 for ((zone) = 0; (zone) < MAX_NR_ZONES; (zone)++) 2719 2715 2720 2716 #define for_each_evictable_type(type, swappiness) \ 2721 - for ((type) = !(swappiness); (type) <= ((swappiness) <= MAX_SWAPPINESS); (type)++) 2717 + for ((type) = min_type(swappiness); (type) <= max_type(swappiness); (type)++) 2722 2718 2723 2719 #define get_memcg_gen(seq) ((seq) % MEMCG_NR_GENS) 2724 2720 #define get_memcg_bin(bin) ((bin) % MEMCG_NR_BINS) ··· 3869 3865 int hist = lru_hist_from_seq(lrugen->min_seq[type]); 3870 3866 int new_gen, old_gen = lru_gen_from_seq(lrugen->min_seq[type]); 3871 3867 3872 - if (type ? swappiness > MAX_SWAPPINESS : !swappiness) 3868 + /* For file type, skip the check if swappiness is anon only */ 3869 + if (type && (swappiness == SWAPPINESS_ANON_ONLY)) 3870 + goto done; 3871 + 3872 + /* For anon type, skip the check if swappiness is zero (file only) */ 3873 + if (!type && !swappiness) 3873 3874 goto done; 3874 3875 3875 3876 /* prevent cold/hot inversion if the type is evictable */ ··· 5540 5531 5541 5532 if (swappiness < MIN_SWAPPINESS) 5542 5533 swappiness = get_swappiness(lruvec, sc); 5543 - else if (swappiness > MAX_SWAPPINESS + 1) 5534 + else if (swappiness > SWAPPINESS_ANON_ONLY) 5544 5535 goto done; 5545 5536 5546 5537 switch (cmd) {