mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luiz Capitulino <luizcap@redhat.com>
To: Kemeng Shi <shikemeng@huaweicloud.com>,
	chrisl@kernel.org, kasong@tencent.com, nphamcs@gmail.com,
	baoquan.he@linux.dev, baohua@kernel.org, youngjun.park@lge.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] mm, swap: Move setup_swap_clusters_info() after SWP_SOLIDSTATE initialization
Date: Mon, 20 Jul 2026 11:54:07 -0400	[thread overview]
Message-ID: <a8637ae5-1796-4dea-902d-1ae1238261e6@redhat.com> (raw)
In-Reply-To: <20260720071342.50742-3-shikemeng@huaweicloud.com>

On 2026-07-20 03:13, Kemeng Shi wrote:
> In setup_swap_clusters_info(), SWP_SOLIDSTATE is used to decide
> global_cluster allocation. Move setup_swap_clusters_info() after
> SWP_SOLIDSTATE initialization to avoid unneeded global_cluster
> allocation.
> 
> Fixes: 451c6326105b2 ("mm, swap: clean up swapon process and locking")
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>

I was about to send the same fix :) (one nit below)

> ---
>   mm/swapfile.c | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index d29062d9c3cd..81c4040912be 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -3607,11 +3607,6 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
>   
>   	maxpages = si->max;
>   
> -	/* Set up the swap cluster info */
> -	error = setup_swap_clusters_info(si, swap_header, maxpages);
> -	if (error)
> -		goto bad_swap_unlock_inode;
> -
>   	if (si->bdev && bdev_stable_writes(si->bdev))
>   		si->flags |= SWP_STABLE_WRITES;
>   
> @@ -3625,6 +3620,14 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
>   		inced_nr_rotate_swap = true;
>   	}
>   
> +	/*
> +	 * Set up the swap cluster info. SWP_SOLIDSTATE is used for
> +	 * global_cluster allocation
> +	 */

Maybe something like:

/*
  * Set up the swap cluster info after SWP_ flags handling as
  * setup_swap_clusters_info() checks SWP_SOLIDSTATE.
  */

As it's minor:

Reviewed-by: Luiz Capitulino <luizcap@redhat.com>

> +	error = setup_swap_clusters_info(si, swap_header, maxpages);
> +	if (error)
> +		goto bad_swap_unlock_inode;
> +
>   	if ((swap_flags & SWAP_FLAG_DISCARD) &&
>   	    si->bdev && bdev_max_discard_sectors(si->bdev)) {
>   		/*


  reply	other threads:[~2026-07-20 15:54 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 [this message]
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
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=a8637ae5-1796-4dea-902d-1ae1238261e6@redhat.com \
    --to=luizcap@redhat.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 \
    --cc=youngjun.park@lge.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

all inboxes | Powered by JetHome®