Skip to content

Commit 0d0b6d2

Browse files
jiangliutorvalds
authored andcommitted
mm/unicore32: prepare for removing num_physpages and simplify mem_init()
Prepare for removing num_physpages and simplify mem_init(). Signed-off-by: Jiang Liu <[email protected]> Cc: Guan Xuetao <[email protected]> Cc: Michal Hocko <[email protected]> Cc: David Rientjes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 715ee35 commit 0d0b6d2

File tree

1 file changed

+2
-47
lines changed

1 file changed

+2
-47
lines changed

arch/unicore32/mm/init.c

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -383,59 +383,14 @@ static void __init free_unused_memmap(struct meminfo *mi)
383383
*/
384384
void __init mem_init(void)
385385
{
386-
unsigned long reserved_pages, free_pages;
387-
struct memblock_region *reg;
388-
int i;
389-
390386
max_mapnr = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
391387

392388
free_unused_memmap(&meminfo);
393389

394390
/* this will put all unused low memory onto the freelists */
395391
free_all_bootmem();
396392

397-
reserved_pages = free_pages = 0;
398-
399-
for_each_bank(i, &meminfo) {
400-
struct membank *bank = &meminfo.bank[i];
401-
unsigned int pfn1, pfn2;
402-
struct page *page, *end;
403-
404-
pfn1 = bank_pfn_start(bank);
405-
pfn2 = bank_pfn_end(bank);
406-
407-
page = pfn_to_page(pfn1);
408-
end = pfn_to_page(pfn2 - 1) + 1;
409-
410-
do {
411-
if (PageReserved(page))
412-
reserved_pages++;
413-
else if (!page_count(page))
414-
free_pages++;
415-
page++;
416-
} while (page < end);
417-
}
418-
419-
/*
420-
* Since our memory may not be contiguous, calculate the
421-
* real number of pages we have in this system
422-
*/
423-
printk(KERN_INFO "Memory:");
424-
num_physpages = 0;
425-
for_each_memblock(memory, reg) {
426-
unsigned long pages = memblock_region_memory_end_pfn(reg) -
427-
memblock_region_memory_base_pfn(reg);
428-
num_physpages += pages;
429-
printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
430-
}
431-
printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
432-
433-
printk(KERN_NOTICE "Memory: %luk/%luk available, %luk reserved, %luK highmem\n",
434-
nr_free_pages() << (PAGE_SHIFT-10),
435-
free_pages << (PAGE_SHIFT-10),
436-
reserved_pages << (PAGE_SHIFT-10),
437-
totalhigh_pages << (PAGE_SHIFT-10));
438-
393+
mem_init_print_info(NULL);
439394
printk(KERN_NOTICE "Virtual kernel memory layout:\n"
440395
" vector : 0x%08lx - 0x%08lx (%4ld kB)\n"
441396
" vmalloc : 0x%08lx - 0x%08lx (%4ld MB)\n"
@@ -464,7 +419,7 @@ void __init mem_init(void)
464419
BUILD_BUG_ON(TASK_SIZE > MODULES_VADDR);
465420
BUG_ON(TASK_SIZE > MODULES_VADDR);
466421

467-
if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
422+
if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
468423
/*
469424
* On a machine this small we won't get
470425
* anywhere without overcommit, so turn

0 commit comments

Comments
 (0)