Unverified Commit 3d3d8be5 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!11342 large folios swap-in: handle refault cases first

Merge Pull Request from: @ci-robot 
 
PR sync from: Liu Shixin <liushixin2@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/ZUJPTGYNFUHSSJX42V7EG2LEWMYCB5CW/ 
Barry Song (7):
  mm: remove the implementation of swap_free() and always use
    swap_free_nr()
  mm: introduce pte_move_swp_offset() helper which can move offset
    bidirectionally
  mm: introduce arch_do_swap_page_nr() which allows restore metadata for
    nr pages
  mm: swap: reuse exclusive folio directly instead of wp page faults
  mm: extend rmap flags arguments for folio_add_new_anon_rmap
  mm: use folio_add_new_anon_rmap() if folio_test_anon(folio)==false
  mm: remove folio_test_anon(folio)==false path in
    __folio_add_anon_rmap()

Chuanhua Han (3):
  mm: swap: introduce swap_free_nr() for batched swap_free()
  mm: swap: make should_try_to_free_swap() support large-folio
  mm: swap: entirely map large folios found in swapcache

Kefeng Wang (2):
  mm: ksm: use more folio api in ksm_might_need_to_copy()
  mm: memory: use a folio in validate_page_before_insert()

Liu Shixin (1):
  mm: userswap: page_add_new_anon_rmap() -> folio_add_new_anon_rmap()

Matthew Wilcox (Oracle) (8):
  mm: convert ksm_might_need_to_copy() to work on folios
  mm: convert unuse_pte() to use a folio throughout
  mm: remove some calls to page_add_new_anon_rmap()
  mm: remove stale example from comment
  mm: remove references to page_add_new_anon_rmap in comments
  mm: convert migrate_vma_insert_page() to use a folio
  mm: convert collapse_huge_page() to use a folio
  mm: remove page_add_new_anon_rmap and
    lru_cache_add_inactive_or_unevictable

Yosry Ahmed (1):
  mm: rmap: abstract updating per-node and per-memcg stats


-- 
2.25.1
 
https://gitee.com/openeuler/kernel/issues/IAJ5MT 
 
Link:https://gitee.com/openeuler/kernel/pulls/11342

 

Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 314e8b00 a0839471
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -76,8 +76,8 @@ static inline void ksm_exit(struct mm_struct *mm)
 * We'd like to make this conditional on vma->vm_flags & VM_MERGEABLE,
 * but what if the vma was unmerged while the page was swapped out?
 */
struct page *ksm_might_need_to_copy(struct page *page,
			struct vm_area_struct *vma, unsigned long address);
struct folio *ksm_might_need_to_copy(struct folio *folio,
			struct vm_area_struct *vma, unsigned long addr);

void rmap_walk_ksm(struct folio *folio, struct rmap_walk_control *rwc);
void folio_migrate_ksm(struct folio *newfolio, struct folio *folio);
@@ -127,10 +127,10 @@ static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
	return 0;
}

static inline struct page *ksm_might_need_to_copy(struct page *page,
			struct vm_area_struct *vma, unsigned long address)
static inline struct folio *ksm_might_need_to_copy(struct folio *folio,
			struct vm_area_struct *vma, unsigned long addr)
{
	return page;
	return folio;
}

static inline void rmap_walk_ksm(struct folio *folio,
+20 −6
Original line number Diff line number Diff line
@@ -1075,6 +1075,15 @@ static inline int pgd_same(pgd_t pgd_a, pgd_t pgd_b)
})

#ifndef __HAVE_ARCH_DO_SWAP_PAGE
static inline void arch_do_swap_page_nr(struct mm_struct *mm,
				     struct vm_area_struct *vma,
				     unsigned long addr,
				     pte_t pte, pte_t oldpte,
				     int nr)
{

}
#else
/*
 * Some architectures support metadata associated with a page. When a
 * page is being swapped out, this metadata must be saved so it can be
@@ -1083,12 +1092,17 @@ static inline int pgd_same(pgd_t pgd_a, pgd_t pgd_b)
 * page as metadata for the page. arch_do_swap_page() can restore this
 * metadata when a page is swapped back in.
 */
static inline void arch_do_swap_page(struct mm_struct *mm,
static inline void arch_do_swap_page_nr(struct mm_struct *mm,
					struct vm_area_struct *vma,
					unsigned long addr,
				     pte_t pte, pte_t oldpte)
					pte_t pte, pte_t oldpte,
					int nr)
{

	for (int i = 0; i < nr; i++) {
		arch_do_swap_page(vma->vm_mm, vma, addr + i * PAGE_SIZE,
				pte_advance_pfn(pte, i),
				pte_advance_pfn(oldpte, i));
	}
}
#endif

+1 −3
Original line number Diff line number Diff line
@@ -235,10 +235,8 @@ void folio_add_anon_rmap_ptes(struct folio *, struct page *, int nr_pages,
	folio_add_anon_rmap_ptes(folio, page, 1, vma, address, flags)
void folio_add_anon_rmap_pmd(struct folio *, struct page *,
		struct vm_area_struct *, unsigned long address, rmap_t flags);
void page_add_new_anon_rmap(struct page *, struct vm_area_struct *,
		unsigned long address);
void folio_add_new_anon_rmap(struct folio *, struct vm_area_struct *,
		unsigned long address);
		unsigned long address, rmap_t flags);
void folio_add_file_rmap_ptes(struct folio *, struct page *, int nr_pages,
		struct vm_area_struct *);
#define folio_add_file_rmap_pte(folio, page, vma) \
+7 −5
Original line number Diff line number Diff line
@@ -424,9 +424,6 @@ void folio_deactivate(struct folio *folio);
void folio_mark_lazyfree(struct folio *folio);
extern void swap_setup(void);

extern void lru_cache_add_inactive_or_unevictable(struct page *page,
						struct vm_area_struct *vma);

/* linux/mm/vmscan.c */
extern unsigned long zone_reclaimable_pages(struct zone *zone);
extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
@@ -513,7 +510,7 @@ extern int add_swap_count_continuation(swp_entry_t, gfp_t);
extern void swap_shmem_alloc(swp_entry_t);
extern int swap_duplicate(swp_entry_t);
extern int swapcache_prepare(swp_entry_t);
extern void swap_free(swp_entry_t);
extern void swap_free_nr(swp_entry_t entry, int nr_pages);
extern void swapcache_free_entries(swp_entry_t *entries, int n);
extern void free_swap_and_cache_nr(swp_entry_t entry, int nr);
int swap_type_of(dev_t device, sector_t offset);
@@ -600,7 +597,7 @@ static inline int swapcache_prepare(swp_entry_t swp)
	return 0;
}

static inline void swap_free(swp_entry_t swp)
static inline void swap_free_nr(swp_entry_t entry, int nr_pages)
{
}

@@ -648,6 +645,11 @@ static inline void free_swap_and_cache(swp_entry_t entry)
	free_swap_and_cache_nr(entry, 1);
}

static inline void swap_free(swp_entry_t entry)
{
	swap_free_nr(entry, 1);
}

#ifdef CONFIG_MEMCG
static inline int mem_cgroup_swappiness(struct mem_cgroup *memcg)
{
+1 −1
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr,
	if (new_page) {
		folio_get(new_folio);
		add_reliable_folio_counter(new_folio, mm, folio_nr_pages(new_folio));
		page_add_new_anon_rmap(new_page, vma, addr);
		folio_add_new_anon_rmap(new_folio, vma, addr, RMAP_EXCLUSIVE);
		folio_add_lru_vma(new_folio, vma);
	} else
		/* no new page, just dec_mm_counter for old_page */
Loading