Re: [PATCH] mm/vmscan: when the swappiness is set to 0, memory swapping should be prohibited during the global reclaim process

From: Michal Hocko
Date: Mon Mar 03 2025 - 07:10:52 EST


On Thu 27-02-25 22:34:51, ying chen wrote:
> When we use zram as swap disks, global reclaim may cause the memory in some
> cgroups with memory.swappiness set to 0 to be swapped into zram. This memory
> won't be swapped back immediately after the free memory increases. Instead,
> it will continue to occupy the zram space, which may result in no available
> zram space for the cgroups with swapping enabled. Therefore, I think that
> when the vm.swappiness is set to 0, global reclaim should also refrain
> from memory swapping, just like these cgroups.

You are changing well established and understood semantic while working
around a problem that is not really clear to me. If the zram space is
limited then you should be using swap limits to control who can swap
out, no?

> Signed-off-by: yc1082463 <yc1082463@xxxxxxxxx>
> ---
> mm/vmscan.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index c767d71c43d7..bdbb0fc03412 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -2426,14 +2426,7 @@ static void get_scan_count(struct lruvec
> *lruvec, struct scan_control *sc,
> goto out;
> }
>
> - /*
> - * Global reclaim will swap to prevent OOM even with no
> - * swappiness, but memcg users want to use this knob to
> - * disable swapping for individual groups completely when
> - * using the memory controller's swap limit feature would be
> - * too expensive.
> - */
> - if (cgroup_reclaim(sc) && !swappiness) {
> + if (!swappiness) {
> scan_balance = SCAN_FILE;
> goto out;
> }
> --
> 2.34.1

--
Michal Hocko
SUSE Labs