linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [Patch - Resend v4] Memory-Hotplug: Fix the bug on interface /dev/mem for 64-bit kernel
@ 2010-02-01  4:12 Shaohui Zheng
  2010-02-01  4:41 ` Wu Fengguang
  0 siblings, 1 reply; 3+ messages in thread
From: Shaohui Zheng @ 2010-02-01  4:12 UTC (permalink / raw)
  To: akpm, linux-mm
  Cc: linux-kernel, y-goto, haveblue, kamezawa.hiroyu, ak, fengguang.wu,
	hpa, haicheng.li, shaohui.zheng

[-- Attachment #1: Type: text/plain, Size: 2957 bytes --]

Send the v4 patch to mailing list.

changelog:
v1: add memory range to e820 table, and update the varibles max_pfn/max_low_pfn/high_memory
	Peter[hpa]: memory hotplug make sense on 32-bit kernel for virtual environment.
	Andi[ak]: No VM supports it currently, and 64bit is the important part for hotplug 
	Fengguang[wfg]: some review comments on function naming
v2: rename function update_pfn to update_end_of_memory_vars
	KAMEZAWA[kame]: e820map is considerted to be stable, read-only after boot.
	Fengguang[wfg]: rewrite function page_is_ram, make it friendly for hotplug.
v3: keep the old e820map, update the varible max_pfn, high_memory only
	KAMEZAWA[kame]: suggest to use memory hotplug notifier. If it's allowed, it will
					be cleaner.
	Fengguang[wfg]: notifier is for _outsider_ subsystems. It smells a bit overkill to do 
					notifier _inside_ the hotplug code.
	Fengguang[wfg]: suggest to update max_pfn/max_low_pfn/high_memory in arch/x86/mm/init_64.c:
					arch_add_memory() now, for X86_64.  
					Later on we can add code to arch/x86/mm/init_32.c:arch_add_memory() for X86_32.
v4: update max_pfn/max_low_pfn/high_memory in arch/x86/mm/init_64.c:arch_add_memory() for x86_64,
	 and resent it to mailing list, since fengguang's page_is_ram patch was accepted,


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 variables high_memory, max_pfn and max_low_pfn.

Add a function update_end_of_memory_vars to update these variables for 64-bit 
kernel.

CC: Andi Kleen <ak@linux.intel.com>
CC: Li Haicheng <haicheng.li@intel.com>
Reviewed-by: Wu Fengguang <fengguang.wu@intel.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Shaohui Zheng <shaohui.zheng@intel.com>
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 5a4398a..acfc01a 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -49,6 +49,7 @@
 #include <asm/numa.h>
 #include <asm/cacheflush.h>
 #include <asm/init.h>
+#include <linux/bootmem.h>
 
 static unsigned long dma_reserve __initdata;
 
@@ -614,6 +615,21 @@ void __init paging_init(void)
  * Memory hotplug specific functions
  */
 #ifdef CONFIG_MEMORY_HOTPLUG
+/**
+ * After memory hotplug, the variable max_pfn, max_low_pfn and high_memory will
+ * be affected, it will be updated in this function.
+ */
+static inline void __meminit update_end_of_memory_vars(u64 start,
+		u64 size)
+{
+	unsigned long end_pfn = PFN_UP(start + size);
+
+	if (end_pfn > max_pfn) {
+		max_low_pfn = max_pfn = end_pfn;
+		high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;
+	}
+}
+
 /*
  * Memory is added always to NORMAL zone. This means you will never get
  * additional DMA/DMA32 memory.
@@ -633,6 +649,9 @@ int arch_add_memory(int nid, u64 start, u64 size)
 	ret = __add_pages(nid, zone, start_pfn, nr_pages);
 	WARN_ON_ONCE(ret);
-- 
Thanks & Regards,
Shaohuki


[-- Attachment #2: memory-hotplug-fix-the-bug-on-interface-dev-mem-v4.patch --]
[-- Type: text/x-diff, Size: 1800 bytes --]

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 variables high_memory, max_pfn and max_low_pfn.

Add a function update_end_of_memory_vars to update these variables for 64-bit 
kernel.

CC: Andi Kleen <ak@linux.intel.com>
CC: Li Haicheng <haicheng.li@intel.com>
Reviewed-by: Wu Fengguang <fengguang.wu@intel.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Shaohui Zheng <shaohui.zheng@intel.com>
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 5a4398a..acfc01a 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -49,6 +49,7 @@
 #include <asm/numa.h>
 #include <asm/cacheflush.h>
 #include <asm/init.h>
+#include <linux/bootmem.h>
 
 static unsigned long dma_reserve __initdata;
 
@@ -614,6 +615,21 @@ void __init paging_init(void)
  * Memory hotplug specific functions
  */
 #ifdef CONFIG_MEMORY_HOTPLUG
+/**
+ * After memory hotplug, the variable max_pfn, max_low_pfn and high_memory will
+ * be affected, it will be updated in this function.
+ */
+static inline void __meminit update_end_of_memory_vars(u64 start,
+		u64 size)
+{
+	unsigned long end_pfn = PFN_UP(start + size);
+
+	if (end_pfn > max_pfn) {
+		max_low_pfn = max_pfn = end_pfn;
+		high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;
+	}
+}
+
 /*
  * Memory is added always to NORMAL zone. This means you will never get
  * additional DMA/DMA32 memory.
@@ -633,6 +649,9 @@ int arch_add_memory(int nid, u64 start, u64 size)
 	ret = __add_pages(nid, zone, start_pfn, nr_pages);
 	WARN_ON_ONCE(ret);
 
+	/* update max_pfn, max_low_pfn and high_memory */
+	update_end_of_memory_vars(start, size);
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(arch_add_memory);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch - Resend v4] Memory-Hotplug: Fix the bug on interface /dev/mem for 64-bit kernel
  2010-02-01  4:12 [Patch - Resend v4] Memory-Hotplug: Fix the bug on interface /dev/mem for 64-bit kernel Shaohui Zheng
@ 2010-02-01  4:41 ` Wu Fengguang
  2010-02-01 12:22   ` Shaohui Zheng
  0 siblings, 1 reply; 3+ messages in thread
From: Wu Fengguang @ 2010-02-01  4:41 UTC (permalink / raw)
  To: akpm, linux-mm, linux-kernel, y-goto, haveblue, kamezawa.hiroyu,
	ak, hpa, haicheng.li, shaohui.zheng

Shaohui,

Some style nitpicks..

>  #ifdef CONFIG_MEMORY_HOTPLUG
> +/**

Should use /* here. 

> + * After memory hotplug, the variable max_pfn, max_low_pfn and high_memory will
> + * be affected, it will be updated in this function.
> + */
> +static inline void __meminit update_end_of_memory_vars(u64 start,

The "inline" and "__meminit" are both redundant here.

> +		max_low_pfn = max_pfn = end_pfn;

One assignment per line is preferred.

Thanks,
Fengguang

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch - Resend v4] Memory-Hotplug: Fix the bug on interface /dev/mem for 64-bit kernel
  2010-02-01  4:41 ` Wu Fengguang
