aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorZhang Yanfei <zhangyanfei@cn.fujitsu.com>2013-07-08 18:59:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-09 13:33:20 -0400
commit7960aedde8cfa72e4caf488806ea7ea7d2fa8dba (patch)
tree1d565e1ae9f59f7dfedff57bb30afbaec251d669 /mm
parent609838cfed972d49a65aac7923a9ff5cbe482e30 (diff)
mm: remove duplicated call of get_pfn_range_for_nid
When calculating pages in a node, for each zone in that node, we will have zone_spanned_pages_in_node --> get_pfn_range_for_nid zone_absent_pages_in_node --> get_pfn_range_for_nid That is to say, we call the get_pfn_range_for_nid to get start_pfn and end_pfn of the node for MAX_NR_ZONES * 2 times. And this is totally unnecessary if we call the get_pfn_range_for_nid before zone_*_pages_in_node add two extra arguments node_start_pfn and node_end_pfn for zone_*_pages_in_node, then we can remove the get_pfn_range_in_node in zone_*_pages_in_node. [akpm@linux-foundation.org: make definitions more readable] Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Cc: Michal Hocko <mhocko@suse.cz> Cc: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/page_alloc.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 327516b7aee9..7d5e40fe0c29 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4421,13 +4421,13 @@ static void __meminit adjust_zone_range_for_zone_movable(int nid,
4421 */ 4421 */
4422static unsigned long __meminit zone_spanned_pages_in_node(int nid, 4422static unsigned long __meminit zone_spanned_pages_in_node(int nid,
4423 unsigned long zone_type, 4423 unsigned long zone_type,
4424 unsigned long node_start_pfn,
4425 unsigned long node_end_pfn,
4424 unsigned long *ignored) 4426 unsigned long *ignored)
4425{ 4427{
4426 unsigned long node_start_pfn, node_end_pfn;
4427 unsigned long zone_start_pfn, zone_end_pfn; 4428 unsigned long zone_start_pfn, zone_end_pfn;
4428 4429
4429 /* Get the start and end of the node and zone */ 4430 /* Get the start and end of the zone */
4430 get_pfn_range_for_nid(nid, &node_start_pfn, &node_end_pfn);
4431 zone_start_pfn = arch_zone_lowest_possible_pfn[zone_type]; 4431 zone_start_pfn = arch_zone_lowest_possible_pfn[zone_type];
4432 zone_end_pfn = arch_zone_highest_possible_pfn[zone_type]; 4432 zone_end_pfn = arch_zone_highest_possible_pfn[zone_type];
4433 adjust_zone_range_for_zone_movable(nid, zone_type, 4433 adjust_zone_range_for_zone_movable(nid, zone_type,
@@ -4482,14 +4482,14 @@ unsigned long __init absent_pages_in_range(unsigned long start_pfn,
4482/* Return the number of page frames in holes in a zone on a node */ 4482/* Return the number of page frames in holes in a zone on a node */
4483static unsigned long __meminit zone_absent_pages_in_node(int nid, 4483static unsigned long __meminit zone_absent_pages_in_node(int nid,
4484 unsigned long zone_type, 4484 unsigned long zone_type,
4485 unsigned long node_start_pfn,
4486 unsigned long node_end_pfn,
4485 unsigned long *ignored) 4487 unsigned long *ignored)
4486{ 4488{
4487 unsigned long zone_low = arch_zone_lowest_possible_pfn[zone_type]; 4489 unsigned long zone_low = arch_zone_lowest_possible_pfn[zone_type];
4488 unsigned long zone_high = arch_zone_highest_possible_pfn[zone_type]; 4490 unsigned long zone_high = arch_zone_highest_possible_pfn[zone_type];
4489 unsigned long node_start_pfn, node_end_pfn;
4490 unsigned long zone_start_pfn, zone_end_pfn; 4491 unsigned long zone_start_pfn, zone_end_pfn;
4491 4492
4492 get_pfn_range_for_nid(nid, &node_start_pfn, &node_end_pfn);
4493 zone_start_pfn = clamp(node_start_pfn, zone_low, zone_high); 4493 zone_start_pfn = clamp(node_start_pfn, zone_low, zone_high);
4494 zone_end_pfn = clamp(node_end_pfn, zone_low, zone_high); 4494 zone_end_pfn = clamp(node_end_pfn, zone_low, zone_high);
4495 4495
@@ -4502,6 +4502,8 @@ static unsigned long __meminit zone_absent_pages_in_node(int nid,
4502#else /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ 4502#else /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
4503static inline unsigned long __meminit zone_spanned_pages_in_node(int nid, 4503static inline unsigned long __meminit zone_spanned_pages_in_node(int nid,
4504 unsigned long zone_type, 4504 unsigned long zone_type,
4505 unsigned long node_start_pfn,
4506 unsigned long node_end_pfn,
4505 unsigned long *zones_size) 4507 unsigned long *zones_size)
4506{ 4508{
4507 return zones_size[zone_type]; 4509 return zones_size[zone_type];
@@ -4509,6 +4511,8 @@ static inline unsigned long __meminit zone_spanned_pages_in_node(int nid,
4509 4511
4510static inline unsigned long __meminit zone_absent_pages_in_node(int nid, 4512static inline unsigned long __meminit zone_absent_pages_in_node(int nid,
4511 unsigned long zone_type, 4513 unsigned long zone_type,
4514 unsigned long node_start_pfn,
4515 unsigned long node_end_pfn,
4512 unsigned long *zholes_size) 4516 unsigned long *zholes_size)
4513{ 4517{
4514 if (!zholes_size) 4518 if (!zholes_size)
@@ -4520,21 +4524,27 @@ static inline unsigned long __meminit zone_absent_pages_in_node(int nid,
4520#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ 4524#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
4521 4525
4522static void __meminit calculate_node_totalpages(struct pglist_data *pgdat, 4526static void __meminit calculate_node_totalpages(struct pglist_data *pgdat,
4523 unsigned long *zones_size, unsigned long *zholes_size) 4527 unsigned long node_start_pfn,
4528 unsigned long node_end_pfn,
4529 unsigned long *zones_size,
4530 unsigned long *zholes_size)
4524{ 4531{
4525 unsigned long realtotalpages, totalpages = 0; 4532 unsigned long realtotalpages, totalpages = 0;
4526 enum zone_type i; 4533 enum zone_type i;
4527 4534
4528 for (i = 0; i < MAX_NR_ZONES; i++) 4535 for (i = 0; i < MAX_NR_ZONES; i++)
4529 totalpages += zone_spanned_pages_in_node(pgdat->node_id, i, 4536 totalpages += zone_spanned_pages_in_node(pgdat->node_id, i,
4530 zones_size); 4537 node_start_pfn,
4538 node_end_pfn,
4539 zones_size);
4531 pgdat->node_spanned_pages = totalpages; 4540 pgdat->node_spanned_pages = totalpages;
4532 4541
4533 realtotalpages = totalpages; 4542 realtotalpages = totalpages;
4534 for (i = 0; i < MAX_NR_ZONES; i++) 4543 for (i = 0; i < MAX_NR_ZONES; i++)
4535 realtotalpages -= 4544 realtotalpages -=
4536 zone_absent_pages_in_node(pgdat->node_id, i, 4545 zone_absent_pages_in_node(pgdat->node_id, i,
4537 zholes_size); 4546 node_start_pfn, node_end_pfn,
4547 zholes_size);
4538 pgdat->node_present_pages = realtotalpages; 4548 pgdat->node_present_pages = realtotalpages;
4539 printk(KERN_DEBUG "On node %d totalpages: %lu\n", pgdat->node_id, 4549 printk(KERN_DEBUG "On node %d totalpages: %lu\n", pgdat->node_id,
4540 realtotalpages); 4550 realtotalpages);
@@ -4643,6 +4653,7 @@ static unsigned long __paginginit calc_memmap_size(unsigned long spanned_pages,
4643 * NOTE: pgdat should get zeroed by caller. 4653 * NOTE: pgdat should get zeroed by caller.
4644 */ 4654 */
4645static void __paginginit free_area_init_core(struct pglist_data *pgdat, 4655static void __paginginit free_area_init_core(struct pglist_data *pgdat,
4656 unsigned long node_start_pfn, unsigned long node_end_pfn,
4646 unsigned long *zones_size, unsigned long *zholes_size) 4657 unsigned long *zones_size, unsigned long *zholes_size)
4647{ 4658{
4648 enum zone_type j; 4659 enum zone_type j;
@@ -4664,8 +4675,11 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat,
4664 struct zone *zone = pgdat->node_zones + j; 4675 struct zone *zone = pgdat->node_zones + j;
4665 unsigned long size, realsize, freesize, memmap_pages; 4676 unsigned long size, realsize, freesize, memmap_pages;
4666 4677
4667 size = zone_spanned_pages_in_node(nid, j, zones_size); 4678 size = zone_spanned_pages_in_node(nid, j, node_start_pfn,
4679 node_end_pfn, zones_size);
4668 realsize = freesize = size - zone_absent_pages_in_node(nid, j, 4680 realsize = freesize = size - zone_absent_pages_in_node(nid, j,
4681 node_start_pfn,
4682 node_end_pfn,
4669 zholes_size); 4683 zholes_size);
4670 4684
4671 /* 4685 /*
@@ -4779,6 +4793,8 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size,
4779 unsigned long node_start_pfn, unsigned long *zholes_size) 4793 unsigned long node_start_pfn, unsigned long *zholes_size)
4780{ 4794{
4781 pg_data_t *pgdat = NODE_DATA(nid); 4795 pg_data_t *pgdat = NODE_DATA(nid);
4796 unsigned long start_pfn = 0;
4797 unsigned long end_pfn = 0;
4782 4798
4783 /* pg_data_t should be reset to zero when it's allocated */ 4799 /* pg_data_t should be reset to zero when it's allocated */
4784 WARN_ON(pgdat->nr_zones || pgdat->classzone_idx); 4800 WARN_ON(pgdat->nr_zones || pgdat->classzone_idx);
@@ -4786,7 +4802,11 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size,
4786 pgdat->node_id = nid; 4802 pgdat->node_id = nid;
4787 pgdat->node_start_pfn = node_start_pfn; 4803 pgdat->node_start_pfn = node_start_pfn;
4788 init_zone_allows_reclaim(nid); 4804 init_zone_allows_reclaim(nid);
4789 calculate_node_totalpages(pgdat, zones_size, zholes_size); 4805#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
4806 get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
4807#endif
4808 calculate_node_totalpages(pgdat, start_pfn, end_pfn,
4809 zones_size, zholes_size);
4790 4810
4791 alloc_node_mem_map(pgdat); 4811 alloc_node_mem_map(pgdat);
4792#ifdef CONFIG_FLAT_NODE_MEM_MAP 4812#ifdef CONFIG_FLAT_NODE_MEM_MAP
@@ -4795,7 +4815,8 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size,
4795 (unsigned long)pgdat->node_mem_map); 4815 (unsigned long)pgdat->node_mem_map);
4796#endif 4816#endif
4797 4817
4798 free_area_init_core(pgdat, zones_size, zholes_size); 4818 free_area_init_core(pgdat, start_pfn, end_pfn,
4819 zones_size, zholes_size);
4799} 4820}
4800 4821
4801#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP 4822#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP