From 7f2f532bd043333528304d26fa5be6f8d8f5890e Mon Sep 17 00:00:00 2001 From: jianhua hao Date: Tue, 6 May 2025 10:42:25 +0800 Subject: [PATCH] ANDROID: mm: export __pte_offset_map/unuse_swap_pte/read_swap_cache_async Export __pte_offset_map facilitate retrieving the corresponding PTE using PMD and an address. Add and export unuse_swap_pte to facilitate releasing the PTE resources corresponding to pages preloaded via swapin. Export read_swap_cache_async to facilitate asynchronously reading pages from the swap partition using PTE-prefetch scanning. Bug: 415852480 Change-Id: Ie200656ec97b087936ca98c06b0a370f547d5d0a Signed-off-by: jianhua hao (cherry picked from commit 88cb3505ebf4d9eb1dd0d3c63403727eb4b239bd) (cherry picked from commit c5defcb638906800d4ab6b50e79e9f25538aefbd) --- include/linux/swapfile.h | 3 +++ mm/swap_state.c | 2 ++ mm/swapfile.c | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/include/linux/swapfile.h b/include/linux/swapfile.h index 7ed529a77c5b..c558a34e8f5d 100644 --- a/include/linux/swapfile.h +++ b/include/linux/swapfile.h @@ -10,6 +10,9 @@ extern struct swap_info_struct *swap_info[]; extern unsigned long generic_max_swapfile_size(void); unsigned long arch_max_swapfile_size(void); +extern int unuse_swap_pte(struct vm_area_struct *vma, pmd_t *pmd, + unsigned long addr, swp_entry_t entry, struct folio *folio); + /* Maximum swapfile size supported for the arch (not inclusive). */ extern unsigned long swapfile_maximum_size; /* Whether swap migration entry supports storing A/D bits for the arch */ diff --git a/mm/swap_state.c b/mm/swap_state.c index df44400df83f..5df7763971c9 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -528,6 +528,8 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, return retpage; } +EXPORT_SYMBOL_GPL(read_swap_cache_async); + static unsigned int __swapin_nr_pages(unsigned long prev_offset, unsigned long offset, int hits, diff --git a/mm/swapfile.c b/mm/swapfile.c index d3c0276369d8..5d552d41cbf4 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1855,6 +1855,13 @@ out: return ret; } +int unuse_swap_pte(struct vm_area_struct *vma, pmd_t *pmd, + unsigned long addr, swp_entry_t entry, struct folio *folio) +{ + return unuse_pte(vma, pmd, addr, entry, folio); +} +EXPORT_SYMBOL_GPL(unuse_swap_pte); + static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd, unsigned long addr, unsigned long end, unsigned int type)