lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f3a54399-6a1b-467f-97d7-ee2481ac811b@linux.alibaba.com>
Date: Mon, 7 Jul 2025 16:14:39 +0800
From: Baolin Wang <baolin.wang@...ux.alibaba.com>
To: Kairui Song <kasong@...cent.com>, linux-mm@...ck.org
Cc: Andrew Morton <akpm@...ux-foundation.org>, Hugh Dickins
 <hughd@...gle.com>, Matthew Wilcox <willy@...radead.org>,
 Kemeng Shi <shikemeng@...weicloud.com>, Chris Li <chrisl@...nel.org>,
 Nhat Pham <nphamcs@...il.com>, Baoquan He <bhe@...hat.com>,
 Barry Song <baohua@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 7/9] mm/shmem, swap: simplify swapin path and result
 handling



On 2025/7/5 02:17, Kairui Song wrote:
> From: Kairui Song <kasong@...cent.com>
> 
> Slightly tidy up the different handling of swap in and error handling
> for SWP_SYNCHRONOUS_IO and non-SWP_SYNCHRONOUS_IO devices. Now swapin
> will always use either shmem_swapin_direct or shmem_swapin_cluster,
> then check the result.
> 
> Simplify the control flow and avoid a redundant goto label.
> 
> Signed-off-by: Kairui Song <kasong@...cent.com>
> ---
>   mm/shmem.c | 31 +++++++++++++------------------
>   1 file changed, 13 insertions(+), 18 deletions(-)
> 
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 1fe9a3eb92b1..782162c0c4e0 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -2327,33 +2327,28 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
>   			count_vm_event(PGMAJFAULT);
>   			count_memcg_event_mm(fault_mm, PGMAJFAULT);
>   		}
> -		/* Skip swapcache for synchronous device. */
>   		if (data_race(si->flags & SWP_SYNCHRONOUS_IO)) {
> +			/* Direct mTHP swapin skipping swap cache & readhaed */
>   			folio = shmem_swapin_direct(inode, vma, index, swap,
>   						    index_entry, order, gfp);
> -			if (!IS_ERR(folio)) {
> +			if (IS_ERR(folio)) {
> +				error = PTR_ERR(folio);
> +				folio = NULL;
> +				goto failed;
> +			} else {

The 'else' can be avoided, otherwise LGTM.

>   				if (folio_test_large(folio))
>   					swap = index_entry;
>   				skip_swapcache = true;
> -				goto alloced;
>   			}
> -
> -			/*
> -			 * Direct swapin handled order 0 fallback already,
> -			 * if it failed, abort.
> -			 */
> -			error = PTR_ERR(folio);
> -			folio = NULL;
> -			goto failed;
> -		}
> -		/* Cached swapin with readahead, only supports order 0 */
> -		folio = shmem_swapin_cluster(swap, gfp, info, index);
> -		if (!folio) {
> -			error = -ENOMEM;
> -			goto failed;
> +		} else {
> +			/* Cached swapin with readhaed, only supports order 0 */
> +			folio = shmem_swapin_cluster(swap, gfp, info, index);
> +			if (!folio) {
> +				error = -ENOMEM;
> +				goto failed;
> +			}
>   		}
>   	}
> -alloced:
>   	if (order > folio_order(folio)) {
>   		/*
>   		 * Swapin may get smaller folios due to various reasons:


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