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 <haojianhua1@xiaomi.com>
(cherry picked from commit 88cb3505ebf4d9eb1dd0d3c63403727eb4b239bd)
This commit is contained in:
jianhua hao
2025-05-06 10:42:25 +08:00
committed by Suren Baghdasaryan
parent f0e8c43c00
commit c5defcb638
4 changed files with 13 additions and 0 deletions

View File

@@ -5,6 +5,9 @@
extern unsigned long generic_max_swapfile_size(void); extern unsigned long generic_max_swapfile_size(void);
unsigned long arch_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). */ /* Maximum swapfile size supported for the arch (not inclusive). */
extern unsigned long swapfile_maximum_size; extern unsigned long swapfile_maximum_size;
/* Whether swap migration entry supports storing A/D bits for the arch */ /* Whether swap migration entry supports storing A/D bits for the arch */

View File

@@ -305,6 +305,7 @@ nomap:
rcu_read_unlock(); rcu_read_unlock();
return NULL; return NULL;
} }
EXPORT_SYMBOL_GPL(__pte_offset_map);
pte_t *pte_offset_map_nolock(struct mm_struct *mm, pmd_t *pmd, pte_t *pte_offset_map_nolock(struct mm_struct *mm, pmd_t *pmd,
unsigned long addr, spinlock_t **ptlp) unsigned long addr, spinlock_t **ptlp)

View File

@@ -549,6 +549,8 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
return retpage; return retpage;
} }
EXPORT_SYMBOL_GPL(read_swap_cache_async);
static unsigned int __swapin_nr_pages(unsigned long prev_offset, static unsigned int __swapin_nr_pages(unsigned long prev_offset,
unsigned long offset, unsigned long offset,
int hits, int hits,

View File

@@ -2204,6 +2204,13 @@ out:
return ret; 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, static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
unsigned long addr, unsigned long end, unsigned long addr, unsigned long end,
unsigned int type) unsigned int type)