From: Youngjun Park <youngjun.park@lge.com>
To: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: chrisl@kernel.org, kasong@tencent.com, nphamcs@gmail.com,
baoquan.he@linux.dev, baohua@kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] mm, swap: return early from swap_extend_table_try_free() on first non-zero entry
Date: Tue, 21 Jul 2026 13:07:58 +0900 [thread overview]
Message-ID: <al7wnpZaIEA8BzOb@yjaykim-PowerEdge-T330> (raw)
In-Reply-To: <20260720071342.50742-4-shikemeng@huaweicloud.com>
On Mon, Jul 20, 2026 at 03:13:41PM +0800, Kemeng Shi wrote:
> Return immediately when the first non-zero swap count is found as
> any non-zero swap count prevents freeing extend_table and further
> iteration is pointless.
>
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
> mm/swapfile.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 81c4040912be..3fcbd10c6353 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -1530,20 +1530,17 @@ int swap_retry_table_alloc(swp_entry_t entry, gfp_t gfp)
> static void swap_extend_table_try_free(struct swap_cluster_info *ci)
> {
> unsigned long i;
> - bool can_free = true;
>
> if (!ci->extend_table)
> return;
>
> for (i = 0; i < SWAPFILE_CLUSTER; i++) {
> if (ci->extend_table[i])
> - can_free = false;
> + return;
> }
>
> - if (can_free) {
> - kfree(ci->extend_table);
> - ci->extend_table = NULL;
> - }
> + kfree(ci->extend_table);
> + ci->extend_table = NULL;
> }
>
> /* Decrease the swap count of one slot, without freeing it */
> --
> 2.36.1
>
LGTM :)
Thanks
Reviewed-by: Youngjun Park <youngjun.park@lge.com>
Youngjun
next prev parent reply other threads:[~2026-07-21 4:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 7:13 [PATCH 0/4] mm, swap: some random fixes and cleanups Kemeng Shi
2026-07-20 7:13 ` [PATCH 1/4] mm, swap: Fix potential NULL dereference when trying a sleep table allocation Kemeng Shi
2026-07-20 9:11 ` Youngjun Park
2026-07-21 1:49 ` Kemeng Shi
2026-07-21 2:15 ` Youngjun Park
2026-07-21 6:12 ` Kemeng Shi
2026-07-20 9:11 ` Kairui Song
2026-07-21 2:21 ` Kemeng Shi
2026-07-20 7:13 ` [PATCH 2/4] mm, swap: Move setup_swap_clusters_info() after SWP_SOLIDSTATE initialization Kemeng Shi
2026-07-20 15:54 ` Luiz Capitulino
2026-07-21 2:19 ` Kemeng Shi
2026-07-20 7:13 ` [PATCH 3/4] mm, swap: return early from swap_extend_table_try_free() on first non-zero entry Kemeng Shi
2026-07-21 4:07 ` Youngjun Park [this message]
2026-07-20 7:13 ` [PATCH 4/4] mm, swap: Remove unneeded swap_extend_table_try_free() in swap_dup_entries_cluster() Kemeng Shi
2026-07-21 7:58 ` Youngjun Park
2026-08-20 11:46 ` Kemeng Shi
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=al7wnpZaIEA8BzOb@yjaykim-PowerEdge-T330 \
--to=youngjun.park@lge.com \
--cc=baohua@kernel.org \
--cc=baoquan.he@linux.dev \
--cc=chrisl@kernel.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=shikemeng@huaweicloud.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