From: Yosry Ahmed <yosryahmed@google.com>
To: Chris Li <chrisl@kernel.org>
Cc: chengming.zhou@linux.dev, hannes@cmpxchg.org, nphamcs@gmail.com,
akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Chengming Zhou <zhouchengming@bytedance.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v3] mm/zswap: invalidate old entry when store fail or !zswap_enabled
Date: Tue, 6 Feb 2024 21:45:41 -0800 [thread overview]
Message-ID: <CAJD7tkbc7j8B3X8YfQ9r00D3ojJvJg+YwNuAF6P=jyCyrGy_=Q@mail.gmail.com> (raw)
In-Reply-To: <CAF8kJuOCbuFemoFNUYeNGYzYJ7eGLka6Y6OvSg8h61vXUfYdLw@mail.gmail.com>
> > @@ -1608,14 +1598,12 @@ bool zswap_store(struct folio *folio)
> > /* map */
> > spin_lock(&tree->lock);
> > /*
> > - * A duplicate entry should have been removed at the beginning of this
> > - * function. Since the swap entry should be pinned, if a duplicate is
> > - * found again here it means that something went wrong in the swap
> > - * cache.
> > + * The folio may have been dirtied again, invalidate the
> > + * possibly stale entry before inserting the new entry.
> > */
> > - while (zswap_rb_insert(&tree->rbroot, entry, &dupentry) == -EEXIST) {
> > - WARN_ON(1);
> > + if (zswap_rb_insert(&tree->rbroot, entry, &dupentry) == -EEXIST) {
> > zswap_invalidate_entry(tree, dupentry);
> > + VM_WARN_ON(zswap_rb_insert(&tree->rbroot, entry, &dupentry));
>
> It seems there is only one path called zswap_rb_insert() and there is
> no loop to repeat the insert any more. Can we have the
> zswap_rb_insert() install the entry and return the dupentry? We can
> still just call zswap_invalidate_entry() on the duplicate. The mapping
> of the dupentry has been removed when zswap_rb_insert() returns. That
> will save a repeat lookup on the duplicate case.
> After this change, the zswap_rb_insert() will map to the xarray
> xa_store() pretty nicely.
I brought this up in v1 [1]. We agreed to leave it as-is for now since
we expect the xarray conversion soon-ish. No need to update
zswap_rb_insert() only to replace it with xa_store() later anyway.
[1] https://lore.kernel.org/lkml/ZcFne336KJdbrvvS@google.com/
next prev parent reply other threads:[~2024-02-07 5:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-07 3:38 chengming.zhou
2024-02-07 5:41 ` Chris Li
2024-02-07 5:45 ` Yosry Ahmed [this message]
2024-02-07 5:52 ` Chris Li
2024-02-07 11:36 ` Chengming Zhou
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='CAJD7tkbc7j8B3X8YfQ9r00D3ojJvJg+YwNuAF6P=jyCyrGy_=Q@mail.gmail.com' \
--to=yosryahmed@google.com \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=chrisl@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=stable@vger.kernel.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