mm/zswap: global lru and shrinker shared by all zswap_pools fix
authorChengming Zhou <chengming.zhou@linux.dev>
Tue, 5 Mar 2024 07:53:45 +0000 (07:53 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 6 Mar 2024 21:04:18 +0000 (13:04 -0800)
commite35606e4167dd55d48aa6232c074137577818add
tree36af510b5501a691237289c500e69cbb59558cc8
parent5aa598a72eafcf05239519646ec88638c8894dba
mm/zswap: global lru and shrinker shared by all zswap_pools fix

Commit bf9b7df23cb3 ("mm/zswap: global lru and shrinker shared by all
zswap_pools") introduced a new lock to protect zswap_next_shrink, instead
of reusing zswap_pools_lock.

But the problem is that it's initialized only when zswap enabled, which
causes bug if zswap_memcg_offline_cleanup() called without zswap enabled.

Fix it by using DEFINE_SPINLOCK() to statically initialize them and define
them as multiple static variables to keep in consistent with the existing
global variables in zswap.

Link: https://lkml.kernel.org/r/20240305075345.1493214-1-chengming.zhou@linux.dev
Fixes: bf9b7df23cb3 ("mm/zswap: global lru and shrinker shared by all zswap_pools")
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202403051008.a8cf8a94-lkp@intel.com
Signed-off-by: Chengming Zhou <chengming.zhou@linux.dev>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/zswap.c