@ 2010-02-01 12:22   ` Shaohui Zheng
  0 siblings, 0 replies; 3+ messages in thread
From: Shaohui Zheng @ 2010-02-01 12:22 UTC (permalink / raw)
  To: Wu Fengguang, akpm, linux-mm
  Cc: linux-kernel, y-goto, haveblue, kamezawa.hiroyu, ak, hpa,
	haicheng.li, shaohui.zheng

[-- Attachment #1: Type: text/plain, Size: 2416 bytes --]

On Mon, Feb 01, 2010 at 12:41:24PM +0800, Wu Fengguang wrote:
> Shaohui,
> 
> Some style nitpicks..
> 
> >  #ifdef CONFIG_MEMORY_HOTPLUG
> > +/**
> 
> Should use /* here. 
Agree.
> 
> > + * After memory hotplug, the variable max_pfn, max_low_pfn and high_memory will
> > + * be affected, it will be updated in this function.
> > + */
> > +static inline void __meminit update_end_of_memory_vars(u64 start,
> 
> The "inline" and "__meminit" are both redundant here.
will remove both.
> 
> > +		max_low_pfn = max_pfn = end_pfn;
> 
> One assignment per line is preferred.
will change to 2 statements.
> 
> Thanks,
> Fengguang

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 variables high_memory, max_pfn and max_low_pfn.

Add a function update_end_of_memory_vars to update these variables for 64-bit 
kernel.

CC: Andi Kleen <ak@linux.intel.com>
CC: Li Haicheng <haicheng.li@intel.com>
Reviewed-by: Wu Fengguang <fengguang.wu@intel.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Shaohui Zheng <shaohui.zheng@intel.com>
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 5198b9b..e1c9202 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -49,6 +49,7 @@
 #include <asm/numa.h>
 #include <asm/cacheflush.h>
 #include <asm/init.h>
+#include <linux/bootmem.h>
 
 static unsigned long dma_reserve __initdata;
 
@@ -616,6 +617,21 @@ void __init paging_init(void)
  */
 #ifdef CONFIG_MEMORY_HOTPLUG
 /*
+ * After memory hotplug, the variables max_pfn, max_low_pfn and high_memory will
+ * be affected, they will be updated in this function.
+ */
+static void  update_end_of_memory_vars(u64 start, u64 size)
+{
+	unsigned long end_pfn = PFN_UP(start + size);
+
+	if (end_pfn > max_pfn) {
+		max_pfn = end_pfn;
+		max_low_pfn = end_pfn;
+		high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;
+	}
+}
+
+/*
  * Memory is added always to NORMAL zone. This means you will never get
  * additional DMA/DMA32 memory.
  */
@@ -634,6 +650,9 @@ int arch_add_memory(int nid, u64 start, u64 size)
 	ret = __add_pages(nid, zone, start_pfn, nr_pages);
 	WARN_ON_ONCE(ret);
 
+	/* update max_pfn, max_low_pfn and high_memory */
+	update_end_of_memory_vars(start, size);
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(arch_add_memory);
-- 
Thanks & Regards,
Shaohui


[-- Attachment #2: memory-hotplug-fix-the-bug-on-interface-dev-mem-v5.patch --]
[-- Type: text/x-diff, Size: 1762 bytes --]

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 variables high_memory, max_pfn and max_low_pfn.

Add a function update_end_of_memory_vars to update these variables for 64-bit 
kernel.

CC: Andi Kleen <ak@linux.intel.com>
CC: Li Haicheng <haicheng.li@intel.com>
Reviewed-by: Wu Fengguang <fengguang.wu@intel.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Shaohui Zheng <shaohui.zheng@intel.com>
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 5198b9b..e1c9202 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -49,6 +49,7 @@
 #include <asm/numa.h>
 #include <asm/cacheflush.h>
 #include <asm/init.h>
+#include <linux/bootmem.h>
 
 static unsigned long dma_reserve __initdata;
 
@@ -616,6 +617,21 @@ void __init paging_init(void)
  */
 #ifdef CONFIG_MEMORY_HOTPLUG
 /*
+ * After memory hotplug, the variables max_pfn, max_low_pfn and high_memory will
+ * be affected, they will be updated in this function.
+ */
+static void  update_end_of_memory_vars(u64 start, u64 size)
+{
+	unsigned long end_pfn = PFN_UP(start + size);
+
+	if (end_pfn > max_pfn) {
+		max_pfn = end_pfn;
+		max_low_pfn = end_pfn;
+		high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;
+	}
+}
+
+/*
  * Memory is added always to NORMAL zone. This means you will never get
  * additional DMA/DMA32 memory.
  */
@@ -634,6 +650,9 @@ int arch_add_memory(int nid, u64 start, u64 size)
 	ret = __add_pages(nid, zone, start_pfn, nr_pages);
 	WARN_ON_ONCE(ret);
 
+	/* update max_pfn, max_low_pfn and high_memory */
+	update_end_of_memory_vars(start, size);
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(arch_add_memory);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-02-01 12:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-01  4:12 [Patch - Resend v4] Memory-Hotplug: Fix the bug on interface /dev/mem for 64-bit kernel Shaohui Zheng
2010-02-01  4:41 ` Wu Fengguang
2010-02-01 12:22   ` Shaohui Zheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).