Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: zswap: return -ENOENT when the swap device is gone
@ 2026-09-13  6:30 Baoquan He
  2026-09-13  7:48 ` Andrew Morton
  2026-09-13  7:51 ` Andrew Morton
  0 siblings, 2 replies; 3+ messages in thread
From: Baoquan He @ 2026-09-13  6:30 UTC (permalink / raw)
  To: akpm
  Cc: hannes, yosry, nphamcs, chengming.zhou, linux-mm, linux-kernel,
	kasong, chrisl, Baoquan He

zswap_writeback_entry() returns -EEXIST when get_swap_device() finds no
device.  -EEXIST is the shrinker's "page already in swap cache" signal,
which makes zswap_shrinker_scan() stop shrinking entirely.  A NULL
get_swap_device() instead means the device is being swapped off, so the
entry is simply stale.

Return -ENOENT so the shrinker skips the stale entry and keeps scanning.
Independent of xswap; affects all swap devices.

Signed-off-by: Baoquan He <hebaoquan@kylinos.cn>
Acked-by: Nhat Pham <nphamcs@gmail.com>
---
Note:
This is taken from xswap patchset. Nhat suggested this is a fix, should
be sent out independently.

 mm/zswap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index 37f34e406c8e..b9948d4657d2 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -998,7 +998,7 @@ static int zswap_writeback_entry(struct zswap_entry *entry,
 	/* try to allocate swap cache folio */
 	si = get_swap_device(swpentry);
 	if (!si)
-		return -EEXIST;
+		return -ENOENT;
 
 	mpol = get_task_policy(current);
 	folio = swap_cache_alloc_folio(swpentry, GFP_KERNEL, BIT(0), NULL, mpol,
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: zswap: return -ENOENT when the swap device is gone
  2026-09-13  6:30 [PATCH] mm: zswap: return -ENOENT when the swap device is gone Baoquan He
@ 2026-09-13  7:48 ` Andrew Morton
  2026-09-13  7:51 ` Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2026-09-13  7:48 UTC (permalink / raw)
  To: Baoquan He
  Cc: hannes, yosry, nphamcs, chengming.zhou, linux-mm, linux-kernel,
	kasong, chrisl

On Sun, 13 Sep 2026 14:30:31 +0800 Baoquan He <hebaoquan@kylinos.cn> wrote:

> zswap_writeback_entry() returns -EEXIST when get_swap_device() finds no
> device.  -EEXIST is the shrinker's "page already in swap cache" signal,
> which makes zswap_shrinker_scan() stop shrinking entirely.  A NULL
> get_swap_device() instead means the device is being swapped off, so the
> entry is simply stale.
> 
> Return -ENOENT so the shrinker skips the stale entry and keeps scanning.
> Independent of xswap; affects all swap devices.

I'm struggling to understand the userspace-visible runtime effects of this.

I see that reclaim will prematurely abort, but is this a once-off thing
which will resolve on the next reclaim attempt, or will the reclaim
failure persist for a significant period?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: zswap: return -ENOENT when the swap device is gone
  2026-09-13  6:30 [PATCH] mm: zswap: return -ENOENT when the swap device is gone Baoquan He
  2026-09-13  7:48 ` Andrew Morton
@ 2026-09-13  7:51 ` Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2026-09-13  7:51 UTC (permalink / raw)
  To: Baoquan He
  Cc: hannes, yosry, nphamcs, chengming.zhou, linux-mm, linux-kernel,
	kasong, chrisl

On Sun, 13 Sep 2026 14:30:31 +0800 Baoquan He <hebaoquan@kylinos.cn> wrote:

> zswap_writeback_entry() returns -EEXIST when get_swap_device() finds no
> device.  -EEXIST is the shrinker's "page already in swap cache" signal,
> which makes zswap_shrinker_scan() stop shrinking entirely.  A NULL
> get_swap_device() instead means the device is being swapped off, so the
> entry is simply stale.
> 
> Return -ENOENT so the shrinker skips the stale entry and keeps scanning.
> Independent of xswap; affects all swap devices.
> 
> ...
>
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -998,7 +998,7 @@ static int zswap_writeback_entry(struct zswap_entry *entry,
>  	/* try to allocate swap cache folio */

Comment was always lame ("say why, not what").  It now seems flat out wrong?

>  	si = get_swap_device(swpentry);
>  	if (!si)
> -		return -EEXIST;
> +		return -ENOENT;

mm-new has changed.  I made this


	/* try to allocate swap cache folio */
	si = get_swap_device(swpentry);
	if (IS_ERR_OR_NULL(si))
		return -ENOENT;



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-13  7:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-13  6:30 [PATCH] mm: zswap: return -ENOENT when the swap device is gone Baoquan He
2026-09-13  7:48 ` Andrew Morton
2026-09-13  7:51 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox