[PATCH v2 2/8] mm/huge_memory: add a comment to the open-coded swap entry

Tal Zussman tz2294 at columbia.edu
Tue Sep 8 08:16:32 PDT 2026


The swap entry of each new folio in __split_folio_to_order() is
computed by hand from folio->swap rather than with folio_swap_entry(),
because the folio's page count is not valid while it is being split.
Add a comment explaining this.

Signed-off-by: Tal Zussman <tz2294 at columbia.edu>
---
 mm/huge_memory.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index d1ce061601bc..1fabdcbd8c8f 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3763,6 +3763,10 @@ static void __split_folio_to_order(struct folio *folio, int old_order,
 		 */
 		VM_WARN_ON_ONCE_PAGE(new_folio->private, new_head);
 
+		/*
+		 * Not all folio fields are valid during a split, so open-code
+		 * the swap entry rather than using folio_swap_entry().
+		 */
 		if (folio_test_swapcache(folio))
 			new_folio->swap.val = folio->swap.val + i;
 

-- 
2.39.5




More information about the linux-arm-kernel mailing list