Unverified Commit 07ed0130 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!7764 v2 mm: Some bugfix and optimization

Merge Pull Request from: @ci-robot 
 
PR sync from: Liu Shixin <liushixin2@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/O5BEHJ3I4HLYFTM5OTC7PQUMI6QRZ72I/ 
Patch [1-21] is series "Rearrange batched folio freeing" and three bugfix.
Patch [22-26] is series "Clean up __folio_put()".
Patch [27] add trace of alloc_contig_migrate_range.
Patch [28-30] is three bugfix about hugetlb.
Patch [31] is an performance optimization of pcp draining.
Patch [32] is a minor improve of _deferred_list which benefit from debug.
  This patch is from series "Various significant MM patches". Other patches
  are not related to this patch, so don't backport together.
  Patch "mm: Free up PG_slab" may also benefit for us, but have compile
  problem need to fix, so not in this series.
Patch [33-36] is part of series "Improve anon_vma scalability for anon VMAs".
  Patch "mm: Fix some minor per-VMA lock issues in userfaultfd" is not in
  backport because it depends on patch "userfaultfd: use per-vma locks in
  userfaultfd operations"
Patch [37] fix a bug introduced by patch "mm: turn folio_test_hugetlb into
  a PageType" which is from the previous backport.

v1->v2: Add patch [37].

Liu Shixin (1):
  mm/dynamic_pool: clear PG_hugetlb when demote hugepages

Lucas Stach (1):
  mm: page_alloc: control latency caused by zone PCP draining

Matthew Wilcox (Oracle) (30):
  mm: make folios_put() the basis of release_pages()
  mm: convert free_unref_page_list() to use folios
  mm: add free_unref_folios()
  mm: use folios_put() in __folio_batch_release()
  memcg: add mem_cgroup_uncharge_folios()
  mm: remove use of folio list from folios_put()
  mm: use free_unref_folios() in put_pages_list()
  mm: use __page_cache_release() in folios_put()
  mm: handle large folios in free_unref_folios()
  mm: allow non-hugetlb large folios to be batch processed
  mm: free folios in a batch in shrink_folio_list()
  mm: free folios directly in move_folios_to_lru()
  memcg: remove mem_cgroup_uncharge_list()
  mm: remove free_unref_page_list()
  mm: remove lru_to_page()
  mm: convert free_pages_and_swap_cache() to use folios_put()
  mm: use a folio in __collapse_huge_page_copy_succeeded()
  mm: convert free_swap_cache() to take a folio
  mm: remove folio from deferred split list before uncharging it
  mm: fix list corruption in put_pages_list
  mm: increase folio batch size
  mm: free non-hugetlb large folios in a batch
  mm: combine free_the_page() and free_unref_page()
  mm: inline destroy_large_folio() into __folio_put_large()
  mm: combine __folio_put_small, __folio_put_large and __folio_put
  mm: convert free_zone_device_page to free_zone_device_folio
  mm: always initialise folio->_deferred_list
  mm: assert the mmap_lock is held in __anon_vma_prepare()
  mm: delay the check for a NULL anon_vma
  mm: optimise vmf_anon_prepare() for VMAs without an anon_vma

Miaohe Lin (1):
  mm/hugetlb: fix DEBUG_LOCKS_WARN_ON(1) when
    dissolve_free_hugetlb_folio()

Mike Kravetz (2):
  hugetlb: set hugetlb page flag before optimizing vmemmap
  hugetlb: check for hugetlb folio before vmemmap_restore

Richard Chang (1):
  mm: add alloc_contig_migrate_range allocation statistics

Vishal Moola (Oracle) (1):
  mm/memory: change vmf_anon_prepare() to be non-static


-- 
2.25.1
 
https://gitee.com/openeuler/kernel/issues/I9R3AY 
 
Link:https://gitee.com/openeuler/kernel/pulls/7764

 

Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents c542a3e5 3616bd3a
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -829,18 +829,16 @@ static inline void mem_cgroup_uncharge(struct folio *folio)
	__mem_cgroup_uncharge(folio);
}

void __mem_cgroup_uncharge_list(struct list_head *page_list);
static inline void mem_cgroup_uncharge_list(struct list_head *page_list)
void __mem_cgroup_uncharge_folios(struct folio_batch *folios);
static inline void mem_cgroup_uncharge_folios(struct folio_batch *folios)
{
	if (mem_cgroup_disabled())
		return;
	__mem_cgroup_uncharge_list(page_list);
	__mem_cgroup_uncharge_folios(folios);
}

void mem_cgroup_cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages);

void mem_cgroup_replace_folio(struct folio *old, struct folio *new);

void mem_cgroup_migrate(struct folio *old, struct folio *new);

/**
@@ -1421,7 +1419,7 @@ static inline void mem_cgroup_uncharge(struct folio *folio)
{
}

static inline void mem_cgroup_uncharge_list(struct list_head *page_list)
static inline void mem_cgroup_uncharge_folios(struct folio_batch *folios)
{
}

@@ -1829,18 +1827,18 @@ static inline struct lruvec *folio_lruvec_relock_irq(struct folio *folio,
	return folio_lruvec_lock_irq(folio);
}

/* Don't lock again iff page's lruvec locked */
static inline struct lruvec *folio_lruvec_relock_irqsave(struct folio *folio,
		struct lruvec *locked_lruvec, unsigned long *flags)
