All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH next 3/3] shmem: Fix "Unused swap" messages
@ 2022-01-03  1:35 Hugh Dickins
  2022-01-03 15:36 ` Matthew Wilcox
  0 siblings, 1 reply; 6+ messages in thread
From: Hugh Dickins @ 2022-01-03  1:35 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Andrew Morton, Christoph Hellwig, Jan Kara, William Kucharski,
	linux-fsdevel, linux-mm

shmem_swapin_page()'s swap_free() has occasionally been generating
"_swap_info_get: Unused swap offset entry" messages.  Usually that's
no worse than noise; but perhaps it indicates a worse case, when we
might there be freeing swap already reused by others.

The multi-index xas_find_conflict() loop in shmem_add_to_page_cache()
did not allow for entry found NULL when expected to be non-NULL, so did
not catch that race when the swap has already been freed.

The loop would not actually catch a realistic conflict which the single
check does not catch, so revert it back to the single check.

Fixes: 3103f9a51dd0 ("mm: Use multi-index entries in the page cache")
Signed-off-by: Hugh Dickins <hughd@google.com>
---

 mm/shmem.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- hughd2/mm/shmem.c
+++ hughd3/mm/shmem.c
@@ -727,9 +727,8 @@ static int shmem_add_to_page_cache(struc
 	do {
 		void *entry;
 		xas_lock_irq(&xas);
-		while ((entry = xas_find_conflict(&xas)) != NULL) {
-			if (entry == expected)
-				continue;
+		entry = xas_find_conflict(&xas);
+		if (entry != expected) {
 			xas_set_err(&xas, -EEXIST);
 			goto unlock;
 		}

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

end of thread, other threads:[~2022-01-04  8:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-03  1:35 [PATCH next 3/3] shmem: Fix "Unused swap" messages Hugh Dickins
2022-01-03 15:36 ` Matthew Wilcox
2022-01-03 20:10   ` Hugh Dickins
2022-01-04  1:41     ` Matthew Wilcox
2022-01-04  4:43       ` Hugh Dickins
2022-01-04  8:12         ` Matthew Wilcox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.