diff options
author | Yinghai Lu <yinghai@kernel.org> | 2013-09-06 22:07:09 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-09-10 03:51:34 -0400 |
commit | 6979287a7df66a92d6f308338e972a406f9ef842 (patch) | |
tree | c04cb205eb63143b9d41894e190008fe575ac66d /arch/x86/mm/init.c | |
parent | 816434ec4a674fcdb3c2221a6dffdc8f34020550 (diff) |
x86/mm: Add 'step_size' comments to init_mem_mapping()
Current code uses macro to shift by 5, but there is no explanation
why there's no worry about an overflow there.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Jacob Shin <jacob.shin@amd.com>
Link: http://lkml.kernel.org/r/1378519629-10433-1-git-send-email-yinghai@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/mm/init.c')
-rw-r--r-- | arch/x86/mm/init.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 04664cdb7fda..ce32017c5e38 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c | |||
@@ -399,8 +399,25 @@ static unsigned long __init init_range_memory_mapping( | |||
399 | return mapped_ram_size; | 399 | return mapped_ram_size; |
400 | } | 400 | } |
401 | 401 | ||
402 | /* (PUD_SHIFT-PMD_SHIFT)/2 */ | 402 | static unsigned long __init get_new_step_size(unsigned long step_size) |
403 | #define STEP_SIZE_SHIFT 5 | 403 | { |
404 | /* | ||
405 | * Explain why we shift by 5 and why we don't have to worry about | ||
406 | * 'step_size << 5' overflowing: | ||
407 | * | ||
408 | * initial mapped size is PMD_SIZE (2M). | ||
409 | * We can not set step_size to be PUD_SIZE (1G) yet. | ||
410 | * In worse case, when we cross the 1G boundary, and | ||
411 | * PG_LEVEL_2M is not set, we will need 1+1+512 pages (2M + 8k) | ||
412 | * to map 1G range with PTE. Use 5 as shift for now. | ||
413 | * | ||
414 | * Don't need to worry about overflow, on 32bit, when step_size | ||
415 | * is 0, round_down() returns 0 for start, and that turns it | ||
416 | * into 0x100000000ULL. | ||
417 | */ | ||
418 | return step_size << 5; | ||
419 | } | ||
420 | |||
404 | void __init init_mem_mapping(void) | 421 | void __init init_mem_mapping(void) |
405 | { | 422 | { |
406 | unsigned long end, real_end, start, last_start; | 423 | unsigned long end, real_end, start, last_start; |
@@ -449,7 +466,7 @@ void __init init_mem_mapping(void) | |||
449 | min_pfn_mapped = last_start >> PAGE_SHIFT; | 466 | min_pfn_mapped = last_start >> PAGE_SHIFT; |
450 | /* only increase step_size after big range get mapped */ | 467 | /* only increase step_size after big range get mapped */ |
451 | if (new_mapped_ram_size > mapped_ram_size) | 468 | if (new_mapped_ram_size > mapped_ram_size) |
452 | step_size <<= STEP_SIZE_SHIFT; | 469 | step_size = get_new_step_size(step_size); |
453 | mapped_ram_size += new_mapped_ram_size; | 470 | mapped_ram_size += new_mapped_ram_size; |
454 | } | 471 | } |
455 | 472 | ||