Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756048Ab3EIP5r (ORCPT ); Thu, 9 May 2013 11:57:47 -0400 Received: from mail-pb0-f48.google.com ([209.85.160.48]:39518 "EHLO mail-pb0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754050Ab3EIP5q (ORCPT ); Thu, 9 May 2013 11:57:46 -0400 Message-ID: <518BC776.7010506@gmail.com> Date: Thu, 09 May 2013 23:57:42 +0800 From: Zhang Yanfei User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130404 Thunderbird/17.0.5 MIME-Version: 1.0 To: "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , Yinghai Lu , Andrew Morton CC: Yasuaki Ishimatsu , Konrad Rzeszutek Wilk , linux-kernel@vger.kernel.org Subject: [PATCH] x86: mm: Add missing comments for initial kernel direct mapping Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2688 Lines: 66 From: Zhang Yanfei For some reason, comments below are lost: - comments for init_range_memory_mapping() - comments in init_mem_mapping that is helpful for reminding people that the pagetable is setup top-down The comments were written by Yinghai in his patch in https://lkml.org/lkml/2012/11/28/620 Signed-off-by: Zhang Yanfei Signed-off-by: Yinghai Lu Cc: "H. Peter Anvin" Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Konrad Rzeszutek Wilk Cc: Andrew Morton Cc: Yasuaki Ishimatsu --- arch/x86/mm/init.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index fdc5dca..fed9993 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -359,7 +359,17 @@ unsigned long __init_refok init_memory_mapping(unsigned long start, } /* - * would have hole in the middle or ends, and only ram parts will be mapped. + * We need to iterate through E820 memory map and create direct mappings + * for only E820_RAM and E820_KERN_RESERVED regions. We cannot simply + * create direct mappings for all pfns from [0 to max_low_pfn) and + * [4GB to max_pfn) because of possible memory holes in high addresses + * that cannot be marked as UC by fixed/variable range MTRRs. + * Depending on the alignment of E820 ranges, this may possibly result + * in using smaller size (i.e. 4K instead of 2M or 1G) page tables. + * + * init_mem_mapping call init_range_memory_mapping with big range. + * That range would have hole in the middle or ends, and only ram parts + * will be mapped in init_range_memory_mapping. */ static unsigned long __init init_range_memory_mapping( unsigned long r_start, @@ -419,6 +429,13 @@ void __init init_mem_mapping(void) max_pfn_mapped = 0; /* will get exact value next */ min_pfn_mapped = real_end >> PAGE_SHIFT; last_start = start = real_end; + + /* + * We start from the top (end of memory) and go to the bottom. + * The memblock_find_in_range gets us a block of RAM from the + * end of RAM in [min_pfn_mapped, max_pfn_mapped) as new pages + * for page table. + */ while (last_start > ISA_END_ADDRESS) { if (last_start > step_size) { start = round_down(last_start - 1, step_size); -- 1.8.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/