linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Christoph Hellwig <hch@infradead.org>, Jan Kara <jack@suse.cz>,
	William Kucharski <william.kucharski@oracle.com>,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH next 3/3] shmem: Fix "Unused swap" messages
Date: Sun, 2 Jan 2022 17:35:50 -0800 (PST)	[thread overview]
Message-ID: <49ae72d6-f5f-5cd-e480-e2212cb7af97@google.com> (raw)

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;
 		}

             reply	other threads:[~2022-01-03  1:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-03  1:35 Hugh Dickins [this message]
2022-01-03 15:36 ` [PATCH next 3/3] shmem: Fix "Unused swap" messages 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49ae72d6-f5f-5cd-e480-e2212cb7af97@google.com \
    --to=hughd@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=william.kucharski@oracle.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).