From: Yosry Ahmed <yosryahmed@google.com>
To: Chris Li <chrisl@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Nhat Pham <nphamcs@gmail.com>,
Johannes Weiner <hannes@cmpxchg.org>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Chengming Zhou <zhouchengming@bytedance.com>,
Barry Song <v-songbaohua@oppo.com>
Subject: Re: [PATCH v7] zswap: replace RB tree with xarray
Date: Wed, 20 Mar 2024 07:24:27 +0000 [thread overview]
Message-ID: <ZfqPK7AVunq2SC1l@google.com> (raw)
In-Reply-To: <CANeU7Q=yxf0dnerTOZfe_ioeCbjnZd2Fpb-szvW7-Q1BzCUpOw@mail.gmail.com>
[..]
> > > - /* map */
> > > - spin_lock(&tree->lock);
> > > /*
> > > - * The folio may have been dirtied again, invalidate the
> > > - * possibly stale entry before inserting the new entry.
> > > + * We finish initializing the entry while it's already in xarray.
> > > + * This is safe because:
> > > + *
> > > + * 1. Concurrent stores and invalidations are excluded by folio lock.
> > > + *
> > > + * 2. Writeback is excluded by the entry not being on the LRU yet.
> > > + * The publishing order matters to prevent writeback from seeing
> > > + * an incoherent entry.
> >
> > As I mentioned before, writeback is also protected by the folio lock.
> > Concurrent writeback will find the folio in the swapcache and abort. The
> > fact that the entry is not on the LRU yet is just additional protection,
> > so I don't think the publishing order actually matters here. Right?
>
> Right. This comment is explaining why this publishing order does not
> matter. I think we are talking about the same thing here?
The comment literally says "the publishing order matters.." :)
I believe Johannes meant that we should only publish the entry to the
LRU once it is fully initialized, to prevent writeback from using a
partially initialized entry.
What I am saying is that, even if we add a partially initialized entry
to the zswap LRU, writeback will skip it anyway because the folio is
locked in the swapcache.
So basically I think the comment should say:
/*
* We finish initializing the entry while it's already in the
* xarray. This is safe because the folio is locked in the swap
* cache, which should protect against concurrent stores,
* invalidations, and writeback.
*/
Johannes, what do you think?
next prev parent reply other threads:[~2024-03-20 7:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 5:52 [PATCH v7] zswap: replace RB tree with xarray Chris Li
2024-03-20 6:13 ` Yosry Ahmed
2024-03-20 6:34 ` Chris Li
2024-03-20 7:24 ` Yosry Ahmed [this message]
2024-03-20 10:08 ` Johannes Weiner
2024-03-20 18:34 ` Chris Li
2024-03-20 19:11 ` Yosry Ahmed
2024-03-20 19:25 ` Johannes Weiner
2024-03-20 19:34 ` Yosry Ahmed
2024-03-20 19:41 ` Chris Li
2024-03-20 19:46 ` Yosry Ahmed
2024-03-20 20:03 ` Johannes Weiner
2024-03-20 20:12 ` Yosry Ahmed
2024-03-20 10:14 ` Johannes Weiner
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=ZfqPK7AVunq2SC1l@google.com \
--to=yosryahmed@google.com \
--cc=akpm@linux-foundation.org \
--cc=chrisl@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=v-songbaohua@oppo.com \
--cc=willy@infradead.org \
--cc=zhouchengming@bytedance.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).