Skip to content

Commit c89ab04

Browse files
rppttorvalds
authored andcommitted
mm/sparse: cleanup the code surrounding memory_present()
After removal of CONFIG_HAVE_MEMBLOCK_NODE_MAP we have two equivalent functions that call memory_present() for each region in memblock.memory: sparse_memory_present_with_active_regions() and membocks_present(). Moreover, all architectures have a call to either of these functions preceding the call to sparse_init() and in the most cases they are called one after the other. Mark the regions from memblock.memory as present during sparce_init() by making sparse_init() call memblocks_present(), make memblocks_present() and memory_present() functions static and remove redundant sparse_memory_present_with_active_regions() function. Also remove no longer required HAVE_MEMORY_PRESENT configuration option. Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Link: http://lkml.kernel.org/r/20200712083130.22919-1-rppt@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6cda720 commit c89ab04

23 files changed

Lines changed: 19 additions & 101 deletions

File tree

‎Documentation/vm/memory-model.rst‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,8 @@ sections:
141141
`mem_section` objects and the number of rows is calculated to fit
142142
all the memory sections.
143143

144-
The architecture setup code should call :c:func:`memory_present` for
145-
each active memory range or use :c:func:`memblocks_present` or
146-
:c:func:`sparse_memory_present_with_active_regions` wrappers to
147-
initialize the memory sections. Next, the actual memory maps should be
148-
set up using :c:func:`sparse_init`.
144+
The architecture setup code should call sparse_init() to
145+
initialize the memory sections and the memory maps.
149146

150147
With SPARSEMEM there are two possible ways to convert a PFN to the
151148
corresponding `struct page` - a "classic sparse" and "sparse

‎arch/arm/mm/init.c‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,8 @@ void __init bootmem_init(void)
243243
(phys_addr_t)max_low_pfn << PAGE_SHIFT);
244244

245245
/*
246-
* Sparsemem tries to allocate bootmem in memory_present(),
247-
* so must be done after the fixed reservations
248-
*/
249-
memblocks_present();
250-
251-
/*
252-
* sparse_init() needs the bootmem allocator up and running.
246+
* sparse_init() tries to allocate memory from memblock, so must be
247+
* done after the fixed reservations
253248
*/
254249
sparse_init();
255250

‎arch/arm64/mm/init.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,9 @@ void __init bootmem_init(void)
430430
#endif
431431

432432
/*
433-
* Sparsemem tries to allocate bootmem in memory_present(), so must be
434-
* done after the fixed reservations.
433+
* sparse_init() tries to allocate memory from memblock, so must be
434+
* done after the fixed reservations
435435
*/
436-
memblocks_present();
437-
438436
sparse_init();
439437
zone_sizes_init(min, max);
440438

‎arch/ia64/mm/discontig.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@ void __init paging_init(void)
600600

601601
max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
602602

603-
sparse_memory_present_with_active_regions(MAX_NUMNODES);
604603
sparse_init();
605604

606605
#ifdef CONFIG_VIRTUAL_MEM_MAP

‎arch/microblaze/mm/init.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,6 @@ void __init setup_memory(void)
172172
&memblock.memory, 0);
173173
}
174174

175-
/* XXX need to clip this if using highmem? */
176-
sparse_memory_present_with_active_regions(0);
177-
178175
paging_init();
179176
}
180177

‎arch/mips/kernel/setup.c‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,6 @@ static void __init bootmem_init(void)
371371
#endif
372372
}
373373

374-
375-
/*
376-
* In any case the added to the memblock memory regions
377-
* (highmem/lowmem, available/reserved, etc) are considered
378-
* as present, so inform sparsemem about them.
379-
*/
380-
memblocks_present();
381-
382374
/*
383375
* Reserve initrd memory if needed.
384376
*/

‎arch/mips/loongson64/numa.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ static __init void prom_meminit(void)
220220
cpumask_clear(&__node_cpumask[node]);
221221
}
222222
}
223-
memblocks_present();
224223
max_low_pfn = PHYS_PFN(memblock_end_of_DRAM());
225224

226225
for (cpu = 0; cpu < loongson_sysconf.nr_cpus; cpu++) {

‎arch/mips/sgi-ip27/ip27-memory.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,6 @@ void __init prom_meminit(void)
402402
}
403403
__node_data[node] = &null_node;
404404
}
405-
406-
memblocks_present();
407405
}
408406

409407
void __init prom_free_prom_memory(void)

‎arch/parisc/mm/init.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -689,11 +689,6 @@ void __init paging_init(void)
689689
flush_cache_all_local(); /* start with known state */
690690
flush_tlb_all_local(NULL);
691691

692-
/*
693-
* Mark all memblocks as present for sparsemem using
694-
* memory_present() and then initialize sparsemem.
695-
*/
696-
memblocks_present();
697692
sparse_init();
698693
parisc_bootmem_free();
699694
}

‎arch/powerpc/mm/mem.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ void __init mem_topology_setup(void)
183183

184184
void __init initmem_init(void)
185185
{
186-
/* XXX need to clip this if using highmem? */
187-
sparse_memory_present_with_active_regions(0);
188186
sparse_init();
189187
}
190188

0 commit comments

Comments
 (0)