linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Jackie Liu <liu.yun@linux.dev>,
	linux-mm@kvack.org, akpm@linux-foundation.org
Cc: hughd@google.com, liuyun01@kylinos.cn
Subject: Re: [PATCH] mm/shmem: remove redundant entry_order variable in shmem_split_large_entry()
Date: Mon, 8 Sep 2025 14:05:33 +0800	[thread overview]
Message-ID: <888448f1-518b-49f2-9c91-1f4434777720@linux.alibaba.com> (raw)
In-Reply-To: <20250908023915.28907-2-liu.yun@linux.dev>



On 2025/9/8 10:39, Jackie Liu wrote:
> From: Jackie Liu <liuyun01@kylinos.cn>
> 
> Commit d53c78fffe7a ("mm/shmem: use xas_try_split() in shmem_split_large_entry()")
> reworked shmem_split_large_entry() to use xas_try_split() and simplified
> the splitting logic. After that change, the local variable `entry_order`
> became redundant since its value was always immediately copied to `cur_order`.
> Remove `entry_order` and use `cur_order` directly to simplify the code.

The commit message is a bit misleading. It does not introduce a 
redundant variable by commit d53c78fffe7a. Instead, it's because after 
commit 93c0476e7057 ("mm/shmem, swap: rework swap entry and index 
calculation for large swapin"), the 'entry_order' will never be returned.

> No functional change intended.
> 
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> ---

With the commit message updated:
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>

>   mm/shmem.c | 11 ++++-------
>   1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/shmem.c b/mm/shmem.c
> index e2c76a30802b..53d28ea6e52b 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -2235,7 +2235,7 @@ static int shmem_split_large_entry(struct inode *inode, pgoff_t index,
>   {
>   	struct address_space *mapping = inode->i_mapping;
>   	XA_STATE_ORDER(xas, &mapping->i_pages, index, 0);
> -	int split_order = 0, entry_order;
> +	int split_order = 0;
>   	int i;
>   
>   	/* Convert user data gfp flags to xarray node gfp flags */
> @@ -2253,15 +2253,12 @@ static int shmem_split_large_entry(struct inode *inode, pgoff_t index,
>   			goto unlock;
>   		}
>   
> -		entry_order = xas_get_order(&xas);
> -
> -		if (!entry_order)
> +		cur_order = xas_get_order(&xas);
> +		if (!cur_order)
>   			goto unlock;
>   
>   		/* Try to split large swap entry in pagecache */
> -		cur_order = entry_order;
> -		swap_index = round_down(index, 1 << entry_order);
> -
> +		swap_index = round_down(index, 1 << cur_order);
>   		split_order = xas_try_split_min_order(cur_order);
>   
>   		while (cur_order > 0) {



  reply	other threads:[~2025-09-08  6:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-08  2:39 Jackie Liu
2025-09-08  2:39 ` Jackie Liu
2025-09-08  6:05   ` Baolin Wang [this message]
2025-09-08  6:22     ` Jackie Liu

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=888448f1-518b-49f2-9c91-1f4434777720@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-mm@kvack.org \
    --cc=liu.yun@linux.dev \
    --cc=liuyun01@kylinos.cn \
    /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