mm: zswap: fix zswap_never_enabled() for CONFIG_ZSWAP==N
Subsystems (2)
PATCH 1/1 mm: zswap: fix zswap_never_enabled() for CONFIG_ZSWAP==N
From: Barry Song <[email protected]>
If CONFIG_ZSWAP is set to N, it means zswap cannot be enabled. zswap_never_enabled() should return true.
--- include/linux/zswap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/zswap.h +1 -1
@@ -68,7 +68,7 @@ static inline bool zswap_is_enabled(void)static inline bool zswap_never_enabled (void ) { -return false; +return true; }#endif
Signature · 1 line
2.34.1
Quoted 14 lines · Barry Song
From: Barry Song <[email protected]>
If
CONFIG_ZSWAPis set to N, it means zswap cannot be enabled.zswap_never_enabled()should return true.Fixes 0300e17d67c3 ("mm: zswap: add zswap_never_enabled()")Signed-off-by Barry Song <[email protected]>Cc Yosry Ahmed <[email protected]>Cc Nhat Pham <[email protected]>Cc Chengming Zhou <[email protected]>Cc Chris Li <[email protected]>Cc David Hildenbrand <[email protected]>Cc Johannes Weiner <[email protected]>Cc Matthew Wilcox (Oracle) <[email protected]>
Quoted 1 line
---
Quoted 16 lines
include/linux/zswap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/zswap.h +1
-1@@ -68,7 +68,7 @@ static inline bool zswap_is_enabled(void)static inline bool zswap_never_enabled (void ) { -return false; +return true; }#endif
Quoted 8 lines · Barry Song
From: Barry Song <[email protected]>
If
CONFIG_ZSWAPis set to N, it means zswap cannot be enabled.zswap_never_enabled()should return true.Fixes 0300e17d67c3 ("mm: zswap: add zswap_never_enabled()")Signed-off-by Barry Song <[email protected]>
Chris
Quoted 35 lines · Barry Song
From: Barry Song <[email protected]>
If
CONFIG_ZSWAPis set to N, it means zswap cannot be enabled.zswap_never_enabled()should return true.Fixes 0300e17d67c3 ("mm: zswap: add zswap_never_enabled()")Signed-off-by Barry Song <[email protected]>Cc Yosry Ahmed <[email protected]>Cc Nhat Pham <[email protected]>Cc Chengming Zhou <[email protected]>Cc Chris Li <[email protected]>Cc David Hildenbrand <[email protected]>Cc Johannes Weiner <[email protected]>Cc Matthew Wilcox (Oracle) <[email protected]>--- include/linux/zswap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/zswap.h +1
-2@@ -68,7 +68,7 @@ static inline bool zswap_is_enabled(void)static inline bool zswap_never_enabled (void ) { -return false; +return true; }#endif --2.34.1
Andrew Morton
maintainerQuoted 10 lines · On Sun, 30 Jun 2024 11:22:31 +1200 Barry Song <[email protected]> wrote:
From: Barry Song <[email protected]>
If
CONFIG_ZSWAPis set to N, it means zswap cannot be enabled.zswap_never_enabled()should return true....
include/linux/zswap.h static inline bool zswap_is_enabled(void) · line 72
Quoted 6 lines
include/linux/zswap.h +1
-1@@ -68,7 +68,7 @@ static inline bool zswap_is_enabled(void)static inline bool zswap_never_enabled (void ) { -return false; +return true; }
Well, that code was as wrong as it's possible to get.
But what effect does this have? Seems "not much"? Perhaps we'll attempt a zswap_load() which later fails for other reasons?
Quoted 22 lines · Andrew Morton
Quoted 10 lines · On Sun, 30 Jun 2024 11:22:31 +1200 Barry Song <[email protected]> wrote:
From: Barry Song <[email protected]>
If
CONFIG_ZSWAPis set to N, it means zswap cannot be enabled.zswap_never_enabled()should return true....
include/linux/zswap.h static inline bool zswap_is_enabled(void) · line 72
Quoted 6 lines
include/linux/zswap.h +1
-1@@ -68,7 +68,7 @@ static inline bool zswap_is_enabled(void)static inline bool zswap_never_enabled (void ) { -return false; +return true; }Well, that code was as wrong as it's possible to get.
Quoted 2 lines
But what effect does this have? Seems "not much"? Perhaps we'll attempt a
zswap_load()which later fails for other reasons?
Yes, but the API was created to inform the mm core that zswap has never been enabled, allowing the mm core to perform mTHP swap-in. This is a transitional solution until zswap supports mTHP. If zswap has been enabled, performing mTHP swap-in will result in corrupted data. You may find the answer in the mTHP swap-in series:
https://lore.kernel.org/linux-mm/CAJD7tkZ4FQr6HZpduOdvmqgg_-whuZYE-Bz5O2t6yzw6Yg+v1A@mail.gmail.com/
Thanks
Barry
Quoted 22 lines · Andrew Morton
Quoted 10 lines · On Sun, 30 Jun 2024 11:22:31 +1200 Barry Song <[email protected]> wrote:
From: Barry Song <[email protected]>
If
CONFIG_ZSWAPis set to N, it means zswap cannot be enabled.zswap_never_enabled()should return true....
include/linux/zswap.h static inline bool zswap_is_enabled(void) · line 72
Quoted 6 lines
include/linux/zswap.h +1
-1@@ -68,7 +68,7 @@ static inline bool zswap_is_enabled(void)static inline bool zswap_never_enabled (void ) { -return false; +return true; }Well, that code was as wrong as it's possible to get.
Quoted 2 lines
But what effect does this have? Seems "not much"? Perhaps we'll attempt a
zswap_load()which later fails for other reasons?
Actually zswap_load() is a noop with !CONFIG_ZSWAP, so it doesn't have an effect there. The only effect is that with Barry's latest large folio swapin patches for zram, we will always fallback to order-0 swapin, even mistakenly when !CONFIG_ZSWAP.
Basically the bug just makes Barry's in progress patches not work at all.
Andrew Morton
maintainerQuoted 15 lines · On Tue, 2 Jul 2024 04:58:05 -0700 Yosry Ahmed <[email protected]> wrote:
Quoted 12 lines
include/linux/zswap.h static inline bool zswap_is_enabled(void) · line 72
Quoted 9 lines
include/linux/zswap.h +1
-1@@ -68,7 +68,7 @@ static inline bool zswap_is_enabled(void)static inline bool zswap_never_enabled (void ) { -return false; +return true; }Well, that code was as wrong as it's possible to get.
Quoted 2 lines
But what effect does this have? Seems "not much"? Perhaps we'll attempt a
zswap_load()which later fails for other reasons?
Quoted 6 lines
Actually
zswap_load()is a noop with !CONFIG_ZSWAP, so it doesn't have an effect there. The only effect is that with Barry's latest large folio swapin patches for zram, we will always fallback to order-0 swapin, even mistakenly when !CONFIG_ZSWAP.Basically the bug just makes Barry's in progress patches not work at all.
OK, thanks, I added this to the changelog:
The only effect of this issue is that with Barry's latest large folio swapin patches for zram ("mm: support mTHP swap-in for zRAM-like swapfile"), we will always fallback to order-0 swapin, even mistakenly when !CONFIG_ZSWAP.
Basically this bug makes Barry's in progress patches not work at all.
Quoted 23 lines · Barry Song
From: Barry Song <[email protected]>
If
CONFIG_ZSWAPis set to N, it means zswap cannot be enabled.zswap_never_enabled()should return true.Fixes 0300e17d67c3 ("mm: zswap: add zswap_never_enabled()")Signed-off-by Barry Song <[email protected]>Cc Yosry Ahmed <[email protected]>Cc Nhat Pham <[email protected]>Cc Chengming Zhou <[email protected]>Cc Chris Li <[email protected]>Cc David Hildenbrand <[email protected]>Cc Johannes Weiner <[email protected]>Cc Matthew Wilcox (Oracle) <[email protected]>--- include/linux/zswap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/zswap.h +0
-0
include/linux/zswap.h static inline bool zswap_is_enabled(void) · line 74
Quoted 8 lines
include/linux/zswap.h +1
-1@@ -68,7 +68,7 @@ static inline bool zswap_is_enabled(void)static inline bool zswap_never_enabled (void ) { -return false; +return true; }#endif
Signature · 3 lines
Cheers, David / dhildenb
Quoted 33 lines · Barry Song
From: Barry Song <[email protected]>
If
CONFIG_ZSWAPis set to N, it means zswap cannot be enabled.zswap_never_enabled()should return true.Fixes 0300e17d67c3 ("mm: zswap: add zswap_never_enabled()")Signed-off-by Barry Song <[email protected]>Cc Yosry Ahmed <[email protected]>Cc Nhat Pham <[email protected]>Cc Chengming Zhou <[email protected]>Cc Chris Li <[email protected]>Cc David Hildenbrand <[email protected]>Cc Johannes Weiner <[email protected]>Cc Matthew Wilcox (Oracle) <[email protected]>--- include/linux/zswap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/zswap.h +1
-2@@ -68,7 +68,7 @@ static inline bool zswap_is_enabled(void)static inline bool zswap_never_enabled (void ) { -return false; +return true; }#endif --
Quoted 2 lines
2.34.1
That's some pretty yikesy bug :) Thankfully this seems unused thus far (which is probably why it is not caught until now).
Thanks for fixing this, Barry!