Skip to content

Commit d98fb1a

Browse files
author
Fox Snowpatch
committed
1 parent d5603db commit d98fb1a

File tree

64 files changed

+223
-414
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+223
-414
lines changed

Documentation/driver-api/cxl/linux/early-boot.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ The contiguous memory allocator (CMA) enables reservation of contiguous memory
125125
regions on NUMA nodes during early boot. However, CMA cannot reserve memory
126126
on NUMA nodes that are not online during early boot. ::
127127

128-
void __init hugetlb_cma_reserve(int order) {
128+
void __init hugetlb_cma_reserve(void) {
129129
if (!node_online(nid))
130130
/* do not allow reservations */
131131
}

Documentation/mm/memory-model.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ sections:
9797
`mem_section` objects and the number of rows is calculated to fit
9898
all the memory sections.
9999

100-
The architecture setup code should call sparse_init() to
101-
initialize the memory sections and the memory maps.
102-
103100
With SPARSEMEM there are two possible ways to convert a PFN to the
104101
corresponding `struct page` - a "classic sparse" and "sparse
105102
vmemmap". The selection is made at build time and it is determined by

Documentation/translations/zh_CN/mm/memory-model.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ SPARSEMEM模型将物理内存显示为一个部分的集合。一个区段用me
8383
每一行包含价值 `PAGE_SIZE` 的 `mem_section` 对象,行数的计算是为了适应所有的
8484
内存区。
8585

86-
架构设置代码应该调用sparse_init()来初始化内存区和内存映射。
87-
8886
通过SPARSEMEM,有两种可能的方式将PFN转换为相应的 `struct page` --"classic sparse"和
8987
"sparse vmemmap"。选择是在构建时进行的,它由 `CONFIG_SPARSEMEM_VMEMMAP` 的
9088
值决定。

arch/alpha/kernel/setup.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,6 @@ setup_arch(char **cmdline_p)
607607
/* Find our memory. */
608608
setup_memory(kernel_end);
609609
memblock_set_bottom_up(true);
610-
sparse_init();
611610

612611
/* First guess at cpu cache sizes. Do this before init_arch. */
613612
determine_cpu_caches(cpu->type);

arch/alpha/mm/init.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,24 +208,22 @@ callback_init(void * kernel_end)
208208
return kernel_end;
209209
}
210210

211-
/*
212-
* paging_init() sets up the memory map.
213-
*/
214-
void __init paging_init(void)
211+
void __init arch_zone_limits_init(unsigned long *max_zone_pfn)
215212
{
216-
unsigned long max_zone_pfn[MAX_NR_ZONES] = {0, };
217213
unsigned long dma_pfn;
218214

219215
dma_pfn = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
220216
max_pfn = max_low_pfn;
221217

222218
max_zone_pfn[ZONE_DMA] = dma_pfn;
223219
max_zone_pfn[ZONE_NORMAL] = max_pfn;
220+
}
224221

225-
/* Initialize mem_map[]. */
226-
free_area_init(max_zone_pfn);
227-
228-
/* Initialize the kernel's ZERO_PGE. */
222+
/*
223+
* paging_init() initializes the kernel's ZERO_PGE.
224+
*/
225+
void __init paging_init(void)
226+
{
229227
memset(absolute_pointer(ZERO_PGE), 0, PAGE_SIZE);
230228
}
231229

arch/arc/mm/init.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,25 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
7575
base, TO_MB(size), !in_use ? "Not used":"");
7676
}
7777

78+
void __init arch_zone_limits_init(unsigned long *max_zone_pfn)
79+
{
80+
/*----------------- node/zones setup --------------------------*/
81+
max_zone_pfn[ZONE_NORMAL] = max_low_pfn;
82+
83+
#ifdef CONFIG_HIGHMEM
84+
/*
85+
* max_high_pfn should be ok here for both HIGHMEM and HIGHMEM+PAE.
86+
* For HIGHMEM without PAE max_high_pfn should be less than
87+
* min_low_pfn to guarantee that these two regions don't overlap.
88+
* For PAE case highmem is greater than lowmem, so it is natural
89+
* to use max_high_pfn.
90+
*
91+
* In both cases, holes should be handled by pfn_valid().
92+
*/
93+
max_zone_pfn[ZONE_HIGHMEM] = max_high_pfn;
94+
#endif
95+
}
96+
7897
/*
7998
* First memory setup routine called from setup_arch()
8099
* 1. setup swapper's mm @init_mm
@@ -83,8 +102,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
83102
*/
84103
void __init setup_arch_memory(void)
85104
{
86-
unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };
87-
88105
setup_initial_init_mm(_text, _etext, _edata, _end);
89106

90107
/* first page of system - kernel .vector starts here */
@@ -122,9 +139,6 @@ void __init setup_arch_memory(void)
122139

123140
memblock_dump_all();
124141

