* [PATCH v2 00/16] A few cleanup patches for mm
@ 2022-09-16 7:22 Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 01/16] mm/page_alloc: ensure kswapd doesn't accidentally go to sleep Miaohe Lin
` (15 more replies)
0 siblings, 16 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
Hi everyone,
This series contains a few cleanup patches to remove the obsolete
comments and functions, use helper macro to improve readability and
so on. More details can be found in the respective changelogs.
Thanks!
---
v2:
Thanks David, Oscar, Anshuman and Matthew for review and comment!
Collect Reviewed-by and Acked-by tag.
3/6: Further remove NR_PCP_ORDER_WIDTH per Matthew.
8/16: Tweak changelog to better explain the issue per Oscar.
12/16: Adjust if block to match comment per David.
---
Miaohe Lin (16):
mm/page_alloc: ensure kswapd doesn't accidentally go to sleep
mm/page_alloc: make zone_pcp_update() static
mm: remove obsolete macro NR_PCP_ORDER_MASK and NR_PCP_ORDER_WIDTH
mm/page_alloc: remove obsolete comment in zone_statistics()
mm/page_alloc: add __init annotations to
init_mem_debugging_and_hardening()
mm/page_alloc: fix freeing static percpu memory
mm: remove obsolete pgdat_is_empty()
mm/page_alloc: add missing is_migrate_isolate() check in
set_page_guard()
mm/page_alloc: use local variable zone_idx directly
mm, memory_hotplug: remove obsolete generic_free_nodedata()
mm/page_alloc: make boot_nodestats static
mm/page_alloc: use helper macro SZ_1{K,M}
mm/page_alloc: init local variable buddy_pfn
mm/page_alloc: use costly_order in WARN_ON_ONCE_GFP()
mm/page_alloc: remove obsolete gfpflags_normal_context()
mm/page_alloc: fix obsolete comment in deferred_pfn_valid()
include/linux/gfp.h | 23 -------------
include/linux/memory_hotplug.h | 8 -----
include/linux/mm.h | 2 +-
include/linux/mmzone.h | 12 -------
mm/internal.h | 3 --
mm/page_alloc.c | 63 ++++++++++++++++------------------
6 files changed, 31 insertions(+), 80 deletions(-)
--
2.23.0
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 01/16] mm/page_alloc: ensure kswapd doesn't accidentally go to sleep
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 02/16] mm/page_alloc: make zone_pcp_update() static Miaohe Lin
` (14 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
If ALLOC_KSWAPD is set, wake_all_kswapds() will be called to ensure
kswapd doesn't accidentally go to sleep. But when reserve_flags is
set, alloc_flags will be overwritten and ALLOC_KSWAPD is thus lost.
Preserve the ALLOC_KSWAPD flag in alloc_flags to ensure kswapd won't
go to sleep accidentally.
Fixes: 0a79cdad5eb2 ("mm: use alloc_flags to record if kswapd can wake")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
mm/page_alloc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ef3f51c9815d..35e18514215a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5148,7 +5148,8 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
reserve_flags = __gfp_pfmemalloc_flags(gfp_mask);
if (reserve_flags)
- alloc_flags = gfp_to_alloc_flags_cma(gfp_mask, reserve_flags);
+ alloc_flags = gfp_to_alloc_flags_cma(gfp_mask, reserve_flags) |
+ (alloc_flags & ALLOC_KSWAPD);
/*
* Reset the nodemask and zonelist iterators if memory policies can be
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 02/16] mm/page_alloc: make zone_pcp_update() static
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 01/16] mm/page_alloc: ensure kswapd doesn't accidentally go to sleep Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 03/16] mm: remove obsolete macro NR_PCP_ORDER_MASK and NR_PCP_ORDER_WIDTH Miaohe Lin
` (13 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
Since commit b92ca18e8ca5 ("mm/page_alloc: disassociate the pcp->high
from pcp->batch"), zone_pcp_update() is only used in mm/page_alloc.c.
Move zone_pcp_update() up to avoid forward declaration and then make
it static. No functional change intended.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
mm/internal.h | 1 -
mm/page_alloc.c | 22 +++++++++++-----------
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/mm/internal.h b/mm/internal.h
index 883b09f02404..94d8a976c2e2 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -367,7 +367,6 @@ extern int user_min_free_kbytes;
extern void free_unref_page(struct page *page, unsigned int order);
extern void free_unref_page_list(struct list_head *list);
-extern void zone_pcp_update(struct zone *zone, int cpu_online);
extern void zone_pcp_reset(struct zone *zone);
extern void zone_pcp_disable(struct zone *zone);
extern void zone_pcp_enable(struct zone *zone);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 35e18514215a..04559870ed12 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7234,6 +7234,17 @@ void __meminit setup_zone_pageset(struct zone *zone)
zone_set_pageset_high_and_batch(zone, 0);
}
+/*
+ * The zone indicated has a new number of managed_pages; batch sizes and percpu
+ * page high values need to be recalculated.
+ */
+static void zone_pcp_update(struct zone *zone, int cpu_online)
+{
+ mutex_lock(&pcp_batch_high_lock);
+ zone_set_pageset_high_and_batch(zone, cpu_online);
+ mutex_unlock(&pcp_batch_high_lock);
+}
+
/*
* Allocate per cpu pagesets and initialize them.
* Before this call only boot pagesets were available.
@@ -9465,17 +9476,6 @@ void free_contig_range(unsigned long pfn, unsigned long nr_pages)
}
EXPORT_SYMBOL(free_contig_range);
-/*
- * The zone indicated has a new number of managed_pages; batch sizes and percpu
- * page high values need to be recalculated.
- */
-void zone_pcp_update(struct zone *zone, int cpu_online)
-{
- mutex_lock(&pcp_batch_high_lock);
- zone_set_pageset_high_and_batch(zone, cpu_online);
- mutex_unlock(&pcp_batch_high_lock);
-}
-
/*
* Effectively disable pcplists for the zone by setting the high limit to 0
* and draining all cpus. A concurrent page freeing on another CPU that's about
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 03/16] mm: remove obsolete macro NR_PCP_ORDER_MASK and NR_PCP_ORDER_WIDTH
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 01/16] mm/page_alloc: ensure kswapd doesn't accidentally go to sleep Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 02/16] mm/page_alloc: make zone_pcp_update() static Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 04/16] mm/page_alloc: remove obsolete comment in zone_statistics() Miaohe Lin
` (12 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
Since commit 8b10b465d0e1 ("mm/page_alloc: free pages in a single pass
during bulk free"), they're not used anymore. Remove them.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
include/linux/mmzone.h | 7 -------
mm/page_alloc.c | 1 -
2 files changed, 8 deletions(-)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index d907a29cc429..93f9aa346724 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -564,13 +564,6 @@ enum zone_watermarks {
#define NR_LOWORDER_PCP_LISTS (MIGRATE_PCPTYPES * (PAGE_ALLOC_COSTLY_ORDER + 1))
#define NR_PCP_LISTS (NR_LOWORDER_PCP_LISTS + NR_PCP_THP)
-/*
- * Shift to encode migratetype and order in the same integer, with order
- * in the least significant bits.
- */
-#define NR_PCP_ORDER_WIDTH 8
-#define NR_PCP_ORDER_MASK ((1<<NR_PCP_ORDER_WIDTH) - 1)
-
#define min_wmark_pages(z) (z->_watermark[WMARK_MIN] + z->watermark_boost)
#define low_wmark_pages(z) (z->_watermark[WMARK_LOW] + z->watermark_boost)
#define high_wmark_pages(z) (z->_watermark[WMARK_HIGH] + z->watermark_boost)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 04559870ed12..bb2906829599 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1584,7 +1584,6 @@ static void free_pcppages_bulk(struct zone *zone, int count,
order = pindex_to_order(pindex);
nr_pages = 1 << order;
- BUILD_BUG_ON(MAX_ORDER >= (1<<NR_PCP_ORDER_WIDTH));
do {
int mt;
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 04/16] mm/page_alloc: remove obsolete comment in zone_statistics()
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
` (2 preceding siblings ...)
2022-09-16 7:22 ` [PATCH v2 03/16] mm: remove obsolete macro NR_PCP_ORDER_MASK and NR_PCP_ORDER_WIDTH Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 05/16] mm/page_alloc: add __init annotations to init_mem_debugging_and_hardening() Miaohe Lin
` (11 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
Since commit 43c95bcc51e4 ("mm/page_alloc: reduce duration that IRQs
are disabled for VM counters"), zone_statistics() is not called with
interrupts disabled. Update the corresponding comment.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
mm/page_alloc.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index bb2906829599..762619463bb5 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3671,8 +3671,6 @@ void __putback_isolated_page(struct page *page, unsigned int order, int mt)
/*
* Update NUMA hit/miss statistics
- *
- * Must be called with interrupts disabled.
*/
static inline void zone_statistics(struct zone *preferred_zone, struct zone *z,
long nr_account)
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 05/16] mm/page_alloc: add __init annotations to init_mem_debugging_and_hardening()
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
` (3 preceding siblings ...)
2022-09-16 7:22 ` [PATCH v2 04/16] mm/page_alloc: remove obsolete comment in zone_statistics() Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 06/16] mm/page_alloc: fix freeing static percpu memory Miaohe Lin
` (10 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
It's only called by mm_init(). Add __init annotations to it.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
include/linux/mm.h | 2 +-
mm/page_alloc.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 364bcadb4d20..c2277f5aba9e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3093,7 +3093,7 @@ extern int apply_to_existing_page_range(struct mm_struct *mm,
unsigned long address, unsigned long size,
pte_fn_t fn, void *data);
-extern void init_mem_debugging_and_hardening(void);
+extern void __init init_mem_debugging_and_hardening(void);
#ifdef CONFIG_PAGE_POISONING
extern void __kernel_poison_pages(struct page *page, int numpages);
extern void __kernel_unpoison_pages(struct page *page, int numpages);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 762619463bb5..27ef763bb59f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -903,7 +903,7 @@ static inline void clear_page_guard(struct zone *zone, struct page *page,
* order of appearance. So we need to first gather the full picture of what was
* enabled, and then make decisions.
*/
-void init_mem_debugging_and_hardening(void)
+void __init init_mem_debugging_and_hardening(void)
{
bool page_poisoning_requested = false;
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 06/16] mm/page_alloc: fix freeing static percpu memory
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
` (4 preceding siblings ...)
2022-09-16 7:22 ` [PATCH v2 05/16] mm/page_alloc: add __init annotations to init_mem_debugging_and_hardening() Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 07/16] mm: remove obsolete pgdat_is_empty() Miaohe Lin
` (9 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
The size of struct per_cpu_zonestat can be 0 on !SMP && !NUMA. In that
case, zone->per_cpu_zonestats will always equal to boot_zonestats. But
in zone_pcp_reset(), zone->per_cpu_zonestats is freed via free_percpu()
directly without checking against boot_zonestats first. boot_zonestats
will be released by free_percpu() unexpectedly.
Fixes: 28f836b6777b ("mm/page_alloc: split per cpu page lists and zone stats")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
mm/page_alloc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 27ef763bb59f..cad235770948 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -9505,9 +9505,11 @@ void zone_pcp_reset(struct zone *zone)
drain_zonestat(zone, pzstats);
}
free_percpu(zone->per_cpu_pageset);
- free_percpu(zone->per_cpu_zonestats);
zone->per_cpu_pageset = &boot_pageset;
- zone->per_cpu_zonestats = &boot_zonestats;
+ if (zone->per_cpu_zonestats != &boot_zonestats) {
+ free_percpu(zone->per_cpu_zonestats);
+ zone->per_cpu_zonestats = &boot_zonestats;
+ }
}
}
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 07/16] mm: remove obsolete pgdat_is_empty()
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
` (5 preceding siblings ...)
2022-09-16 7:22 ` [PATCH v2 06/16] mm/page_alloc: fix freeing static percpu memory Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 08/16] mm/page_alloc: add missing is_migrate_isolate() check in set_page_guard() Miaohe Lin
` (8 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
There's no caller. Remove it.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
include/linux/mmzone.h | 5 -----
1 file changed, 5 deletions(-)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 93f9aa346724..2b3f273faf68 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1241,11 +1241,6 @@ static inline unsigned long pgdat_end_pfn(pg_data_t *pgdat)
return pgdat->node_start_pfn + pgdat->node_spanned_pages;
}
-static inline bool pgdat_is_empty(pg_data_t *pgdat)
-{
- return !pgdat->node_start_pfn && !pgdat->node_spanned_pages;
-}
-
#include <linux/memory_hotplug.h>
void build_all_zonelists(pg_data_t *pgdat);
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 08/16] mm/page_alloc: add missing is_migrate_isolate() check in set_page_guard()
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
` (6 preceding siblings ...)
2022-09-16 7:22 ` [PATCH v2 07/16] mm: remove obsolete pgdat_is_empty() Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-19 11:28 ` David Hildenbrand
2022-09-16 7:22 ` [PATCH v2 09/16] mm/page_alloc: use local variable zone_idx directly Miaohe Lin
` (7 subsequent siblings)
15 siblings, 1 reply; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
In MIGRATE_ISOLATE case, zone freepage state shouldn't be modified as
caller will take care of it. Add missing is_migrate_isolate() here to
avoid possible unbalanced freepage state. This would happen if someone
isolates the block, and then we face an MCE failure/soft-offline on a
page within that block. __mod_zone_freepage_state() will be triggered
via below call trace which already had been triggered back when block
was isolated:
take_page_off_buddy
break_down_buddy_pages
set_page_guard
Fixes: 06be6ff3d2ec ("mm,hwpoison: rework soft offline for free pages")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
mm/page_alloc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index cad235770948..8fcc905ef317 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -873,7 +873,8 @@ static inline bool set_page_guard(struct zone *zone, struct page *page,
INIT_LIST_HEAD(&page->buddy_list);
set_page_private(page, order);
/* Guard pages are not available for any usage */
- __mod_zone_freepage_state(zone, -(1 << order), migratetype);
+ if (!is_migrate_isolate(migratetype))
+ __mod_zone_freepage_state(zone, -(1 << order), migratetype);
return true;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 09/16] mm/page_alloc: use local variable zone_idx directly
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
` (7 preceding siblings ...)
2022-09-16 7:22 ` [PATCH v2 08/16] mm/page_alloc: add missing is_migrate_isolate() check in set_page_guard() Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 10/16] mm, memory_hotplug: remove obsolete generic_free_nodedata() Miaohe Lin
` (6 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
Use local variable zone_idx directly since it holds the exact value of
zone_idx(). No functional change intended.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
mm/page_alloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 8fcc905ef317..83b2cb93d6fd 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6873,7 +6873,7 @@ void __ref memmap_init_zone_device(struct zone *zone,
unsigned long start = jiffies;
int nid = pgdat->node_id;
- if (WARN_ON_ONCE(!pgmap || zone_idx(zone) != ZONE_DEVICE))
+ if (WARN_ON_ONCE(!pgmap || zone_idx != ZONE_DEVICE))
return;
/*
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 10/16] mm, memory_hotplug: remove obsolete generic_free_nodedata()
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
` (8 preceding siblings ...)
2022-09-16 7:22 ` [PATCH v2 09/16] mm/page_alloc: use local variable zone_idx directly Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 11/16] mm/page_alloc: make boot_nodestats static Miaohe Lin
` (5 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
Commit 390511e1476e ("mm, memory_hotplug: drop arch_free_nodedata")
drops the last caller of generic_free_nodedata(). Remove it too.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
include/linux/memory_hotplug.h | 8 --------
1 file changed, 8 deletions(-)
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 51052969dbfe..9fcbf5706595 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -43,11 +43,6 @@ extern void arch_refresh_nodedata(int nid, pg_data_t *pgdat);
({ \
memblock_alloc(sizeof(*pgdat), SMP_CACHE_BYTES); \
})
-/*
- * This definition is just for error path in node hotadd.
- * For node hotremove, we have to replace this.
- */
-#define generic_free_nodedata(pgdat) kfree(pgdat)
extern pg_data_t *node_data[];
static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat)
@@ -63,9 +58,6 @@ static inline pg_data_t *generic_alloc_nodedata(int nid)
BUG();
return NULL;
}
-static inline void generic_free_nodedata(pg_data_t *pgdat)
-{
-}
static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat)
{
}
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 11/16] mm/page_alloc: make boot_nodestats static
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
` (9 preceding siblings ...)
2022-09-16 7:22 ` [PATCH v2 10/16] mm, memory_hotplug: remove obsolete generic_free_nodedata() Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 12/16] mm/page_alloc: use helper macro SZ_1{K,M} Miaohe Lin
` (4 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
It's only used in mm/page_alloc.c now. Make it static.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
mm/internal.h | 2 --
mm/page_alloc.c | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/mm/internal.h b/mm/internal.h
index 94d8a976c2e2..b3002e03c28f 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -836,8 +836,6 @@ int migrate_device_coherent_page(struct page *page);
*/
struct folio *try_grab_folio(struct page *page, int refs, unsigned int flags);
-DECLARE_PER_CPU(struct per_cpu_nodestat, boot_nodestats);
-
extern bool mirrored_kernelcore;
static inline bool vma_soft_dirty_enabled(struct vm_area_struct *vma)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 83b2cb93d6fd..6bdc98c7019f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6571,7 +6571,7 @@ static void per_cpu_pages_init(struct per_cpu_pages *pcp, struct per_cpu_zonesta
#define BOOT_PAGESET_BATCH 1
static DEFINE_PER_CPU(struct per_cpu_pages, boot_pageset);
static DEFINE_PER_CPU(struct per_cpu_zonestat, boot_zonestats);
-DEFINE_PER_CPU(struct per_cpu_nodestat, boot_nodestats);
+static DEFINE_PER_CPU(struct per_cpu_nodestat, boot_nodestats);
static void __build_all_zonelists(void *data)
{
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 12/16] mm/page_alloc: use helper macro SZ_1{K,M}
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
` (10 preceding siblings ...)
2022-09-16 7:22 ` [PATCH v2 11/16] mm/page_alloc: make boot_nodestats static Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-19 11:30 ` David Hildenbrand
2022-09-16 7:22 ` [PATCH v2 13/16] mm/page_alloc: init local variable buddy_pfn Miaohe Lin
` (3 subsequent siblings)
15 siblings, 1 reply; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
Use helper macro SZ_1K and SZ_1M to do the size conversion. Minor
readability improvement.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
mm/page_alloc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6bdc98c7019f..67ec8a2e1db2 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7048,7 +7048,7 @@ static int zone_batchsize(struct zone *zone)
* size is striking a balance between allocation latency
* and zone lock contention.
*/
- batch = min(zone_managed_pages(zone) >> 10, (1024 * 1024) / PAGE_SIZE);
+ batch = min(zone_managed_pages(zone) >> 10, SZ_1M / PAGE_SIZE);
batch /= 4; /* We effectively *= 4 below */
if (batch < 1)
batch = 1;
@@ -8523,8 +8523,8 @@ void __init mem_init_print_info(void)
#endif
")\n",
K(nr_free_pages()), K(physpages),
- codesize >> 10, datasize >> 10, rosize >> 10,
- (init_data_size + init_code_size) >> 10, bss_size >> 10,
+ codesize / SZ_1K, datasize / SZ_1K, rosize / SZ_1K,
+ (init_data_size + init_code_size) / SZ_1K, bss_size / SZ_1K,
K(physpages - totalram_pages() - totalcma_pages),
K(totalcma_pages)
#ifdef CONFIG_HIGHMEM
@@ -9049,8 +9049,8 @@ void *__init alloc_large_system_hash(const char *tablename,
numentries -= arch_reserved_kernel_pages();
/* It isn't necessary when PAGE_SIZE >= 1MB */
- if (PAGE_SHIFT < 20)
- numentries = round_up(numentries, (1<<20)/PAGE_SIZE);
+ if (PAGE_SIZE < SZ_1M)
+ numentries = round_up(numentries, SZ_1M / PAGE_SIZE);
#if __BITS_PER_LONG > 32
if (!high_limit) {
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 13/16] mm/page_alloc: init local variable buddy_pfn
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
` (11 preceding siblings ...)
2022-09-16 7:22 ` [PATCH v2 12/16] mm/page_alloc: use helper macro SZ_1{K,M} Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 14/16] mm/page_alloc: use costly_order in WARN_ON_ONCE_GFP() Miaohe Lin
` (2 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
The local variable buddy_pfn could be passed to buddy_merge_likely()
without initialization if the passed in order is MAX_ORDER - 1. This
looks buggy but buddy_pfn won't be used in this case as there's a
order >= MAX_ORDER - 2 check. Init buddy_pfn to 0 anyway to avoid
possible future misuse.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
mm/page_alloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 67ec8a2e1db2..652b3d766003 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1113,7 +1113,7 @@ static inline void __free_one_page(struct page *page,
int migratetype, fpi_t fpi_flags)
{
struct capture_control *capc = task_capc(zone);
- unsigned long buddy_pfn;
+ unsigned long buddy_pfn = 0;
unsigned long combined_pfn;
struct page *buddy;
bool to_tail;
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 14/16] mm/page_alloc: use costly_order in WARN_ON_ONCE_GFP()
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
` (12 preceding siblings ...)
2022-09-16 7:22 ` [PATCH v2 13/16] mm/page_alloc: init local variable buddy_pfn Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 15/16] mm/page_alloc: remove obsolete gfpflags_normal_context() Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 16/16] mm/page_alloc: fix obsolete comment in deferred_pfn_valid() Miaohe Lin
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
There's no need to check whether order > PAGE_ALLOC_COSTLY_ORDER again.
Minor readability improvement.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
mm/page_alloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 652b3d766003..3d2ad5c197d5 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5272,7 +5272,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
* so that we can identify them and convert them to something
* else.
*/
- WARN_ON_ONCE_GFP(order > PAGE_ALLOC_COSTLY_ORDER, gfp_mask);
+ WARN_ON_ONCE_GFP(costly_order, gfp_mask);
/*
* Help non-failing allocations by giving them access to memory
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 15/16] mm/page_alloc: remove obsolete gfpflags_normal_context()
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
` (13 preceding siblings ...)
2022-09-16 7:22 ` [PATCH v2 14/16] mm/page_alloc: use costly_order in WARN_ON_ONCE_GFP() Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 16/16] mm/page_alloc: fix obsolete comment in deferred_pfn_valid() Miaohe Lin
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
Since commit dacb5d8875cc ("tcp: fix page frag corruption on page
fault"), there's no caller of gfpflags_normal_context(). Remove it
as this helper is strictly tied to the sk page frag usage and there
won't be other user in the future.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
include/linux/gfp.h | 23 -----------------------
1 file changed, 23 deletions(-)
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index ea6cb9399152..ef4aea3b356e 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -36,29 +36,6 @@ static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
return !!(gfp_flags & __GFP_DIRECT_RECLAIM);
}
-/**
- * gfpflags_normal_context - is gfp_flags a normal sleepable context?
- * @gfp_flags: gfp_flags to test
- *
- * Test whether @gfp_flags indicates that the allocation is from the
- * %current context and allowed to sleep.
- *
- * An allocation being allowed to block doesn't mean it owns the %current
- * context. When direct reclaim path tries to allocate memory, the
- * allocation context is nested inside whatever %current was doing at the
- * time of the original allocation. The nested allocation may be allowed
- * to block but modifying anything %current owns can corrupt the outer
- * context's expectations.
- *
- * %true result from this function indicates that the allocation context
- * can sleep and use anything that's associated with %current.
- */
-static inline bool gfpflags_normal_context(const gfp_t gfp_flags)
-{
- return (gfp_flags & (__GFP_DIRECT_RECLAIM | __GFP_MEMALLOC)) ==
- __GFP_DIRECT_RECLAIM;
-}
-
#ifdef CONFIG_HIGHMEM
#define OPT_ZONE_HIGHMEM ZONE_HIGHMEM
#else
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 16/16] mm/page_alloc: fix obsolete comment in deferred_pfn_valid()
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
` (14 preceding siblings ...)
2022-09-16 7:22 ` [PATCH v2 15/16] mm/page_alloc: remove obsolete gfpflags_normal_context() Miaohe Lin
@ 2022-09-16 7:22 ` Miaohe Lin
15 siblings, 0 replies; 19+ messages in thread
From: Miaohe Lin @ 2022-09-16 7:22 UTC (permalink / raw)
To: akpm, david, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel, linmiaohe
There are no architectures that can have holes in the memory map within
a pageblock since commit 859a85ddf90e ("mm: remove pfn_valid_within()
and CONFIG_HOLES_IN_ZONE"). Update the corresponding comment.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
---
mm/page_alloc.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 3d2ad5c197d5..d7b20bf09c1c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1929,11 +1929,7 @@ static inline void __init pgdat_init_report_one_done(void)
/*
* Returns true if page needs to be initialized or freed to buddy allocator.
*
- * First we check if pfn is valid on architectures where it is possible to have
- * holes within pageblock_nr_pages. On systems where it is not possible, this
- * function is optimized out.
- *
- * Then, we check if a current large page is valid by only checking the validity
+ * We check if a current large page is valid by only checking the validity
* of the head pfn.
*/
static inline bool __init deferred_pfn_valid(unsigned long pfn)
--
2.23.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v2 08/16] mm/page_alloc: add missing is_migrate_isolate() check in set_page_guard()
2022-09-16 7:22 ` [PATCH v2 08/16] mm/page_alloc: add missing is_migrate_isolate() check in set_page_guard() Miaohe Lin
@ 2022-09-19 11:28 ` David Hildenbrand
0 siblings, 0 replies; 19+ messages in thread
From: David Hildenbrand @ 2022-09-19 11:28 UTC (permalink / raw)
To: Miaohe Lin, akpm, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel
On 16.09.22 09:22, Miaohe Lin wrote:
> In MIGRATE_ISOLATE case, zone freepage state shouldn't be modified as
> caller will take care of it. Add missing is_migrate_isolate() here to
> avoid possible unbalanced freepage state. This would happen if someone
> isolates the block, and then we face an MCE failure/soft-offline on a
> page within that block. __mod_zone_freepage_state() will be triggered
> via below call trace which already had been triggered back when block
> was isolated:
>
> take_page_off_buddy
> break_down_buddy_pages
> set_page_guard
>
> Fixes: 06be6ff3d2ec ("mm,hwpoison: rework soft offline for free pages")
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> Reviewed-by: Oscar Salvador <osalvador@suse.de>
> ---
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 12/16] mm/page_alloc: use helper macro SZ_1{K,M}
2022-09-16 7:22 ` [PATCH v2 12/16] mm/page_alloc: use helper macro SZ_1{K,M} Miaohe Lin
@ 2022-09-19 11:30 ` David Hildenbrand
0 siblings, 0 replies; 19+ messages in thread
From: David Hildenbrand @ 2022-09-19 11:30 UTC (permalink / raw)
To: Miaohe Lin, akpm, osalvador, anshuman.khandual
Cc: willy, linux-mm, linux-kernel
On 16.09.22 09:22, Miaohe Lin wrote:
> Use helper macro SZ_1K and SZ_1M to do the size conversion. Minor
> readability improvement.
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2022-09-19 11:30 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16 7:22 [PATCH v2 00/16] A few cleanup patches for mm Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 01/16] mm/page_alloc: ensure kswapd doesn't accidentally go to sleep Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 02/16] mm/page_alloc: make zone_pcp_update() static Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 03/16] mm: remove obsolete macro NR_PCP_ORDER_MASK and NR_PCP_ORDER_WIDTH Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 04/16] mm/page_alloc: remove obsolete comment in zone_statistics() Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 05/16] mm/page_alloc: add __init annotations to init_mem_debugging_and_hardening() Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 06/16] mm/page_alloc: fix freeing static percpu memory Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 07/16] mm: remove obsolete pgdat_is_empty() Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 08/16] mm/page_alloc: add missing is_migrate_isolate() check in set_page_guard() Miaohe Lin
2022-09-19 11:28 ` David Hildenbrand
2022-09-16 7:22 ` [PATCH v2 09/16] mm/page_alloc: use local variable zone_idx directly Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 10/16] mm, memory_hotplug: remove obsolete generic_free_nodedata() Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 11/16] mm/page_alloc: make boot_nodestats static Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 12/16] mm/page_alloc: use helper macro SZ_1{K,M} Miaohe Lin
2022-09-19 11:30 ` David Hildenbrand
2022-09-16 7:22 ` [PATCH v2 13/16] mm/page_alloc: init local variable buddy_pfn Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 14/16] mm/page_alloc: use costly_order in WARN_ON_ONCE_GFP() Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 15/16] mm/page_alloc: remove obsolete gfpflags_normal_context() Miaohe Lin
2022-09-16 7:22 ` [PATCH v2 16/16] mm/page_alloc: fix obsolete comment in deferred_pfn_valid() Miaohe Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).