diff options
author | Tejun Heo <tj@kernel.org> | 2011-07-12 04:46:29 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2011-07-14 14:45:30 -0400 |
commit | 96e907d1360240d1958fe8ce3a3ac640733330d4 (patch) | |
tree | ac1fec297f9b6d620a76dc0cd0476b74bc628a95 /mm/page_alloc.c | |
parent | 5dfe8660a3d7f1ee1265c3536433ee53da3f98a3 (diff) |
bootmem: Reimplement __absent_pages_in_range() using for_each_mem_pfn_range()
__absent_pages_in_range() was needlessly complex. Reimplement it
using for_each_mem_pfn_range().
Also, update zone_absent_pages_in_node() such that it doesn't call
__absent_pages_in_range() with @zone_start_pfn which is larger than
@zone_end_pfn.
Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1310460395-30913-3-git-send-email-tj@kernel.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 54 |
1 files changed, 12 insertions, 42 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 69fffabf61b7..3092a97268d1 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -4044,46 +4044,16 @@ unsigned long __meminit __absent_pages_in_range(int nid, | |||
4044 | unsigned long range_start_pfn, | 4044 | unsigned long range_start_pfn, |
4045 | unsigned long range_end_pfn) | 4045 | unsigned long range_end_pfn) |
4046 | { | 4046 | { |
4047 | int i = 0; | 4047 | unsigned long nr_absent = range_end_pfn - range_start_pfn; |
4048 | unsigned long prev_end_pfn = 0, hole_pages = 0; | 4048 | unsigned long start_pfn, end_pfn; |
4049 | unsigned long start_pfn; | 4049 | int i; |
4050 | |||
4051 | /* Find the end_pfn of the first active range of pfns in the node */ | ||
4052 | i = first_active_region_index_in_nid(nid); | ||
4053 | if (i == -1) | ||
4054 | return 0; | ||
4055 | |||
4056 | prev_end_pfn = min(early_node_map[i].start_pfn, range_end_pfn); | ||
4057 | |||
4058 | /* Account for ranges before physical memory on this node */ | ||
4059 | if (early_node_map[i].start_pfn > range_start_pfn) | ||
4060 | hole_pages = prev_end_pfn - range_start_pfn; | ||
4061 | |||
4062 | /* Find all holes for the zone within the node */ | ||
4063 | for (; i != -1; i = next_active_region_index_in_nid(i, nid)) { | ||
4064 | |||
4065 | /* No need to continue if prev_end_pfn is outside the zone */ | ||
4066 | if (prev_end_pfn >= range_end_pfn) | ||
4067 | break; | ||
4068 | |||
4069 | /* Make sure the end of the zone is not within the hole */ | ||
4070 | start_pfn = min(early_node_map[i].start_pfn, range_end_pfn); | ||
4071 | prev_end_pfn = max(prev_end_pfn, range_start_pfn); | ||
4072 | 4050 | ||
4073 | /* Update the hole size cound and move on */ | 4051 | for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) { |
4074 | if (start_pfn > range_start_pfn) { | 4052 | start_pfn = clamp(start_pfn, range_start_pfn, range_end_pfn); |
4075 | BUG_ON(prev_end_pfn > start_pfn); | 4053 | end_pfn = clamp(end_pfn, range_start_pfn, range_end_pfn); |
4076 | hole_pages += start_pfn - prev_end_pfn; | 4054 | nr_absent -= end_pfn - start_pfn; |
4077 | } | ||
4078 | prev_end_pfn = early_node_map[i].end_pfn; | ||
4079 | } | 4055 | } |
4080 | 4056 | return nr_absent; | |
4081 | /* Account for ranges past physical memory on this node */ | ||
4082 | if (range_end_pfn > prev_end_pfn) | ||
4083 | hole_pages += range_end_pfn - | ||
4084 | max(range_start_pfn, prev_end_pfn); | ||
4085 | |||
4086 | return hole_pages; | ||
4087 | } | 4057 | } |
4088 | 4058 | ||
4089 | /** | 4059 | /** |
@@ -4104,14 +4074,14 @@ static unsigned long __meminit zone_absent_pages_in_node(int nid, | |||
4104 | unsigned long zone_type, | 4074 | unsigned long zone_type, |
4105 | unsigned long *ignored) | 4075 | unsigned long *ignored) |
4106 | { | 4076 | { |
4077 | unsigned long zone_low = arch_zone_lowest_possible_pfn[zone_type]; | ||
4078 | unsigned long zone_high = arch_zone_highest_possible_pfn[zone_type]; | ||
4107 | unsigned long node_start_pfn, node_end_pfn; | 4079 | unsigned long node_start_pfn, node_end_pfn; |
4108 | unsigned long zone_start_pfn, zone_end_pfn; | 4080 | unsigned long zone_start_pfn, zone_end_pfn; |
4109 | 4081 | ||
4110 | get_pfn_range_for_nid(nid, &node_start_pfn, &node_end_pfn); | 4082 | get_pfn_range_for_nid(nid, &node_start_pfn, &node_end_pfn); |
4111 | zone_start_pfn = max(arch_zone_lowest_possible_pfn[zone_type], | 4083 | zone_start_pfn = clamp(node_start_pfn, zone_low, zone_high); |
4112 | node_start_pfn); | 4084 | zone_end_pfn = clamp(node_end_pfn, zone_low, zone_high); |
4113 | zone_end_pfn = min(arch_zone_highest_possible_pfn[zone_type], | ||
4114 | node_end_pfn); | ||
4115 | 4085 | ||
4116 | adjust_zone_range_for_zone_movable(nid, zone_type, | 4086 | adjust_zone_range_for_zone_movable(nid, zone_type, |
4117 | node_start_pfn, node_end_pfn, | 4087 | node_start_pfn, node_end_pfn, |