[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b12340fa-358a-4799-a040-636994beef36@lucifer.local>
Date: Mon, 10 Nov 2025 21:16:23 +0000
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: "Garg, Shivank" <shivankg@....com>
Cc: Zi Yan <ziy@...dia.com>, Andrew Morton <akpm@...ux-foundation.org>,
David Hildenbrand <david@...hat.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>,
"Liam R . Howlett" <Liam.Howlett@...cle.com>,
Nico Pache <npache@...hat.com>, Ryan Roberts <ryan.roberts@....com>,
Dev Jain <dev.jain@....com>, Barry Song <baohua@...nel.org>,
Lance Yang <lance.yang@...ux.dev>,
Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Zach O'Keefe <zokeefe@...gle.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
Branden Moore <Branden.Moore@....com>
Subject: Re: [PATCH 1/2] mm/khugepaged: do synchronous writeback for
MADV_COLLAPSE
OK ignore the past mail, I have managed to repro this locally and have a
fix.
Turns out the swap code is doing something quite insane... I will send
fix-patches to the series shortly.
Meanwhile I attach fix-patch! :)
Cheers, Lorenzo
----8<----
>From c705fd85a806f53017df31e6b072c4bfa839e3a2 Mon Sep 17 00:00:00 2001
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Date: Mon, 10 Nov 2025 21:11:52 +0000
Subject: [PATCH] fix
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
---
include/linux/leafops.h | 4 ++--
mm/swapfile.c | 12 ++++++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/include/linux/leafops.h b/include/linux/leafops.h
index a464a7e08c76..c4cd36760ea0 100644
--- a/include/linux/leafops.h
+++ b/include/linux/leafops.h
@@ -56,7 +56,7 @@ static inline softleaf_t softleaf_from_pte(pte_t pte)
{
softleaf_t arch_entry;
- if (pte_present(pte))
+ if (pte_present(pte) || pte_none(pte))
return softleaf_mk_none();
pte = pte_swp_clear_flags(pte);
@@ -95,7 +95,7 @@ static inline softleaf_t softleaf_from_pmd(pmd_t pmd)
{
softleaf_t arch_entry;
- if (pmd_present(pmd))
+ if (pmd_present(pmd) || pmd_none(pmd))
return softleaf_mk_none();
if (pmd_swp_soft_dirty(pmd))
diff --git a/mm/swapfile.c b/mm/swapfile.c
index fd23d9f7ae10..f0dcf261f652 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -3202,9 +3202,17 @@ static int claim_swapfile(struct swap_info_struct *si, struct inode *inode)
*/
unsigned long generic_max_swapfile_size(void)
{
- const softleaf_t entry = swp_entry(0, ~0UL);
+ softleaf_t entry = swp_entry(0, ~0UL);
+ const pte_t pte = softleaf_to_pte(entry);
- return swp_offset(softleaf_from_pte(softleaf_to_pte(entry))) + 1;
+ /*
+ * Since the PTE can be an invalid swap entry (i.e. the none PTE), we do
+ * this manually.
+ */
+ entry = __pte_to_swp_entry(pte);
+ entry = swp_entry(__swp_type(entry), __swp_offset(entry));
+
+ return swp_offset(entry) + 1;
}
/* Can be overridden by an architecture for additional checks. */
--
2.51.0
Powered by blists - more mailing lists