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: <20240803120819.b2f539115ad3cec84de967bf@linux-foundation.org>
Date: Sat, 3 Aug 2024 12:08:19 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Barry Song <21cnbao@...il.com>
Cc: linux-mm@...ck.org, baolin.wang@...ux.alibaba.com, chrisl@...nel.org,
 david@...hat.com, hannes@...xchg.org, hughd@...gle.com,
 kaleshsingh@...gle.com, kasong@...cent.com, linux-kernel@...r.kernel.org,
 mhocko@...e.com, minchan@...nel.org, nphamcs@...il.com,
 ryan.roberts@....com, senozhatsky@...omium.org, shakeel.butt@...ux.dev,
 shy828301@...il.com, surenb@...gle.com, v-songbaohua@...o.com,
 willy@...radead.org, xiang@...nel.org, ying.huang@...el.com,
 yosryahmed@...gle.com, hch@...radead.org, Chuanhua Han
 <hanchuanhua@...o.com>
Subject: Re: [PATCH v6 2/2] mm: support large folios swap-in for zRAM-like
 devices

On Sat,  3 Aug 2024 00:20:31 +1200 Barry Song <21cnbao@...il.com> wrote:

> From: Chuanhua Han <hanchuanhua@...o.com>
> 
> Currently, we have mTHP features, but unfortunately, without support for large
> folio swap-ins, once these large folios are swapped out, they are lost because
> mTHP swap is a one-way process. The lack of mTHP swap-in functionality prevents
> mTHP from being used on devices like Android that heavily rely on swap.
> 
> This patch introduces mTHP swap-in support. It starts from sync devices such
> as zRAM. This is probably the simplest and most common use case, benefiting
> billions of Android phones and similar devices with minimal implementation
> cost. In this straightforward scenario, large folios are always exclusive,
> eliminating the need to handle complex rmap and swapcache issues.
> 
> It offers several benefits:
> 1. Enables bidirectional mTHP swapping, allowing retrieval of mTHP after
>    swap-out and swap-in. Large folios in the buddy system are also
>    preserved as much as possible, rather than being fragmented due
>    to swap-in.
> 
> 2. Eliminates fragmentation in swap slots and supports successful
>    THP_SWPOUT.
> 
>    w/o this patch (Refer to the data from Chris's and Kairui's latest
>    swap allocator optimization while running ./thp_swap_allocator_test
>    w/o "-a" option [1]):
> 
> ...
>
> +static struct folio *alloc_swap_folio(struct vm_fault *vmf)
> +{
> +	struct vm_area_struct *vma = vmf->vma;
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>
> ...
>
> +#endif
> +	return vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, vmf->address, false);
> +}

Generates an unused-variable warning with allnoconfig.  Because
vma_alloc_folio_noprof() was implemented as a macro instead of an
inlined C function.  Why do we keep doing this.

Please check:

From: Andrew Morton <akpm@...ux-foundation.org>
Subject: mm-support-large-folios-swap-in-for-zram-like-devices-fix
Date: Sat Aug  3 11:59:00 AM PDT 2024

fix unused var warning

mm/memory.c: In function 'alloc_swap_folio':
mm/memory.c:4062:32: warning: unused variable 'vma' [-Wunused-variable]
 4062 |         struct vm_area_struct *vma = vmf->vma;
      |                                ^~~

Cc: Baolin Wang <baolin.wang@...ux.alibaba.com>
Cc: Barry Song <v-songbaohua@...o.com>
Cc: Chris Li <chrisl@...nel.org>
Cc: Christoph Hellwig <hch@...radead.org>
Cc: Chuanhua Han <hanchuanhua@...o.com>
Cc: David Hildenbrand <david@...hat.com>
Cc: Gao Xiang <xiang@...nel.org>
Cc: "Huang, Ying" <ying.huang@...el.com>
Cc: Hugh Dickins <hughd@...gle.com>
Cc: Johannes Weiner <hannes@...xchg.org>
Cc: Kairui Song <kasong@...cent.com>
Cc: Kalesh Singh <kaleshsingh@...gle.com>
Cc: Matthew Wilcox <willy@...radead.org>
Cc: Michal Hocko <mhocko@...e.com>
Cc: Minchan Kim <minchan@...nel.org>
Cc: Nhat Pham <nphamcs@...il.com>
Cc: Ryan Roberts <ryan.roberts@....com>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>
Cc: Shakeel Butt <shakeel.butt@...ux.dev>
Cc: Suren Baghdasaryan <surenb@...gle.com>
Cc: Yang Shi <shy828301@...il.com>
Cc: Yosry Ahmed <yosryahmed@...gle.com>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
---

 mm/memory.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/mm/memory.c~mm-support-large-folios-swap-in-for-zram-like-devices-fix
+++ a/mm/memory.c
@@ -4059,8 +4059,8 @@ static inline bool can_swapin_thp(struct
 
 static struct folio *alloc_swap_folio(struct vm_fault *vmf)
 {
-	struct vm_area_struct *vma = vmf->vma;
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
+	struct vm_area_struct *vma = vmf->vma;
 	unsigned long orders;
 	struct folio *folio;
 	unsigned long addr;
@@ -4128,7 +4128,8 @@ static struct folio *alloc_swap_folio(st
 
 fallback:
 #endif
-	return vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, vmf->address, false);
+	return vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vmf->vma,
+			       vmf->address, false);
 }
 
 
_


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