From: Matthew Wilcox <willy@infradead.org>
To: Kairui Song <kasong@tencent.com>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Yosry Ahmed <yosryahmed@google.com>,
Nhat Pham <nphamcs@gmail.com>,
Chengming Zhou <chengming.zhou@linux.dev>,
Chris Li <chrisl@kernel.org>, Barry Song <v-songbaohua@oppo.com>,
"Huang, Ying" <ying.huang@intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm, zswap: don't touch the XArray lock if there is no entry to free
Date: Fri, 18 Oct 2024 20:46:35 +0100 [thread overview]
Message-ID: <ZxK7G3S0N42ejJMh@casper.infradead.org> (raw)
In-Reply-To: <20241018192525.95862-1-ryncsn@gmail.com>
On Sat, Oct 19, 2024 at 03:25:25AM +0800, Kairui Song wrote:
> if (xa_empty(tree))
> return;
>
> - entry = xa_erase(tree, offset);
> - if (entry)
> + rcu_read_lock();
> + entry = xas_load(&xas);
> + if (entry) {
You should call xas_reset() here. And I'm not sure it's a great idea to
spin waiting for the xa lock while holding the RCU read lock? Probably
not awful but I could easily be wrong.
> + xas_lock(&xas);
> + WARN_ON_ONCE(xas_reload(&xas) != entry);
> + xas_store(&xas, NULL);
> + xas_unlock(&xas);
> zswap_entry_free(entry);
> + }
> + rcu_read_unlock();
> }
>
> int zswap_swapon(int type, unsigned long nr_pages)
> --
> 2.47.0
>
>
next prev parent reply other threads:[~2024-10-18 19:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 19:25 Kairui Song
2024-10-18 19:46 ` Matthew Wilcox [this message]
2024-10-18 20:01 ` Kairui Song
2024-10-18 20:40 ` Yosry Ahmed
2024-10-18 20:55 ` Matthew Wilcox
2024-10-18 21:00 ` Yosry Ahmed
2024-10-18 21:38 ` Matthew Wilcox
2024-10-18 22:28 ` Yosry Ahmed
2024-10-18 22:38 ` 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=ZxK7G3S0N42ejJMh@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=chrisl@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=v-songbaohua@oppo.com \
--cc=ying.huang@intel.com \
--cc=yosryahmed@google.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