Skip to content

Commit 46a8413

Browse files
jiangliutorvalds
authored andcommitted
mm/x86: 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: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Andreas Herrmann <[email protected]> Cc: Tang Chen <[email protected]> Cc: Wen Congyang <[email protected]> Cc: Jianguo Wu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 0d0b6d2 commit 46a8413

File tree

5 files changed

+4
-52
lines changed

5 files changed

+4
-52
lines changed

arch/x86/kernel/cpu/amd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c)
9090
static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
9191
{
9292
u32 l, h;
93-
int mbytes = num_physpages >> (20-PAGE_SHIFT);
93+
int mbytes = get_num_physpages() >> (20-PAGE_SHIFT);
9494

9595
if (c->x86_model < 6) {
9696
/* Based on AMD doc 20734R - June 2000 */

arch/x86/kernel/setup.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,8 +1040,6 @@ void __init setup_arch(char **cmdline_p)
10401040
/* max_low_pfn get updated here */
10411041
find_low_pfn_range();
10421042
#else
1043-
num_physpages = max_pfn;
1044-
10451043
check_x2apic();
10461044

10471045
/* How many end-of-memory variables you have, grandma! */

arch/x86/mm/init_32.c

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -660,18 +660,16 @@ void __init initmem_init(void)
660660
highstart_pfn = max_low_pfn;
661661
printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
662662
pages_to_mb(highend_pfn - highstart_pfn));
663-
num_physpages = highend_pfn;
664663
high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
665664
#else
666-
num_physpages = max_low_pfn;
667665
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
668666
#endif
669667

670668
memblock_set_node(0, (phys_addr_t)ULLONG_MAX, 0);
671669
sparse_memory_present_with_active_regions(0);
672670

673671
#ifdef CONFIG_FLATMEM
674-
max_mapnr = num_physpages;
672+
max_mapnr = IS_ENABLED(CONFIG_HIGHMEM) ? highend_pfn : max_low_pfn;
675673
#endif
676674
__vmalloc_start_set = true;
677675

@@ -739,9 +737,6 @@ static void __init test_wp_bit(void)
739737

740738
void __init mem_init(void)
741739
{
742-
int codesize, reservedpages, datasize, initsize;
743-
int tmp;
744-
745740
pci_iommu_alloc();
746741

747742
#ifdef CONFIG_FLATMEM
@@ -761,30 +756,9 @@ void __init mem_init(void)
761756
/* this will put all low memory onto the freelists */
762757
free_all_bootmem();
763758

764-
reservedpages = 0;
765-
for (tmp = 0; tmp < max_low_pfn; tmp++)
766-
/*
767-
* Only count reserved RAM pages:
768-
*/
769-
if (page_is_ram(tmp) && PageReserved(pfn_to_page(tmp)))
770-
reservedpages++;
771-
772759
after_bootmem = 1;
773760

774-
codesize = (unsigned long) &_etext - (unsigned long) &_text;
775-
datasize = (unsigned long) &_edata - (unsigned long) &_etext;
776-
initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
777-
778-
printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
779-
"%dk reserved, %dk data, %dk init, %ldk highmem)\n",
780-
nr_free_pages() << (PAGE_SHIFT-10),
781-
num_physpages << (PAGE_SHIFT-10),
782-
codesize >> 10,
783-
reservedpages << (PAGE_SHIFT-10),
784-
datasize >> 10,
785-
initsize >> 10,
786-
totalhigh_pages << (PAGE_SHIFT-10));
787-
761+
mem_init_print_info(NULL);
788762
printk(KERN_INFO "virtual kernel memory layout:\n"
789763
" fixmap : 0x%08lx - 0x%08lx (%4ld kB)\n"
790764
#ifdef CONFIG_HIGHMEM

arch/x86/mm/init_64.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,9 +1044,6 @@ static void __init register_page_bootmem_info(void)
10441044

10451045
void __init mem_init(void)
10461046
{
1047-
long codesize, reservedpages, datasize, initsize;
1048-
unsigned long absent_pages;
1049-
10501047
pci_iommu_alloc();
10511048

10521049
/* clear_bss() already clear the empty_zero_page */
@@ -1055,28 +1052,13 @@ void __init mem_init(void)
10551052

10561053
/* this will put all memory onto the freelists */
10571054
free_all_bootmem();
1058-
1059-
absent_pages = absent_pages_in_range(0, max_pfn);
1060-
reservedpages = max_pfn - totalram_pages - absent_pages;
10611055
after_bootmem = 1;
10621056

1063-
codesize = (unsigned long) &_etext - (unsigned long) &_text;
1064-
datasize = (unsigned long) &_edata - (unsigned long) &_etext;
1065-
initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
1066-
10671057
/* Register memory areas for /proc/kcore */
10681058
kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START,
10691059
VSYSCALL_END - VSYSCALL_START, KCORE_OTHER);
10701060

1071-
printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
1072-
"%ldk absent, %ldk reserved, %ldk data, %ldk init)\n",
1073-
nr_free_pages() << (PAGE_SHIFT-10),
1074-
max_pfn << (PAGE_SHIFT-10),
1075-
codesize >> 10,
1076-
absent_pages << (PAGE_SHIFT-10),
1077-
reservedpages << (PAGE_SHIFT-10),
1078-
datasize >> 10,
1079-
initsize >> 10);
1061+
mem_init_print_info(NULL);
10801062
}
10811063

10821064
#ifdef CONFIG_DEBUG_RODATA

arch/x86/mm/numa_32.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ void __init initmem_init(void)
8383
highstart_pfn = max_low_pfn;
8484
printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
8585
pages_to_mb(highend_pfn - highstart_pfn));
86-
num_physpages = highend_pfn;
8786
high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
8887
#else
89-
num_physpages = max_low_pfn;
9088
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
9189
#endif
9290
printk(KERN_NOTICE "%ldMB LOWMEM available.\n",

0 commit comments

Comments
 (0)