linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Hugh Dickins <hughd@google.com>
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: Re: [PATCH next 3/3] shmem: Fix "Unused swap" messages
Date: Mon, 3 Jan 2022 15:36:40 +0000	[thread overview]
Message-ID: <YdMYCFIHA/wtcDVV@casper.infradead.org> (raw)
In-Reply-To: <49ae72d6-f5f-5cd-e480-e2212cb7af97@google.com>

On Sun, Jan 02, 2022 at 05:35:50PM -0800, Hugh Dickins wrote:
> 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.

I think what led to the loop was concern for the xa_state if trying
to find a swap entry that's smaller than the size of the folio.
So yes, the loop was expected to execute twice, but I didn't consider
the case where we were looking for something non-NULL and actually found
NULL.

So should we actually call xas_find_conflict() twice (if we're looking
for something non-NULL), and check that we get @expected, followed by
NULL?

  reply	other threads:[~2022-01-03 15:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-03  1:35 [PATCH next 3/3] shmem: Fix "Unused swap" messages Hugh Dickins
2022-01-03 15:36 ` Matthew Wilcox [this message]
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=YdMYCFIHA/wtcDVV@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=hughd@google.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=william.kucharski@oracle.com \
    /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).