125-
/*----------------- node/zones setup --------------------------*/
126-
max_zone_pfn[ZONE_NORMAL] = max_low_pfn;
127-
128142
#ifdef CONFIG_HIGHMEM
129143
/*
130144
* On ARC (w/o PAE) HIGHMEM addresses are actually smaller (0 based)
@@ -139,22 +153,9 @@ void __init setup_arch_memory(void)
139153
min_high_pfn = PFN_DOWN(high_mem_start);
140154
max_high_pfn = PFN_DOWN(high_mem_start + high_mem_sz);
141155

142-
/*
143-
* max_high_pfn should be ok here for both HIGHMEM and HIGHMEM+PAE.
144-
* For HIGHMEM without PAE max_high_pfn should be less than
145-
* min_low_pfn to guarantee that these two regions don't overlap.
146-
* For PAE case highmem is greater than lowmem, so it is natural
147-
* to use max_high_pfn.
148-
*
149-
* In both cases, holes should be handled by pfn_valid().
150-
*/
151-
max_zone_pfn[ZONE_HIGHMEM] = max_high_pfn;
152-
153156
arch_pfn_offset = min(min_low_pfn, min_high_pfn);
154157
kmap_init();
155158
#endif /* CONFIG_HIGHMEM */
156-
157-
free_area_init(max_zone_pfn);
158159
}
159160

160161
void __init arch_mm_preinit(void)

arch/arm/include/asm/pgtable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* ZERO_PAGE is a global shared page that is always zero: used
1616
* for zero-mapped memory areas etc..
1717
*/
18-
extern struct page *empty_zero_page;
19-
#define ZERO_PAGE(vaddr) (empty_zero_page)
18+
extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
19+
#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
2020
#endif
2121

2222
#include <asm-generic/pgtable-nopud.h>

arch/arm/mm/init.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,15 @@ void __init setup_dma_zone(const struct machine_desc *mdesc)
107107
#endif
108108
}
109109

110-
static void __init zone_sizes_init(unsigned long min, unsigned long max_low,
111-
unsigned long max_high)
110+
void __init arch_zone_limits_init(unsigned long *max_zone_pfn)
112111
{
113-
unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };
114-
115112
#ifdef CONFIG_ZONE_DMA
116-
max_zone_pfn[ZONE_DMA] = min(arm_dma_pfn_limit, max_low);
113+
max_zone_pfn[ZONE_DMA] = min(arm_dma_pfn_limit, max_low_pfn);
117114
#endif
118-
max_zone_pfn[ZONE_NORMAL] = max_low;
115+
max_zone_pfn[ZONE_NORMAL] = max_low_pfn;
119116
#ifdef CONFIG_HIGHMEM
120-
max_zone_pfn[ZONE_HIGHMEM] = max_high;
117+
max_zone_pfn[ZONE_HIGHMEM] = max_pfn;
121118
#endif
122-
free_area_init(max_zone_pfn);
123119
}
124120

125121
#ifdef CONFIG_HAVE_ARCH_PFN_VALID
@@ -211,19 +207,6 @@ void __init bootmem_init(void)
211207

212208
early_memtest((phys_addr_t)min_low_pfn << PAGE_SHIFT,
213209
(phys_addr_t)max_low_pfn << PAGE_SHIFT);
214-
215-
/*
216-
* sparse_init() tries to allocate memory from memblock, so must be
217-
* done after the fixed reservations
218-
*/
219-
sparse_init();
220-
221-
/*
222-
* Now free the memory - free_area_init needs
223-
* the sparse mem_map arrays initialized by sparse_init()
224-
* for memmap_init_zone(), otherwise all PFNs are invalid.
225-
*/
226-
zone_sizes_init(min_low_pfn, max_low_pfn, max_pfn);
227210
}
228211

229212
/*

arch/arm/mm/mmu.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extern unsigned long __atags_pointer;
4545
* empty_zero_page is a special page that is used for
4646
* zero-initialized data and COW.
4747
*/
48-
struct page *empty_zero_page;
48+
unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;
4949
EXPORT_SYMBOL(empty_zero_page);
5050

5151
/*
@@ -1754,8 +1754,6 @@ static void __init early_fixmap_shutdown(void)
17541754
*/
17551755
void __init paging_init(const struct machine_desc *mdesc)
17561756
{
1757-
void *zero_page;
1758-
17591757
#ifdef CONFIG_XIP_KERNEL
17601758
/* Store the kernel RW RAM region start/end in these variables */
17611759
kernel_sec_start = CONFIG_PHYS_OFFSET & SECTION_MASK;
@@ -1781,13 +1779,7 @@ void __init paging_init(const struct machine_desc *mdesc)
17811779

17821780
top_pmd = pmd_off_k(0xffff0000);
17831781

1784-
/* allocate the zero page. */
1785-
zero_page = early_alloc(PAGE_SIZE);
1786-
17871782
bootmem_init();
1788-
1789-
empty_zero_page = virt_to_page(zero_page);
1790-
__flush_dcache_folio(NULL, page_folio(empty_zero_page));
17911783
}
17921784

17931785
void __init early_mm_init(const struct machine_desc *mdesc)

arch/arm/mm/nommu.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ unsigned long vectors_base;
3131
* empty_zero_page is a special page that is used for
3232
* zero-initialized data and COW.
3333
*/
34-
struct page *empty_zero_page;
34+
unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;
3535
EXPORT_SYMBOL(empty_zero_page);
3636

3737
#ifdef CONFIG_ARM_MPU
@@ -156,18 +156,10 @@ void __init adjust_lowmem_bounds(void)
156156
*/
157157
void __init paging_init(const struct machine_desc *mdesc)
158158
{
159-
void *zero_page;
160-
161159
early_trap_init((void *)vectors_base);
162160
mpu_setup();
163161

164-
/* allocate the zero page. */
165-
zero_page = (void *)memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE);
166-
167162
bootmem_init();
168-
169-
empty_zero_page = virt_to_page(zero_page);
170-
flush_dcache_page(empty_zero_page);
171163
}
172164

173165
/*

0 commit comments

Comments
 (0)