mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-11-01 06:46:35 +01:00
mm: free_area_init: allow defining max_zone_pfn in descending order
Some architectures (e.g. ARC) have the ZONE_HIGHMEM zone below the ZONE_NORMAL. Allowing free_area_init() parse max_zone_pfn array even it is sorted in descending order allows using free_area_init() on such architectures. Add top -> down traversal of max_zone_pfn array in free_area_init() and use the latter in ARC node/zone initialization. [[email protected]: ARC fix] Link: http://lkml.kernel.org/r/[email protected] [[email protected]: arc: free_area_init(): take into account PAE40 mode] Link: http://lkml.kernel.org/r/[email protected] [[email protected]: declare arch_has_descending_max_zone_pfns()] Signed-off-by: Mike Rapoport <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Tested-by: Hoan Tran <[email protected]> [arm64] Reviewed-by: Baoquan He <[email protected]> Cc: Brian Cain <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Greentime Hu <[email protected]> Cc: Greg Ungerer <[email protected]> Cc: Guan Xuetao <[email protected]> Cc: Guo Ren <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Helge Deller <[email protected]> Cc: "James E.J. Bottomley" <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Ley Foon Tan <[email protected]> Cc: Mark Salter <[email protected]> Cc: Matt Turner <[email protected]> Cc: Max Filippov <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Michal Simek <[email protected]> Cc: Nick Hu <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Rich Felker <[email protected]> Cc: Russell King <[email protected]> Cc: Stafford Horne <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Tony Luck <[email protected]> Cc: Vineet Gupta <[email protected]> Cc: Yoshinori Sato <[email protected]> Cc: Guenter Roeck <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
1 parent
acd3f5c441
commit
51930df580
3 files changed
+34
-34
No files matched your search
+12
-29
@@ -63,11 +63,13 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
|
||||
|
||||
low_mem_sz = size;
|
||||
in_use = 1;
|
||||
memblock_add_node(base, size, 0);
|
||||
} else {
|
||||
#ifdef CONFIG_HIGHMEM
|
||||
high_mem_start = base;
|
||||
high_mem_sz = size;
|
||||
in_use = 1;
|
||||
memblock_add_node(base, size, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -75,6 +77,11 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
|
||||
base, TO_MB(size), !in_use ? "Not used":"");
|
||||
}
|
||||
|
||||
bool arch_has_descending_max_zone_pfns(void)
|
||||
{
|
||||
return !IS_ENABLED(CONFIG_ARC_HAS_PAE40);
|
||||
}
|
||||
|
||||
/*
|
||||
* First memory setup routine called from setup_arch()
|
||||
* 1. setup swapper's mm @init_mm
|
||||
@@ -83,8 +90,7 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
|
||||
*/
|
||||
void __init setup_arch_memory(void)
|
||||
{
|
||||
unsigned long zones_size[MAX_NR_ZONES];
|
||||
unsigned long zones_holes[MAX_NR_ZONES];
|
||||
unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };
|
||||
|
||||
init_mm.start_code = (unsigned long)_text;
|
||||
init_mm.end_code = (unsigned long)_etext;
|
||||
@@ -115,7 +121,6 @@ void __init setup_arch_memory(void)
|
||||
* the crash
|
||||
*/
|
||||
|
||||
memblock_add_node(low_mem_start, low_mem_sz, 0);
|
||||
memblock_reserve(CONFIG_LINUX_LINK_BASE,
|
||||
__pa(_end) - CONFIG_LINUX_LINK_BASE);
|
||||
|
||||
@@ -133,22 +138,7 @@ void __init setup_arch_memory(void)
|
||||
memblock_dump_all();
|
||||
|
||||
/*----------------- node/zones setup --------------------------*/
|
||||
memset(zones_size, 0, sizeof(zones_size));
|
||||
memset(zones_holes, 0, sizeof(zones_holes));
|
||||
|
||||
zones_size[ZONE_NORMAL] = max_low_pfn - min_low_pfn;
|
||||
zones_holes[ZONE_NORMAL] = 0;
|
||||
|
||||
/*
|
||||
* We can't use the helper free_area_init(zones[]) because it uses
|
||||
* PAGE_OFFSET to compute the @min_low_pfn which would be wrong
|
||||
* when our kernel doesn't start at PAGE_OFFSET, i.e.
|
||||
* PAGE_OFFSET != CONFIG_LINUX_RAM_BASE
|
||||
*/
|
||||
free_area_init_node(0, /* node-id */
|
||||
zones_size, /* num pages per zone */
|
||||
min_low_pfn, /* first pfn of node */
|
||||
zones_holes); /* holes */
|
||||
max_zone_pfn[ZONE_NORMAL] = max_low_pfn;
|
||||
|
||||
#ifdef CONFIG_HIGHMEM
|
||||
/*
|
||||
@@ -168,20 +158,13 @@ void __init setup_arch_memory(void)
|
||||
min_high_pfn = PFN_DOWN(high_mem_start);
|
||||
max_high_pfn = PFN_DOWN(high_mem_start + high_mem_sz);
|
||||
|
||||
zones_size[ZONE_NORMAL] = 0;
|
||||
zones_holes[ZONE_NORMAL] = 0;
|
||||
|
||||
zones_size[ZONE_HIGHMEM] = max_high_pfn - min_high_pfn;
|
||||
zones_holes[ZONE_HIGHMEM] = 0;
|
||||
|
||||
free_area_init_node(1, /* node-id */
|
||||
zones_size, /* num pages per zone */
|
||||
min_high_pfn, /* first pfn of node */
|
||||
zones_holes); /* holes */
|
||||
max_zone_pfn[ZONE_HIGHMEM] = max_high_pfn;
|
||||
|
||||
high_memory = (void *)(min_high_pfn << PAGE_SHIFT);
|
||||
kmap_init();
|
||||
#endif
|
||||
|
||||
free_area_init(max_zone_pfn);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -2473,6 +2473,7 @@ extern void setup_per_cpu_pageset(void);
|
||||
extern int min_free_kbytes;
|
||||
extern int watermark_boost_factor;
|
||||
extern int watermark_scale_factor;
|
||||
extern bool arch_has_descending_max_zone_pfns(void);
|
||||
|
||||
/* nommu.c */
|
||||
extern atomic_long_t mmap_pages_allocated;
|
||||
|
||||
+21
-5
@@ -7408,6 +7408,15 @@ static void check_for_memory(pg_data_t *pgdat, int nid)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Some architecturs, e.g. ARC may have ZONE_HIGHMEM below ZONE_NORMAL. For
|
||||
* such cases we allow max_zone_pfn sorted in the descending order
|
||||
*/
|
||||
bool __weak arch_has_descending_max_zone_pfns(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* free_area_init - Initialise all pg_data_t and zone data
|
||||
* @max_zone_pfn: an array of max PFNs for each zone
|
||||
@@ -7424,7 +7433,8 @@ static void check_for_memory(pg_data_t *pgdat, int nid)
|
||||
void __init free_area_init(unsigned long *max_zone_pfn)
|
||||
{
|
||||
unsigned long start_pfn, end_pfn;
|
||||
int i, nid;
|
||||
int i, nid, zone;
|
||||
bool descending;
|
||||
|
||||
/* Record where the zone boundaries are */
|
||||
memset(arch_zone_lowest_possible_pfn, 0,
|
||||
@@ -7433,14 +7443,20 @@ void __init free_area_init(unsigned long *max_zone_pfn)
|
||||
sizeof(arch_zone_highest_possible_pfn));
|
||||
|
||||
start_pfn = find_min_pfn_with_active_regions();
|
||||
descending = arch_has_descending_max_zone_pfns();
|
||||
|
||||
for (i = 0; i < MAX_NR_ZONES; i++) {
|
||||
if (i == ZONE_MOVABLE)
|
||||
if (descending)
|
||||
zone = MAX_NR_ZONES - i - 1;
|
||||
else
|
||||
zone = i;
|
||||
|
||||
if (zone == ZONE_MOVABLE)
|
||||
continue;
|
||||
|
||||
end_pfn = max(max_zone_pfn[i], start_pfn);
|
||||
arch_zone_lowest_possible_pfn[i] = start_pfn;
|
||||
arch_zone_highest_possible_pfn[i] = end_pfn;
|
||||
end_pfn = max(max_zone_pfn[zone], start_pfn);
|
||||
arch_zone_lowest_possible_pfn[zone] = start_pfn;
|
||||
arch_zone_highest_possible_pfn[zone] = end_pfn;
|
||||
|
||||
start_pfn = end_pfn;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user