init.c (cddb5ddf2b76debdb8cad1728ad0a9321383d933) init.c (c9118e6c37bff9ade90b638207a6e0db676ee6a9)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * linux/arch/arm/mm/init.c
4 *
5 * Copyright (C) 1995-2005 Russell King
6 */
7#include <linux/kernel.h>
8#include <linux/errno.h>

--- 285 unchanged lines hidden (view full) ---

294 memblock_free_early(pg, pgend - pg);
295}
296
297/*
298 * The mem_map array can get very big. Free the unused area of the memory map.
299 */
300static void __init free_unused_memmap(void)
301{
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * linux/arch/arm/mm/init.c
4 *
5 * Copyright (C) 1995-2005 Russell King
6 */
7#include <linux/kernel.h>
8#include <linux/errno.h>

--- 285 unchanged lines hidden (view full) ---

294 memblock_free_early(pg, pgend - pg);
295}
296
297/*
298 * The mem_map array can get very big. Free the unused area of the memory map.
299 */
300static void __init free_unused_memmap(void)
301{
302 unsigned long start, prev_end = 0;
303 struct memblock_region *reg;
302 unsigned long start, end, prev_end = 0;
303 int i;
304
305 /*
306 * This relies on each bank being in address order.
307 * The banks are sorted previously in bootmem_init().
308 */
304
305 /*
306 * This relies on each bank being in address order.
307 * The banks are sorted previously in bootmem_init().
308 */
309 for_each_memblock(memory, reg) {
310 start = memblock_region_memory_base_pfn(reg);
311
309 for_each_mem_pfn_range(i, MAX_NUMNODES, &start, &end, NULL) {
312#ifdef CONFIG_SPARSEMEM
313 /*
314 * Take care not to free memmap entries that don't exist
315 * due to SPARSEMEM sections which aren't present.
316 */
317 start = min(start,
318 ALIGN(prev_end, PAGES_PER_SECTION));
319#else

--- 11 unchanged lines hidden (view full) ---

331 if (prev_end && prev_end < start)
332 free_memmap(prev_end, start);
333
334 /*
335 * Align up here since the VM subsystem insists that the
336 * memmap entries are valid from the bank end aligned to
337 * MAX_ORDER_NR_PAGES.
338 */
310#ifdef CONFIG_SPARSEMEM
311 /*
312 * Take care not to free memmap entries that don't exist
313 * due to SPARSEMEM sections which aren't present.
314 */
315 start = min(start,
316 ALIGN(prev_end, PAGES_PER_SECTION));
317#else

--- 11 unchanged lines hidden (view full) ---

329 if (prev_end && prev_end < start)
330 free_memmap(prev_end, start);
331
332 /*
333 * Align up here since the VM subsystem insists that the
334 * memmap entries are valid from the bank end aligned to
335 * MAX_ORDER_NR_PAGES.
336 */
339 prev_end = ALIGN(memblock_region_memory_end_pfn(reg),
340 MAX_ORDER_NR_PAGES);
337 prev_end = ALIGN(end, MAX_ORDER_NR_PAGES);
341 }
342
343#ifdef CONFIG_SPARSEMEM
344 if (!IS_ALIGNED(prev_end, PAGES_PER_SECTION))
345 free_memmap(prev_end,
346 ALIGN(prev_end, PAGES_PER_SECTION));
347#endif
348}

--- 275 unchanged lines hidden ---
338 }
339
340#ifdef CONFIG_SPARSEMEM
341 if (!IS_ALIGNED(prev_end, PAGES_PER_SECTION))
342 free_memmap(prev_end,
343 ALIGN(prev_end, PAGES_PER_SECTION));
344#endif
345}

--- 275 unchanged lines hidden ---