Skip to content

Commit e0932b6

Browse files
hnazakpm00
authored andcommitted
mm: page_alloc: consolidate free page accounting
Free page accounting currently happens a bit too high up the call stack, where it has to deal with guard pages, compaction capturing, block stealing and even page isolation. This is subtle and fragile, and makes it difficult to hack on the code. Now that type violations on the freelists have been fixed, push the accounting down to where pages enter and leave the freelist. [[email protected]: undo unrelated drive-by line wrap] Link: https://lkml.kernel.org/r/[email protected] [[email protected]: remove unused page parameter from account_freepages()] Link: https://lkml.kernel.org/r/[email protected] [[email protected]: fix free page accounting] Link: https://lkml.kernel.org/r/a2a48baca69f103aa431fd201f8a06e3b95e203d.1712648441.git.baolin.wang@linux.alibaba.com [[email protected]: avoid defining unused function] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Johannes Weiner <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Baolin Wang <[email protected]> Reviewed-by: Vlastimil Babka <[email protected]> Tested-by: Baolin Wang <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: "Huang, Ying" <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Zi Yan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent fd919a8 commit e0932b6

File tree

5 files changed

+118
-117
lines changed

5 files changed

+118
-117
lines changed

include/linux/mm.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3797,24 +3797,22 @@ static inline bool page_is_guard(struct page *page)
37973797
return PageGuard(page);
37983798
}
37993799

3800-
bool __set_page_guard(struct zone *zone, struct page *page, unsigned int order,
3801-
int migratetype);
3800+
bool __set_page_guard(struct zone *zone, struct page *page, unsigned int order);
38023801
static inline bool set_page_guard(struct zone *zone, struct page *page,
3803-
unsigned int order, int migratetype)
3802+
unsigned int order)
38043803
{
38053804
if (!debug_guardpage_enabled())
38063805
return false;
3807-
return __set_page_guard(zone, page, order, migratetype);
3806+
return __set_page_guard(zone, page, order);
38083807
}
38093808

3810-
void __clear_page_guard(struct zone *zone, struct page *page, unsigned int order,
3811-
int migratetype);
3809+
void __clear_page_guard(struct zone *zone, struct page *page, unsigned int order);
38123810
static inline void clear_page_guard(struct zone *zone, struct page *page,
3813-
unsigned int order, int migratetype)
3811+
unsigned int order)
38143812
{
38153813
if (!debug_guardpage_enabled())
38163814
return;
3817-
__clear_page_guard(zone, page, order, migratetype);
3815+
__clear_page_guard(zone, page, order);
38183816
}
38193817

38203818
#else /* CONFIG_DEBUG_PAGEALLOC */
@@ -3824,9 +3822,9 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
38243822
static inline bool debug_guardpage_enabled(void) { return false; }
38253823
static inline bool page_is_guard(struct page *page) { return false; }
38263824
static inline bool set_page_guard(struct zone *zone, struct page *page,
3827-
unsigned int order, int migratetype) { return false; }
3825+
unsigned int order) { return false; }
38283826
static inline void clear_page_guard(struct zone *zone, struct page *page,
3829-
unsigned int order, int migratetype) {}
3827+
unsigned int order) {}
38303828
#endif /* CONFIG_DEBUG_PAGEALLOC */
38313829

38323830
#ifdef __HAVE_ARCH_GATE_AREA

include/linux/vmstat.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -487,14 +487,6 @@ static inline void node_stat_sub_folio(struct folio *folio,
487487
mod_node_page_state(folio_pgdat(folio), item, -folio_nr_pages(folio));
488488
}
489489

490-
static inline void __mod_zone_freepage_state(struct zone *zone, int nr_pages,
491-
int migratetype)
492-
{
493-
__mod_zone_page_state(zone, NR_FREE_PAGES, nr_pages);
494-
if (is_migrate_cma(migratetype))
495-
__mod_zone_page_state(zone, NR_FREE_CMA_PAGES, nr_pages);
496-
}
497-
498490
extern const char * const vmstat_text[];
499491

500492
static inline const char *zone_stat_name(enum zone_stat_item item)

mm/debug_page_alloc.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,20 @@ static int __init debug_guardpage_minorder_setup(char *buf)
3232
}
3333
early_param("debug_guardpage_minorder", debug_guardpage_minorder_setup);
3434

35-
bool __set_page_guard(struct zone *zone, struct page *page, unsigned int order,
36-
int migratetype)
35+
bool __set_page_guard(struct zone *zone, struct page *page, unsigned int order)
3736
{
3837
if (order >= debug_guardpage_minorder())
3938
return false;
4039

4140
__SetPageGuard(page);
4241
INIT_LIST_HEAD(&page->buddy_list);
4342
set_page_private(page, order);
44-
/* Guard pages are not available for any usage */
45-
if (!is_migrate_isolate(migratetype))
46-
__mod_zone_freepage_state(zone, -(1 << order), migratetype);
4743

4844
return true;
4945
}
5046

51-
void __clear_page_guard(struct zone *zone, struct page *page, unsigned int order,
52-
int migratetype)
47+
void __clear_page_guard(struct zone *zone, struct page *page, unsigned int order)
5348
{
5449
__ClearPageGuard(page);
55-
5650
set_page_private(page, 0);
57-
if (!is_migrate_isolate(migratetype))
58-
__mod_zone_freepage_state(zone, (1 << order), migratetype);
5951
}

mm/internal.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,11 +1039,6 @@ static inline bool is_migrate_highatomic(enum migratetype migratetype)
10391039
return migratetype == MIGRATE_HIGHATOMIC;
10401040
}
10411041

1042-
static inline bool is_migrate_highatomic_page(struct page *page)
1043-
{
1044-
return get_pageblock_migratetype(page) == MIGRATE_HIGHATOMIC;
1045-
}
1046-
10471042
void setup_zone_pageset(struct zone *zone);
10481043

10491044
struct migration_target_control {

0 commit comments

Comments
 (0)