Skip to contentSkip to conversation

mm: zswap: fix zswap_never_enabled() for CONFIG_ZSWAP==N

PATCH Applied Barry Song 7 participants 10 messages Jun 29, 2024 – Jul 3, 2024

Subsystems (2)
lore
Share & tools
lore

Barry Song

author
#0 lore raw

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.

Fixes 0300e17d67c3 ("mm: zswap: add zswap_never_enabled()")
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 -1
index bf83ae5e285d..6cecb4a4f68b 100644
@@ -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
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Barry Song

From: Barry Song <[email protected]>

If CONFIG_ZSWAP is set to N, it means zswap cannot be enabled. zswap_never_enabled() should return true.

Fixes 0300e17d67c3 ("mm: zswap: add zswap_never_enabled()")
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
index bf83ae5e285d..6cecb4a4f68b 100644
@@ -68,7 +68,7 @@ static inline bool zswap_is_enabled(void)
 
  static inline bool zswap_never_enabled(void)
  {
-	return false;
+	return true;
  }
 
  #endif
Acked-by on v1 1/1
#3 lore raw
In reply to Barry Song

Chris

Quoted 35 lines · Barry Song

From: Barry Song <[email protected]>

If CONFIG_ZSWAP is set to N, it means zswap cannot be enabled. zswap_never_enabled() should return true.

Fixes 0300e17d67c3 ("mm: zswap: add zswap_never_enabled()")
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
index bf83ae5e285d..6cecb4a4f68b 100644
@@ -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

maintainer
#4 lore raw
In reply to Barry Song
Quoted 10 lines · On Sun, 30 Jun 2024 11:22:31 +1200 Barry Song <[email protected]> wrote:

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 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?

author
#5 lore raw
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_ZSWAP is 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

#6 lore raw
In reply to Andrew Morton
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_ZSWAP is 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.

maintainer
#7 lore raw
Quoted 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.

Acked-by on v1 1/1
#8 lore raw
In reply to Barry Song
Quoted 23 lines · Barry Song

From: Barry Song <[email protected]>

If CONFIG_ZSWAP is set to N, it means zswap cannot be enabled. zswap_never_enabled() should return true.

Fixes 0300e17d67c3 ("mm: zswap: add zswap_never_enabled()")
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
index bf83ae5e285d..6cecb4a4f68b 100644

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
maintainer Reviewed-by on v1 1/1
#9 lore raw
In reply to Barry Song
Quoted 33 lines · Barry Song

From: Barry Song <[email protected]>

If CONFIG_ZSWAP is set to N, it means zswap cannot be enabled. zswap_never_enabled() should return true.

Fixes 0300e17d67c3 ("mm: zswap: add zswap_never_enabled()")
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
index bf83ae5e285d..6cecb4a4f68b 100644
@@ -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!