From: Chris Li <chrisl@kernel.org>
To: Yosry Ahmed <yosryahmed@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Nhat Pham <nphamcs@gmail.com>,
Chengming Zhou <zhouchengming@bytedance.com>,
Huang Ying <ying.huang@intel.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] mm: zswap: remove unnecessary tree cleanups in zswap_swapoff()
Date: Mon, 22 Jan 2024 14:31:46 -0800 [thread overview]
Message-ID: <CANeU7QkdVX0rYZS+QLv58L+zP5ZrHiGjrhxjMuA21o++QTW1nA@mail.gmail.com> (raw)
In-Reply-To: <20240120024007.2850671-3-yosryahmed@google.com>
On Fri, Jan 19, 2024 at 6:40 PM Yosry Ahmed <yosryahmed@google.com> 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 tree cleanup loop, and leaving an
> assertion in its place.
>
> Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
> ---
> Chengming, Chris, I think this should make the tree split and the xarray
> conversion patches simpler (especially the former). If others agree,
> both changes can be rebased on top of this.
I was wondering why those need to be there if all the zswap entries
should have been swapped in already. In my testing I never see this
delete of an entry so
think this is kind of just in case. Nice clean up and will help
simplify my zswap to xarray patch. Thanks for doing this.
Acked-by: Chris Li <chrisl@kernel.org> (Google)
Chris
> ---
> mm/zswap.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/mm/zswap.c b/mm/zswap.c
> index f8bc9e0892687..9675c3c27f9d1 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -1790,17 +1790,12 @@ void zswap_swapon(int type)
> void zswap_swapoff(int type)
> {
> struct zswap_tree *tree = zswap_trees[type];
> - struct zswap_entry *entry, *n;
>
> if (!tree)
> return;
>
> - /* 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 entries already */
> + WARN_ON_ONCE(!RB_EMPTY_ROOT(&tree->rbroot));
> kfree(tree);
> zswap_trees[type] = NULL;
> }
> --
> 2.43.0.429.g432eaa2c6b-goog
>
prev parent reply other threads:[~2024-01-22 22:32 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-20 2:40 [PATCH 0/2] mm: zswap: simplify zswap_swapoff() Yosry Ahmed
2024-01-20 2:40 ` [PATCH 1/2] mm: swap: update inuse_pages after all cleanups are done Yosry Ahmed
2024-01-22 13:17 ` Chengming Zhou
2024-01-23 8:59 ` Huang, Ying
2024-01-23 9:40 ` Yosry Ahmed
2024-01-23 9:54 ` Yosry Ahmed
2024-01-24 3:13 ` Huang, Ying
2024-01-24 3:20 ` Yosry Ahmed
2024-01-24 3:27 ` Huang, Ying
2024-01-24 4:15 ` Yosry Ahmed
2024-01-20 2:40 ` [PATCH 2/2] mm: zswap: remove unnecessary tree cleanups in zswap_swapoff() Yosry Ahmed
2024-01-22 13:13 ` Chengming Zhou
2024-01-22 20:19 ` Johannes Weiner
2024-01-22 20:39 ` Yosry Ahmed
2024-01-23 15:38 ` Johannes Weiner
2024-01-23 15:54 ` Yosry Ahmed
2024-01-23 20:12 ` Johannes Weiner
2024-01-23 21:02 ` Yosry Ahmed
2024-01-24 6:57 ` Yosry Ahmed
2024-01-25 5:28 ` Chris Li
2024-01-25 7:59 ` Yosry Ahmed
2024-01-25 18:55 ` Chris Li
2024-01-25 20:57 ` Yosry Ahmed
2024-01-25 22:31 ` Chris Li
2024-01-25 22:33 ` Yosry Ahmed
2024-01-26 1:09 ` Chris Li
2024-01-24 7:20 ` Chengming Zhou
2024-01-25 5:44 ` Chris Li
2024-01-25 8:01 ` Yosry Ahmed
2024-01-25 19:03 ` Chris Li
2024-01-25 21:01 ` Yosry Ahmed
2024-01-25 7:53 ` Yosry Ahmed
2024-01-25 8:03 ` Yosry Ahmed
2024-01-25 8:30 ` Chengming Zhou
2024-01-25 8:42 ` Yosry Ahmed
2024-01-25 8:52 ` Chengming Zhou
2024-01-25 9:03 ` Yosry Ahmed
2024-01-25 9:22 ` Chengming Zhou
2024-01-25 9:26 ` Yosry Ahmed
2024-01-25 9:38 ` Chengming Zhou
2024-01-26 0:03 ` Chengming Zhou
2024-01-26 0:05 ` Yosry Ahmed
2024-01-26 0:10 ` Chengming Zhou
2024-01-23 20:30 ` Nhat Pham
2024-01-23 21:04 ` Yosry Ahmed
2024-01-22 21:21 ` Nhat Pham
2024-01-22 22:31 ` Chris Li [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=CANeU7QkdVX0rYZS+QLv58L+zP5ZrHiGjrhxjMuA21o++QTW1nA@mail.gmail.com \
--to=chrisl@kernel.org \
--cc=akpm@linux-foundation.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 \
--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