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: <f8051ae4-1b9d-42dc-8272-24a05741d86e@linux.alibaba.com>
Date: Mon, 8 Sep 2025 11:41:55 +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>,
 Matthew Wilcox <willy@...radead.org>, Hugh Dickins <hughd@...gle.com>,
 Chris Li <chrisl@...nel.org>, Barry Song <baohua@...nel.org>,
 Baoquan He <bhe@...hat.com>, Nhat Pham <nphamcs@...il.com>,
 Kemeng Shi <shikemeng@...weicloud.com>,
 Ying Huang <ying.huang@...ux.alibaba.com>,
 Johannes Weiner <hannes@...xchg.org>, David Hildenbrand <david@...hat.com>,
 Yosry Ahmed <yosryahmed@...gle.com>,
 Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, Zi Yan <ziy@...dia.com>,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 10/15] mm, swap: wrap swap cache replacement with a
 helper



On 2025/9/6 03:13, Kairui Song wrote:
> From: Kairui Song <kasong@...cent.com>
> 
> There are currently three swap cache users that are trying to replace an
> existing folio with a new one: huge memory splitting, migration, and
> shmem replacement. What they are doing is quite similar.
> 
> Introduce a common helper for this. In later commits, they can be easily
> switched to use the swap table by updating this helper.
> 
> The newly added helper also makes the swap cache API better defined, and
> debugging is easier.
> 
> Signed-off-by: Kairui Song <kasong@...cent.com>
> ---
>   mm/huge_memory.c |  5 ++---
>   mm/migrate.c     | 11 +++--------
>   mm/shmem.c       | 10 ++--------
>   mm/swap.h        |  3 +++
>   mm/swap_state.c  | 32 ++++++++++++++++++++++++++++++++
>   5 files changed, 42 insertions(+), 19 deletions(-)
> 
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 26cedfcd7418..a4d192c8d794 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -3798,9 +3798,8 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
>   			 * NOTE: shmem in swap cache is not supported yet.
>   			 */
>   			if (swap_cache) {
> -				__xa_store(&swap_cache->i_pages,
> -					   swap_cache_index(new_folio->swap),
> -					   new_folio, 0);
> +				__swap_cache_replace_folio(swap_cache, new_folio->swap,
> +							   folio, new_folio);
>   				continue;
>   			}

IIUC, it doesn't seem like a simple function replacement here. It 
appears that the original code has a bug: if the 'new_folio' is a large 
folio after split, we need to iterate over each swap entry of the large 
swapcache folio and then restore the new 'new_folio'.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