From: Nanzhe Zhao <zhaonanzhe@xiaomi.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Nanzhe Zhao <zhaonanzhe@xiaomi.com>,
linux-mm@kvack.org, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Minchan Kim <minchan@kernel.org>,
Kairui Song <kasong@tencent.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Nhat Pham <nphamcs@gmail.com>, Usama Arif <usama.arif@linux.dev>,
Yosry Ahmed <yosry@kernel.org>,
Chengming Zhou <chengming.zhou@linux.dev>,
Chris Li <chrisl@kernel.org>,
David Hildenbrand <david@kernel.org>,
Ying Huang <ying.huang@intel.com>,
Suren Baghdasaryan <surenb@google.com>,
Ryan Roberts <ryan.roberts@arm.com>,
Kanchana P Sridhar <kanchana.p.sridhar@intel.com>,
Wajdi K Feghali <wajdi.k.feghali@intel.com>,
Bala Seshasayee <bala.seshasayee@linux.intel.com>,
Nick Terrell <terrelln@fb.com>, Barry Song <baohua@kernel.org>,
Tangquan Zheng <zhengtangquan@oppo.com>,
Bo Zhang <zhangbo56@xiaomi.com>
Subject: [RFC PATCH v4 4/4] mm: swap: allow direct reclaim for synchronous multi-page swapin
Date: Sun, 15 Nov 2026 10:44:51 +0800 [thread overview]
Message-ID: <20261115024455.1465726-5-zhaonanzhe@xiaomi.com> (raw)
In-Reply-To: <20261115024455.1465726-1-zhaonanzhe@xiaomi.com>
Synchronous swap devices such as zram complete swap I/O in the faulting
context. With multi-page compression enabled, a 16 KiB block is
stored and decompressed as a single object.
The swapin allocation inherits the VMA's THP gfp mask, which drops
__GFP_DIRECT_RECLAIM for VMAs without MADV_HUGEPAGE. Under memory
pressure, the order-2 allocation fails and falls back to order-0,
requiring the entire 16 KiB block to be decompressed just to swap in
an order-0 page.
Allow direct reclaim for order-2 swapin allocation to improve the
allocation success rate and avoid partial reads.
Signed-off-by: Nanzhe Zhao <zhaonanzhe@xiaomi.com>
---
mm/swap_state.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/mm/swap_state.c b/mm/swap_state.c
index da65d75ceead..912b0e21a781 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -462,6 +462,13 @@ static struct folio *__swap_cache_alloc(struct swap_cluster_info *ci,
if (mpol || !vmf) {
folio = folio_alloc_mpol(gfp, order, mpol, ilx, numa_node_id());
} else {
+ /*
+ * zsmalloc uses order-2 pages to store compressed data.
+ * Allow direct reclaim to improve allocation success and
+ * avoid partial reads.
+ */
+ if (order == 2)
+ gfp |= __GFP_RECLAIM;
address = round_down(vmf->address, PAGE_SIZE << order);
folio = vma_alloc_folio(gfp, order, vmf->vma, address);
}
--
2.43.0
next prev parent reply other threads:[~2026-11-15 2:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 2:44 [RFC PATCH v4 0/4] mTHP-friendly compression in zsmalloc and zram based on multi-pages Nanzhe Zhao
2026-11-15 2:44 ` [RFC PATCH v4 1/4] mm: zsmalloc: support objects compressed based on multiple pages Nanzhe Zhao
2026-11-15 2:44 ` [RFC PATCH v4 2/4] zram: support compression at the granularity of multi-pages Nanzhe Zhao
2026-11-15 2:44 ` [RFC PATCH v4 3/4] zram: backend_zstd: use multi-page size for zstd parameter setup Nanzhe Zhao
2026-11-15 2:44 ` Nanzhe Zhao [this message]
2026-11-19 6:59 ` [syzbot ci] Re: mTHP-friendly compression in zsmalloc and zram based on multi-pages syzbot ci
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=20261115024455.1465726-5-zhaonanzhe@xiaomi.com \
--to=zhaonanzhe@xiaomi.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bala.seshasayee@linux.intel.com \
--cc=baohua@kernel.org \
--cc=chengming.zhou@linux.dev \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kanchana.p.sridhar@intel.com \
--cc=kasong@tencent.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=nphamcs@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=senozhatsky@chromium.org \
--cc=surenb@google.com \
--cc=terrelln@fb.com \
--cc=usama.arif@linux.dev \
--cc=wajdi.k.feghali@intel.com \
--cc=ying.huang@intel.com \
--cc=yosry@kernel.org \
--cc=zhangbo56@xiaomi.com \
--cc=zhengtangquan@oppo.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®