From: Chengming Zhou <zhouchengming@bytedance.com>
To: Yosry Ahmed <yosryahmed@google.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Nhat Pham <nphamcs@gmail.com>, Chris Li <chrisl@kernel.org>,
Huang Ying <ying.huang@intel.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] mm: zswap: remove unnecessary trees cleanups in zswap_swapoff()
Date: Wed, 24 Jan 2024 15:34:05 +0800 [thread overview]
Message-ID: <305078e5-b31e-43ed-825d-7b634c9c9f58@bytedance.com> (raw)
In-Reply-To: <20240124045113.415378-3-yosryahmed@google.com>
On 2024/1/24 12:51, Yosry Ahmed wrote:
> During swapoff, try_to_unuse() makes sure that zswap_invalidate() is
> called for all swap entries before zswap_swapoff() is called. This means
> that all zswap entries should already be removed from the tree. Simplify
> zswap_swapoff() by removing the trees cleanup code, and leave an
> assertion in its place.
>
> Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Looks good to me, thanks!
Reviewed-by: Chengming Zhou <zhouchengming@bytedance.com>
> ---
> mm/zswap.c | 16 +++-------------
> 1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/mm/zswap.c b/mm/zswap.c
> index dcdd5ecfedb09..78df16d307aa8 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -1808,19 +1808,9 @@ void zswap_swapoff(int type)
> if (!trees)
> return;
>
> - for (i = 0; i < nr_zswap_trees[type]; i++) {
> - struct zswap_tree *tree = trees + i;
> - struct zswap_entry *entry, *n;
> -
> - /* walk the tree and free everything */
> - spin_lock(&tree->lock);
> - rbtree_postorder_for_each_entry_safe(entry, n,
> - &tree->rbroot,
> - rbnode)
> - zswap_free_entry(entry);
> - tree->rbroot = RB_ROOT;
> - spin_unlock(&tree->lock);
> - }
> + /* try_to_unuse() invalidated all the entries already */
> + for (i = 0; i < nr_zswap_trees[type]; i++)
> + WARN_ON_ONCE(!RB_EMPTY_ROOT(&trees[i].rbroot));
>
> kvfree(trees);
> nr_zswap_trees[type] = 0;
prev parent reply other threads:[~2024-01-24 7:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-24 4:51 [PATCH v2 0/2] mm: zswap: simplify zswap_swapoff() Yosry Ahmed
2024-01-24 4:51 ` [PATCH v2 1/2] mm: swap: enforce updating inuse_pages at the end of swap_range_free() Yosry Ahmed
2024-01-24 5:20 ` Huang, Ying
2024-01-24 4:51 ` [PATCH v2 2/2] mm: zswap: remove unnecessary trees cleanups in zswap_swapoff() Yosry Ahmed
2024-01-24 4:52 ` Yosry Ahmed
2024-01-24 7:34 ` Chengming Zhou [this message]
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=305078e5-b31e-43ed-825d-7b634c9c9f58@bytedance.com \
--to=zhouchengming@bytedance.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=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