Skip to content

mm: remove page_swap_entry()

Tal Zussman linux-arm-kernel linux-mm lkml 2 versions – In review

Get series with b4
b4 am [email protected] change-id 20260807-folio_swap_entry-e53d68610de0

Versions newest first

  1. v2 Latest8 patches 14 repliesIn review 7 of 8 applied
  2. v18 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- Keep the swap entry computation in __split_folio_to_order() open-coded
and add a comment, per Zi Yan.
- Reduce the zswap patch to using folio_swap_entry(), as the folio
conversion landed separately.
- Link to v1: https://patch.msgid.link/[email protected]

Patches in v2 7 of 8 applied

#Subject and filesSizeRepliesApplied
1/8mm/swap: add folio_swap_entry() and folio_page_swap_entry()include/linux/swap.h+33 -05 replies
2/8mm/huge_memory: add a comment to the open-coded swap entrymm/huge_memory.c+4 -02 repliesApplied
3/8mm/rmap: use folio_page_swap_entry() in ttu_anon_swapbacked_folio()mm/rmap.c+1 -11 replyApplied
4/8mm/zswap: use folio_swap_entry() in zswap_store_page()mm/zswap.c+1 -21 replyApplied
5/8mm/swapfile: use folio_page_swap_entry()mm/swapfile.c+2 -21 replyApplied
6/8arm64: mte: make mte_save_tags() and mte_restore_tags() staticarch/arm64/include/asm/mte.h arch/arm64/mm/mteswap.c+2 -41 replyApplied
7/8arm64: mte: pass the swap entry to mte_save_tags()arch/arm64/mm/mteswap.c+13 -171 replyApplied
8/8mm/swap: remove page_swap_entry()include/linux/swap.h+0 -91 replyApplied

Reviews trailers per patch

All 8 patches have a Reviewed-by or Acked-by.

PatchZi YanDavid Hildenbrand (Arm)
1/8A-b
2/8R-b A-b
3/8A-b
4/8A-b
5/8A-b
6/8A-b
7/8A-b
8/8A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/8] mm: remove page_swap_entry()

A folio in the swap cache occupies folio_nr_pages() contiguous swap entries starting at folio->swap, so a page's swap entry is just folio->swap plus the page's index in the folio. The swap entry is folio state, but the only helper for it is page-based:
page_swap_entry() takes a page and recomputes the folio its callers already hold. Several callers avoid it by open-coding the arithmetic on folio->swap instead.

Add folio_swap_entry() and folio_page_swap_entry(), convert all users, and remove page_swap_entry(), with a few other cleanups along the way.

---
Changes in v2:
- Keep the swap entry computation in __split_folio_to_order() open-coded
and add a comment, per Zi Yan.
- Reduce the zswap patch to using folio_swap_entry(), as the folio
conversion landed separately.
- Link to v1: https://patch.msgid.link/[email protected]

---
Tal Zussman (8):
mm/swap: add folio_swap_entry() and folio_page_swap_entry() mm/huge_memory: add a comment to the open-coded swap entry mm/rmap: use folio_page_swap_entry() in ttu_anon_swapbacked_folio() mm/zswap: use folio_swap_entry() in zswap_store_page() mm/swapfile: use folio_page_swap_entry()
arm64: mte: make mte_save_tags() and mte_restore_tags() static
arm64: mte: pass the swap entry to mte_save_tags() mm/swap: remove page_swap_entry()

 arch/arm64/include/asm/mte.h |  2 --
 arch/arm64/mm/mteswap.c      | 32 ++++++++++++++------------------
 include/linux/swap.h         | 30 +++++++++++++++++++++++++++---
 mm/huge_memory.c             |  4 ++++
 mm/rmap.c                    |  2 +-
 mm/swapfile.c                |  4 ++--
 mm/zswap.c                   |  3 +--
 7 files changed, 49 insertions(+), 28 deletions(-)

---
base-commit: 9d3243fc689fef444f87e0a703b4c99653137e1b
change-id: 20260807-folio_swap_entry-e53d68610de0

Best regards,

Signature · 1 line
Tal Zussman <[email protected]>