Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753038Ab0ALHrL (ORCPT ); Tue, 12 Jan 2010 02:47:11 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751095Ab0ALHrJ (ORCPT ); Tue, 12 Jan 2010 02:47:09 -0500 Received: from mga02.intel.com ([134.134.136.20]:30938 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752113Ab0ALHrI (ORCPT ); Tue, 12 Jan 2010 02:47:08 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.49,261,1262592000"; d="scan'208";a="483272030" From: "Zheng, Shaohui" To: "linux-mm@kvack.org" , "akpm@linux-foundation.org" CC: "linux-kernel@vger.kernel.org" , "ak@linux.intel.com" , "y-goto@jp.fujitsu.com" , Dave Hansen , "x86@kernel.org" , KAMEZAWA Hiroyuki Date: Tue, 12 Jan 2010 15:45:54 +0800 Subject: [ RESEND PATCH v3] Memory-Hotplug: Fix the bug on interface /dev/mem for 64-bit kernel Thread-Topic: [ RESEND PATCH v3] Memory-Hotplug: Fix the bug on interface /dev/mem for 64-bit kernel Thread-Index: AcqTW0U4V9wp3/wXQwG7gYUYaTUX1Q== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: multipart/mixed; boundary="_002_DA586906BA1FFC4384FCFD6429ECE860316C0133shzsmsx502ccrco_" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7183 Lines: 163 --_002_DA586906BA1FFC4384FCFD6429ECE860316C0133shzsmsx502ccrco_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Resend the v3 patch after reviewed by KAMEZAWA Hiroyuki. We still keep the= =20 Old e820map, update variable max_pfn, max_low_pfn and high_memory only.=20 It is dependent on Fenguang's page_is_ram patch. Memory-Hotplug: Fix the bug on interface /dev/mem for 64-bit kernel The new added memory can not be access by interface /dev/mem, because we do= not update the variable high_memory, max_pfn and max_low_pfn. Memory hotplug still has critical issues for 32-bit kernel, and it is more= =20 important for 64-bit kernel, we fix it on 64-bit first. We add a function=20 update_end_of_memory_vars in file arch/x86/mm/init.c to update these variab= les. CC: Andi Kleen CC: Li Haicheng Reviewed-by: Wu Fengguang Reviewed-by: KAMEZAWA Hiroyuki Signed-off-by: Shaohui Zheng diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index d406c52..b6a85cc 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -1,6 +1,7 @@ #include #include #include +#include =20 #include #include @@ -386,3 +387,24 @@ void free_initrd_mem(unsigned long start, unsigned lon= g end) free_init_pages("initrd memory", start, end); } #endif + +/** + * After memory hotplug, the variable max_pfn, max_low_pfn and high_memory= will + * be affected, it will be updated in this function. Memory hotplug still = has + * critical issues on 32-bit kennel, it was more important on 64-bit kerne= l, + * so we update the variables for 64-bit kernel first, fix me in future fo= r + * 32-bit kenrel. + */ +void __meminit __attribute__((weak)) update_end_of_memory_vars(u64 start, + u64 size) +{ +#ifdef CONFIG_X86_64 + unsigned long start_pfn =3D start >> PAGE_SHIFT; + unsigned long end_pfn =3D PFN_UP(start + size); + + if (end_pfn > max_pfn) { + max_low_pfn =3D max_pfn =3D end_pfn; + high_memory =3D (void *)__va(max_pfn * PAGE_SIZE - 1) + 1; + } +#endif /* CONFIG_X86_64 */ +} diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h index b10ec49..84533a5 100644 --- a/include/linux/bootmem.h +++ b/include/linux/bootmem.h @@ -13,6 +13,7 @@ =20 extern unsigned long max_low_pfn; extern unsigned long min_low_pfn; +extern void update_end_of_memory_vars(u64 start, u64 size); =20 /* * highest page diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 030ce8a..3e94b23 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -523,6 +523,9 @@ int __ref add_memory(int nid, u64 start, u64 size) BUG_ON(ret); } =20 + /* update max_pfn, max_low_pfn and high_memory */ + update_end_of_memory_vars(start, size); + goto out; =20 error: Thanks & Regards, Shaohui --_002_DA586906BA1FFC4384FCFD6429ECE860316C0133shzsmsx502ccrco_ Content-Type: application/octet-stream; name="memory-hotplug-fix-the-bug-on-interface-dev-mem-v3.patch" Content-Description: memory-hotplug-fix-the-bug-on-interface-dev-mem-v3.patch Content-Disposition: attachment; filename="memory-hotplug-fix-the-bug-on-interface-dev-mem-v3.patch"; size=2529; creation-date="Tue, 12 Jan 2010 15:40:51 GMT"; modification-date="Tue, 12 Jan 2010 23:21:09 GMT" Content-Transfer-Encoding: base64 TWVtb3J5LUhvdHBsdWc6IEZpeCB0aGUgYnVnIG9uIGludGVyZmFjZSAvZGV2L21lbSBmb3IgNjQt Yml0IGtlcm5lbAoKVGhlIG5ldyBhZGRlZCBtZW1vcnkgY2FuIG5vdCBiZSBhY2Nlc3MgYnkgaW50 ZXJmYWNlIC9kZXYvbWVtLCBiZWNhdXNlIHdlIGRvIG5vdAogdXBkYXRlIHRoZSB2YXJpYWJsZSBo aWdoX21lbW9yeSwgbWF4X3BmbiBhbmQgbWF4X2xvd19wZm4uCgpNZW1vcnkgaG90cGx1ZyBzdGls bCBoYXMgY3JpdGljYWwgaXNzdWVzIGZvciAzMi1iaXQga2VybmVsLCBhbmQgaXQgaXMgbW9yZSAK aW1wb3J0YW50IGZvciA2NC1iaXQga2VybmVsLCB3ZSBmaXggaXQgb24gNjQtYml0IGZpcnN0LiBX ZSBhZGQgYSBmdW5jdGlvbiAKdXBkYXRlX2VuZF9vZl9tZW1vcnlfdmFycyBpbiBmaWxlIGFyY2gv eDg2L21tL2luaXQuYyB0byB1cGRhdGUgdGhlc2UgdmFyaWFibGVzLgoKU2lnbmVkLW9mZi1ieTog U2hhb2h1aSBaaGVuZyA8c2hhb2h1aS56aGVuZ0BpbnRlbC5jb20+CkNDOiBBbmRpIEtsZ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ZV9lbmRfb2ZfbWVtb3J5X3ZhcnModTY0IHN0YXJ0LCB1NjQgc2l6ZSk7CiAKIC8qCiAg KiBoaWdoZXN0IHBhZ2UKZGlmZiAtLWdpdCBhL21tL21lbW9yeV9ob3RwbHVnLmMgYi9tbS9tZW1v cnlfaG90cGx1Zy5jCmluZGV4IDAzMGNlOGEuLjNlOTRiMjMgMTAwNjQ0Ci0tLSBhL21tL21lbW9y eV9ob3RwbHVnLmMKKysrIGIvbW0vbWVtb3J5X2hvdHBsdWcuYwpAQCAtNTIzLDYgKzUyMyw5IEBA IGludCBfX3JlZiBhZGRfbWVtb3J5KGludCBuaWQsIHU2NCBzdGFydCwgdTY0IHNpemUpCiAJCUJV R19PTihyZXQpOwogCX0KIAorCS8qIHVwZGF0ZSBtYXhfcGZuLCBtYXhfbG93X3BmbiBhbmQgaGln aF9tZW1vcnkgKi8KKwl1cGRhdGVfZW5kX29mX21lbW9yeV92YXJzKHN0YXJ0LCBzaXplKTsKKwog CWdvdG8gb3V0OwogCiBlcnJvcjoK --_002_DA586906BA1FFC4384FCFD6429ECE860316C0133shzsmsx502ccrco_-- -- 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/