/* Don't lock again iff folio's lruvec locked */
static inline void folio_lruvec_relock_irqsave(struct folio *folio,
		struct lruvec **lruvecp, unsigned long *flags)
{
	if (locked_lruvec) {
		if (folio_matches_lruvec(folio, locked_lruvec))
			return locked_lruvec;
	if (*lruvecp) {
		if (folio_matches_lruvec(folio, *lruvecp))
			return;

		unlock_page_lruvec_irqrestore(locked_lruvec, *flags);
		unlock_page_lruvec_irqrestore(*lruvecp, *flags);
	}

	return folio_lruvec_lock_irqsave(folio, flags);
	*lruvecp = folio_lruvec_lock_irqsave(folio, flags);
}

#ifdef CONFIG_CGROUP_WRITEBACK
+10 −9
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ struct anon_vma;
struct anon_vma_chain;
struct user_struct;
struct pt_regs;
struct folio_batch;

extern int sysctl_page_lock_unfairness;

@@ -227,7 +228,6 @@ int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *,
/* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */
#define PAGE_ALIGNED(addr)	IS_ALIGNED((unsigned long)(addr), PAGE_SIZE)

#define lru_to_page(head) (list_entry((head)->prev, struct page, lru))
static inline struct folio *lru_to_folio(struct list_head *head)
{
	return list_entry((head)->prev, struct folio, lru);
@@ -1321,8 +1321,6 @@ void folio_copy(struct folio *dst, struct folio *src);

unsigned long nr_free_buffer_pages(void);

void destroy_large_folio(struct folio *folio);

/* Returns the number of bytes in this potentially compound page. */
static inline unsigned long page_size(struct page *page)
{
@@ -1532,6 +1530,8 @@ static inline void folio_put_refs(struct folio *folio, int refs)
		__folio_put(folio);
}

void folios_put_refs(struct folio_batch *folios, unsigned int *refs);

/*
 * union release_pages_arg - an array of pages or folios
 *
@@ -1554,18 +1554,19 @@ void release_pages(release_pages_arg, int nr);
/**
 * folios_put - Decrement the reference count on an array of folios.
 * @folios: The folios.
 * @nr: How many folios there are.
 *
 * Like folio_put(), but for an array of folios.  This is more efficient
 * than writing the loop yourself as it will optimise the locks which
 * need to be taken if the folios are freed.
 * Like folio_put(), but for a batch of folios.  This is more efficient
 * than writing the loop yourself as it will optimise the locks which need
 * to be taken if the folios are freed.  The folios batch is returned
 * empty and ready to be reused for another batch; there is no need to
 * reinitialise it.
 *
 * Context: May be called in process or interrupt context, but not in NMI
 * context.  May be called while holding a spinlock.
 */
static inline void folios_put(struct folio **folios, unsigned int nr)
static inline void folios_put(struct folio_batch *folios)
{
	release_pages(folios, nr);
	folios_put_refs(folios, NULL);
}

static inline void put_page(struct page *page)
+2 −2
Original line number Diff line number Diff line
@@ -11,8 +11,8 @@

#include <linux/types.h>

/* 15 pointers + header align the folio_batch structure to a power of two */
#define PAGEVEC_SIZE	15
/* 31 pointers + header align the folio_batch structure to a power of two */
#define PAGEVEC_SIZE	31

struct folio;

+4 −4
Original line number Diff line number Diff line
@@ -482,9 +482,9 @@ static inline unsigned long total_swapcache_pages(void)
	return global_node_page_state(NR_SWAPCACHE);
}

extern void free_swap_cache(struct page *page);
extern void free_page_and_swap_cache(struct page *);
extern void free_pages_and_swap_cache(struct encoded_page **, int);
void free_swap_cache(struct folio *folio);
void free_page_and_swap_cache(struct page *);
void free_pages_and_swap_cache(struct encoded_page **, int);
/* linux/mm/swapfile.c */
extern atomic_long_t nr_swap_pages;
extern long total_swap_pages;
@@ -577,7 +577,7 @@ static inline void free_swap_and_cache_nr(swp_entry_t entry, int nr)
{
}

static inline void free_swap_cache(struct page *page)
static inline void free_swap_cache(struct folio *folio)
{
}

+38 −0
Original line number Diff line number Diff line
@@ -304,6 +304,44 @@ TRACE_EVENT(mm_page_alloc_extfrag,
		__entry->change_ownership)
);

TRACE_EVENT(mm_alloc_contig_migrate_range_info,

	TP_PROTO(unsigned long start,
		 unsigned long end,
		 unsigned long nr_migrated,
		 unsigned long nr_reclaimed,
		 unsigned long nr_mapped,
		 int migratetype),

	TP_ARGS(start, end, nr_migrated, nr_reclaimed, nr_mapped, migratetype),

	TP_STRUCT__entry(
		__field(unsigned long, start)
		__field(unsigned long, end)
		__field(unsigned long, nr_migrated)
		__field(unsigned long, nr_reclaimed)
		__field(unsigned long, nr_mapped)
		__field(int, migratetype)
	),

	TP_fast_assign(
		__entry->start = start;
		__entry->end = end;
		__entry->nr_migrated = nr_migrated;
		__entry->nr_reclaimed = nr_reclaimed;
		__entry->nr_mapped = nr_mapped;
		__entry->migratetype = migratetype;
	),

	TP_printk("start=0x%lx end=0x%lx migratetype=%d nr_migrated=%lu nr_reclaimed=%lu nr_mapped=%lu",
		  __entry->start,
		  __entry->end,
		  __entry->migratetype,
		  __entry->nr_migrated,
		  __entry->nr_reclaimed,
		  __entry->nr_mapped)
);

/*
 * Required for uniquely and securely identifying mm in rss_stat tracepoint.
 */
Loading