diff options
author | Gu Zheng <guz.fnst@cn.fujitsu.com> | 2015-06-24 19:57:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-24 20:49:42 -0400 |
commit | febd5949e134e279bde927353dc705ce41b18e2d (patch) | |
tree | c01f3548e4a9411838161b2e275b8c731ee1799c | |
parent | 641844f5616d7c6597309f560838f996466d7aac (diff) |
mm/memory hotplug: init the zone's size when calculating node totalpages
Init the zone's size when calculating node totalpages to avoid duplicated
operations in free_area_init_core().
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/page_alloc.c | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 7a5cbe7cc9b6..3b02be4def90 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -4756,22 +4756,28 @@ static void __meminit calculate_node_totalpages(struct pglist_data *pgdat, | |||
4756 | unsigned long *zones_size, | 4756 | unsigned long *zones_size, |
4757 | unsigned long *zholes_size) | 4757 | unsigned long *zholes_size) |
4758 | { | 4758 | { |
4759 | unsigned long realtotalpages, totalpages = 0; | 4759 | unsigned long realtotalpages = 0, totalpages = 0; |
4760 | enum zone_type i; | 4760 | enum zone_type i; |
4761 | 4761 | ||
4762 | for (i = 0; i < MAX_NR_ZONES; i++) | 4762 | for (i = 0; i < MAX_NR_ZONES; i++) { |
4763 | totalpages += zone_spanned_pages_in_node(pgdat->node_id, i, | 4763 | struct zone *zone = pgdat->node_zones + i; |
4764 | node_start_pfn, | 4764 | unsigned long size, real_size; |
4765 | node_end_pfn, | 4765 | |
4766 | zones_size); | 4766 | size = zone_spanned_pages_in_node(pgdat->node_id, i, |
4767 | pgdat->node_spanned_pages = totalpages; | 4767 | node_start_pfn, |
4768 | 4768 | node_end_pfn, | |
4769 | realtotalpages = totalpages; | 4769 | zones_size); |
4770 | for (i = 0; i < MAX_NR_ZONES; i++) | 4770 | real_size = size - zone_absent_pages_in_node(pgdat->node_id, i, |
4771 | realtotalpages -= | ||
4772 | zone_absent_pages_in_node(pgdat->node_id, i, | ||
4773 | node_start_pfn, node_end_pfn, | 4771 | node_start_pfn, node_end_pfn, |
4774 | zholes_size); | 4772 | zholes_size); |
4773 | zone->spanned_pages = size; | ||
4774 | zone->present_pages = real_size; | ||
4775 | |||
4776 | totalpages += size; | ||
4777 | realtotalpages += real_size; | ||
4778 | } | ||
4779 | |||
4780 | pgdat->node_spanned_pages = totalpages; | ||
4775 | pgdat->node_present_pages = realtotalpages; | 4781 | pgdat->node_present_pages = realtotalpages; |
4776 | printk(KERN_DEBUG "On node %d totalpages: %lu\n", pgdat->node_id, | 4782 | printk(KERN_DEBUG "On node %d totalpages: %lu\n", pgdat->node_id, |
4777 | realtotalpages); | 4783 | realtotalpages); |
@@ -4881,8 +4887,7 @@ static unsigned long __paginginit calc_memmap_size(unsigned long spanned_pages, | |||
4881 | * NOTE: pgdat should get zeroed by caller. | 4887 | * NOTE: pgdat should get zeroed by caller. |
4882 | */ | 4888 | */ |
4883 | static void __paginginit free_area_init_core(struct pglist_data *pgdat, | 4889 | static void __paginginit free_area_init_core(struct pglist_data *pgdat, |
4884 | unsigned long node_start_pfn, unsigned long node_end_pfn, | 4890 | unsigned long node_start_pfn, unsigned long node_end_pfn) |
4885 | unsigned long *zones_size, unsigned long *zholes_size) | ||
4886 | { | 4891 | { |
4887 | enum zone_type j; | 4892 | enum zone_type j; |
4888 | int nid = pgdat->node_id; | 4893 | int nid = pgdat->node_id; |
@@ -4903,12 +4908,8 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat, | |||
4903 | struct zone *zone = pgdat->node_zones + j; | 4908 | struct zone *zone = pgdat->node_zones + j; |
4904 | unsigned long size, realsize, freesize, memmap_pages; | 4909 | unsigned long size, realsize, freesize, memmap_pages; |
4905 | 4910 | ||
4906 | size = zone_spanned_pages_in_node(nid, j, node_start_pfn, | 4911 | size = zone->spanned_pages; |
4907 | node_end_pfn, zones_size); | 4912 | realsize = freesize = zone->present_pages; |
4908 | realsize = freesize = size - zone_absent_pages_in_node(nid, j, | ||
4909 | node_start_pfn, | ||
4910 | node_end_pfn, | ||
4911 | zholes_size); | ||
4912 | 4913 | ||
4913 | /* | 4914 | /* |
4914 | * Adjust freesize so that it accounts for how much memory | 4915 | * Adjust freesize so that it accounts for how much memory |
@@ -4943,8 +4944,6 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat, | |||
4943 | nr_kernel_pages -= memmap_pages; | 4944 | nr_kernel_pages -= memmap_pages; |
4944 | nr_all_pages += freesize; | 4945 | nr_all_pages += freesize; |
4945 | 4946 | ||
4946 | zone->spanned_pages = size; | ||
4947 | zone->present_pages = realsize; | ||
4948 | /* | 4947 | /* |
4949 | * Set an approximate value for lowmem here, it will be adjusted | 4948 | * Set an approximate value for lowmem here, it will be adjusted |
4950 | * when the bootmem allocator frees pages into the buddy system. | 4949 | * when the bootmem allocator frees pages into the buddy system. |
@@ -5050,8 +5049,7 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size, | |||
5050 | (unsigned long)pgdat->node_mem_map); | 5049 | (unsigned long)pgdat->node_mem_map); |
5051 | #endif | 5050 | #endif |
5052 | 5051 | ||
5053 | free_area_init_core(pgdat, start_pfn, end_pfn, | 5052 | free_area_init_core(pgdat, start_pfn, end_pfn); |
5054 | zones_size, zholes_size); | ||
5055 | } | 5053 | } |
5056 | 5054 | ||
5057 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP | 5055 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP |