Skip to content

Commit

Permalink
x86, mm: use round_up/down in split_mem_range()
Browse files Browse the repository at this point in the history
to replace own inline version for those roundup and rounddown.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/1353123563-3103-36-git-send-email-yinghai@kernel.org
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
  • Loading branch information
Yinghai Lu authored and H. Peter Anvin committed Nov 17, 2012
1 parent 11ed9e9 commit 5a0d3ae
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions arch/x86/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,11 @@ static int __meminit split_mem_range(struct map_range *mr, int nr_range,
* slowdowns.
*/
if (pos == 0)
end_pfn = 1<<(PMD_SHIFT - PAGE_SHIFT);
end_pfn = PMD_SIZE >> PAGE_SHIFT;
else
end_pfn = ((pos + (PMD_SIZE - 1))>>PMD_SHIFT)
<< (PMD_SHIFT - PAGE_SHIFT);
end_pfn = round_up(pos, PMD_SIZE) >> PAGE_SHIFT;
#else /* CONFIG_X86_64 */
end_pfn = ((pos + (PMD_SIZE - 1)) >> PMD_SHIFT)
<< (PMD_SHIFT - PAGE_SHIFT);
end_pfn = round_up(pos, PMD_SIZE) >> PAGE_SHIFT;
#endif
if (end_pfn > (end >> PAGE_SHIFT))
end_pfn = end >> PAGE_SHIFT;
Expand All @@ -234,15 +232,13 @@ static int __meminit split_mem_range(struct map_range *mr, int nr_range,
}

/* big page (2M) range */
start_pfn = ((pos + (PMD_SIZE - 1))>>PMD_SHIFT)
<< (PMD_SHIFT - PAGE_SHIFT);
start_pfn = round_up(pos, PMD_SIZE) >> PAGE_SHIFT;
#ifdef CONFIG_X86_32
end_pfn = (end>>PMD_SHIFT) << (PMD_SHIFT - PAGE_SHIFT);
end_pfn = round_down(end, PMD_SIZE) >> PAGE_SHIFT;
#else /* CONFIG_X86_64 */
end_pfn = ((pos + (PUD_SIZE - 1))>>PUD_SHIFT)
<< (PUD_SHIFT - PAGE_SHIFT);
if (end_pfn > ((end>>PMD_SHIFT)<<(PMD_SHIFT - PAGE_SHIFT)))
end_pfn = ((end>>PMD_SHIFT)<<(PMD_SHIFT - PAGE_SHIFT));
end_pfn = round_up(pos, PUD_SIZE) >> PAGE_SHIFT;
if (end_pfn > (round_down(end, PMD_SIZE) >> PAGE_SHIFT))
end_pfn = round_down(end, PMD_SIZE) >> PAGE_SHIFT;
#endif

if (start_pfn < end_pfn) {
Expand All @@ -253,9 +249,8 @@ static int __meminit split_mem_range(struct map_range *mr, int nr_range,

#ifdef CONFIG_X86_64
/* big page (1G) range */
start_pfn = ((pos + (PUD_SIZE - 1))>>PUD_SHIFT)
<< (PUD_SHIFT - PAGE_SHIFT);
end_pfn = (end >> PUD_SHIFT) << (PUD_SHIFT - PAGE_SHIFT);
start_pfn = round_up(pos, PUD_SIZE) >> PAGE_SHIFT;
end_pfn = round_down(end, PUD_SIZE) >> PAGE_SHIFT;
if (start_pfn < end_pfn) {
nr_range = save_mr(mr, nr_range, start_pfn, end_pfn,
page_size_mask &
Expand All @@ -264,9 +259,8 @@ static int __meminit split_mem_range(struct map_range *mr, int nr_range,
}

/* tail is not big page (1G) alignment */
start_pfn = ((pos + (PMD_SIZE - 1))>>PMD_SHIFT)
<< (PMD_SHIFT - PAGE_SHIFT);
end_pfn = (end >> PMD_SHIFT) << (PMD_SHIFT - PAGE_SHIFT);
start_pfn = round_up(pos, PMD_SIZE) >> PAGE_SHIFT;
end_pfn = round_down(end, PMD_SIZE) >> PAGE_SHIFT;
if (start_pfn < end_pfn) {
nr_range = save_mr(mr, nr_range, start_pfn, end_pfn,
page_size_mask & (1<<PG_LEVEL_2M));
Expand Down

0 comments on commit 5a0d3ae

Please sign in to comment.