linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH R2 1/7] mm: Add add_registered_memory() to memory hotplug API
@ 2010-12-29 17:02 Daniel Kiper
  2010-12-30  0:50 ` David Rientjes
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Kiper @ 2010-12-29 17:02 UTC (permalink / raw)
  To: ian.campbell, akpm, andi.kleen, haicheng.li, fengguang.wu,
	jeremy, konrad.wilk, dan.magenheimer, v.tolstov, xen-devel,
	linux-kernel, linux-mm

add_registered_memory() adds memory ealier registered
as memory resource. It is required by memory hotplug
for Xen guests, however it could be used also by other
modules.

Signed-off-by: Daniel Kiper <dkiper@net-space.pl>
---
 include/linux/memory_hotplug.h |    1 +
 mm/memory_hotplug.c            |   50 ++++++++++++++++++++++++++++++---------
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 864035f..2458b2f 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -203,6 +203,7 @@ static inline int is_mem_section_removable(unsigned long pfn,
 #endif /* CONFIG_MEMORY_HOTREMOVE */
 
 extern int mem_online_node(int nid);
+extern int add_registered_memory(int nid, u64 start, u64 size);
 extern int add_memory(int nid, u64 start, u64 size);
 extern int arch_add_memory(int nid, u64 start, u64 size);
 extern int remove_memory(u64 start, u64 size);
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index dd186c1..b642f26 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -509,20 +509,12 @@ out:
 }
 
 /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
-int __ref add_memory(int nid, u64 start, u64 size)
+static int __ref __add_memory(int nid, u64 start, u64 size)
 {
 	pg_data_t *pgdat = NULL;
 	int new_pgdat = 0;
-	struct resource *res;
 	int ret;
 
-	lock_system_sleep();
-
-	res = register_memory_resource(start, size);
-	ret = -EEXIST;
-	if (!res)
-		goto out;
-
 	if (!node_online(nid)) {
 		pgdat = hotadd_new_pgdat(nid, start);
 		ret = -ENOMEM;
@@ -556,14 +548,48 @@ int __ref add_memory(int nid, u64 start, u64 size)
 	goto out;
 
 error:
-	/* rollback pgdat allocation and others */
+	/* rollback pgdat allocation */
 	if (new_pgdat)
 		rollback_node_hotadd(nid, pgdat);
-	if (res)
-		release_memory_resource(res);
+
+out:
+	return ret;
+}
+
+int add_registered_memory(int nid, u64 start, u64 size)
+{
+	int ret;
+
+	lock_system_sleep();
+	ret = __add_memory(nid, start, size);
+	unlock_system_sleep();
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(add_registered_memory);
+
+int add_memory(int nid, u64 start, u64 size)
+{
+	int ret = -EEXIST;
+	struct resource *res;
+
+	lock_system_sleep();
+
+	res = register_memory_resource(start, size);
+
+	if (!res)
+		goto out;
+
+	ret = __add_memory(nid, start, size);
+
+	if (!ret)
+		goto out;
+
+	release_memory_resource(res);
 
 out:
 	unlock_system_sleep();
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(add_memory);
-- 
1.4.4.4

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH R2 1/7] mm: Add add_registered_memory() to memory hotplug API
  2010-12-29 17:02 [PATCH R2 1/7] mm: Add add_registered_memory() to memory hotplug API Daniel Kiper
@ 2010-12-30  0:50 ` David Rientjes
  2010-12-30 12:30   ` Daniel Kiper
  0 siblings, 1 reply; 5+ messages in thread
From: David Rientjes @ 2010-12-30  0:50 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: ian.campbell, Andrew Morton, Andi Kleen, haicheng.li,
	fengguang.wu, jeremy, konrad.wilk, dan.magenheimer, v.tolstov,
	xen-devel, linux-kernel, linux-mm, KOSAKI Motohiro

On Wed, 29 Dec 2010, Daniel Kiper wrote:

> diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
> index 864035f..2458b2f 100644
> --- a/include/linux/memory_hotplug.h
> +++ b/include/linux/memory_hotplug.h
> @@ -203,6 +203,7 @@ static inline int is_mem_section_removable(unsigned long pfn,
>  #endif /* CONFIG_MEMORY_HOTREMOVE */
>  
>  extern int mem_online_node(int nid);
> +extern int add_registered_memory(int nid, u64 start, u64 size);
>  extern int add_memory(int nid, u64 start, u64 size);
>  extern int arch_add_memory(int nid, u64 start, u64 size);
>  extern int remove_memory(u64 start, u64 size);
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index dd186c1..b642f26 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -509,20 +509,12 @@ out:
>  }
>  
>  /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
> -int __ref add_memory(int nid, u64 start, u64 size)
> +static int __ref __add_memory(int nid, u64 start, u64 size)
>  {
>  	pg_data_t *pgdat = NULL;
>  	int new_pgdat = 0;
> -	struct resource *res;
>  	int ret;
>  
> -	lock_system_sleep();
> -
> -	res = register_memory_resource(start, size);
> -	ret = -EEXIST;
> -	if (!res)
> -		goto out;
> -
>  	if (!node_online(nid)) {
>  		pgdat = hotadd_new_pgdat(nid, start);
>  		ret = -ENOMEM;

Looks like this patch was based on a kernel before 2.6.37-rc4 since it 
doesn't have 20d6c96b5f (mem-hotplug: introduce {un}lock_memory_hotplug()) 

> @@ -556,14 +548,48 @@ int __ref add_memory(int nid, u64 start, u64 size)
>  	goto out;
>  
>  error:
> -	/* rollback pgdat allocation and others */
> +	/* rollback pgdat allocation */
>  	if (new_pgdat)
>  		rollback_node_hotadd(nid, pgdat);
> -	if (res)
> -		release_memory_resource(res);
> +
> +out:
> +	return ret;
> +}
> +
> +int add_registered_memory(int nid, u64 start, u64 size)
> +{
> +	int ret;
> +
> +	lock_system_sleep();
> +	ret = __add_memory(nid, start, size);
> +	unlock_system_sleep();
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(add_registered_memory);
> +
> +int add_memory(int nid, u64 start, u64 size)
> +{
> +	int ret = -EEXIST;
> +	struct resource *res;
> +
> +	lock_system_sleep();
> +
> +	res = register_memory_resource(start, size);
> +
> +	if (!res)
> +		goto out;
> +
> +	ret = __add_memory(nid, start, size);
> +
> +	if (!ret)
> +		goto out;
> +
> +	release_memory_resource(res);
>  
>  out:
>  	unlock_system_sleep();
> +
>  	return ret;
>  }
>  EXPORT_SYMBOL_GPL(add_memory);

Lots of unnecessary empty lines here, and scripts/checkpatch.pl says there 
are trailing whitespaces as well.

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH R2 1/7] mm: Add add_registered_memory() to memory hotplug API
  2010-12-30  0:50 ` David Rientjes
@ 2010-12-30 12:30   ` Daniel Kiper
  2010-12-30 18:49     ` David Rientjes
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Kiper @ 2010-12-30 12:30 UTC (permalink / raw)
  To: David Rientjes
  Cc: Daniel Kiper, ian.campbell, Andrew Morton, Andi Kleen,
	haicheng.li, fengguang.wu, jeremy, konrad.wilk, dan.magenheimer,
	v.tolstov, xen-devel, linux-kernel, linux-mm, KOSAKI Motohiro

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

Hi,

On Wed, Dec 29, 2010 at 04:50:25PM -0800, David Rientjes wrote:
> On Wed, 29 Dec 2010, Daniel Kiper wrote:
>
> > diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
> > index 864035f..2458b2f 100644
> > --- a/include/linux/memory_hotplug.h
> > +++ b/include/linux/memory_hotplug.h
> > @@ -203,6 +203,7 @@ static inline int is_mem_section_removable(unsigned long pfn,
> >  #endif /* CONFIG_MEMORY_HOTREMOVE */
> >
> >  extern int mem_online_node(int nid);
> > +extern int add_registered_memory(int nid, u64 start, u64 size);
> >  extern int add_memory(int nid, u64 start, u64 size);
> >  extern int arch_add_memory(int nid, u64 start, u64 size);
> >  extern int remove_memory(u64 start, u64 size);
> > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> > index dd186c1..b642f26 100644
> > --- a/mm/memory_hotplug.c
> > +++ b/mm/memory_hotplug.c
> > @@ -509,20 +509,12 @@ out:
> >  }
> >
> >  /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
> > -int __ref add_memory(int nid, u64 start, u64 size)
> > +static int __ref __add_memory(int nid, u64 start, u64 size)
> >  {
> >  	pg_data_t *pgdat = NULL;
> >  	int new_pgdat = 0;
> > -	struct resource *res;
> >  	int ret;
> >
> > -	lock_system_sleep();
> > -
> > -	res = register_memory_resource(start, size);
> > -	ret = -EEXIST;
> > -	if (!res)
> > -		goto out;
> > -
> >  	if (!node_online(nid)) {
> >  		pgdat = hotadd_new_pgdat(nid, start);
> >  		ret = -ENOMEM;
>
> Looks like this patch was based on a kernel before 2.6.37-rc4 since it
> doesn't have 20d6c96b5f (mem-hotplug: introduce {un}lock_memory_hotplug())

As I wrote in "[PATCH R2 0/7] Xen memory balloon driver with memoryhotplug
support" this patch applies to Linux kernel Ver. 2.6.36.

> Lots of unnecessary empty lines here, and scripts/checkpatch.pl says there
> are trailing whitespaces as well.

Strange. I tested it with this script and I received:

0001-mm-Add-add_registered_memory-to-memory-hotplug-API.txt has no
obvious style problems and is ready for submission.

I do not know why my e-mail was mangled. For your convenience
I am sending this patch as attachment.

Empty lines are added for better readability (it is my
opinion) however, I do not insist to leave this patch
with that formating.

Daniel

[-- Attachment #2: 0001-mm-Add-add_registered_memory-to-memory-hotplug-API.txt --]
[-- Type: text/plain, Size: 2535 bytes --]

add_registered_memory() adds memory ealier registered
as memory resource. It is required by memory hotplug
for Xen guests, however it could be used also by other
modules.

Signed-off-by: Daniel Kiper <dkiper@net-space.pl>
---
 include/linux/memory_hotplug.h |    1 +
 mm/memory_hotplug.c            |   50 ++++++++++++++++++++++++++++++---------
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 864035f..2458b2f 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -203,6 +203,7 @@ static inline int is_mem_section_removable(unsigned long pfn,
 #endif /* CONFIG_MEMORY_HOTREMOVE */
 
 extern int mem_online_node(int nid);
+extern int add_registered_memory(int nid, u64 start, u64 size);
 extern int add_memory(int nid, u64 start, u64 size);
 extern int arch_add_memory(int nid, u64 start, u64 size);
 extern int remove_memory(u64 start, u64 size);
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index dd186c1..b642f26 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -509,20 +509,12 @@ out:
 }
 
 /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
-int __ref add_memory(int nid, u64 start, u64 size)
+static int __ref __add_memory(int nid, u64 start, u64 size)
 {
 	pg_data_t *pgdat = NULL;
 	int new_pgdat = 0;
-	struct resource *res;
 	int ret;
 
-	lock_system_sleep();
-
-	res = register_memory_resource(start, size);
-	ret = -EEXIST;
-	if (!res)
-		goto out;
-
 	if (!node_online(nid)) {
 		pgdat = hotadd_new_pgdat(nid, start);
 		ret = -ENOMEM;
@@ -556,14 +548,48 @@ int __ref add_memory(int nid, u64 start, u64 size)
 	goto out;
 
 error:
-	/* rollback pgdat allocation and others */
+	/* rollback pgdat allocation */
 	if (new_pgdat)
 		rollback_node_hotadd(nid, pgdat);
-	if (res)
-		release_memory_resource(res);
+
+out:
+	return ret;
+}
+
+int add_registered_memory(int nid, u64 start, u64 size)
+{
+	int ret;
+
+	lock_system_sleep();
+	ret = __add_memory(nid, start, size);
+	unlock_system_sleep();
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(add_registered_memory);
+
+int add_memory(int nid, u64 start, u64 size)
+{
+	int ret = -EEXIST;
+	struct resource *res;
+
+	lock_system_sleep();
+
+	res = register_memory_resource(start, size);
+
+	if (!res)
+		goto out;
+
+	ret = __add_memory(nid, start, size);
+
+	if (!ret)
+		goto out;
+
+	release_memory_resource(res);
 
 out:
 	unlock_system_sleep();
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(add_memory);
-- 
1.4.4.4


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

* Re: [PATCH R2 1/7] mm: Add add_registered_memory() to memory hotplug API
  2010-12-30 12:30   ` Daniel Kiper
@ 2010-12-30 18:49     ` David Rientjes
  2010-12-30 22:04       ` Daniel Kiper
  0 siblings, 1 reply; 5+ messages in thread
From: David Rientjes @ 2010-12-30 18:49 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: ian.campbell, Andrew Morton, Andi Kleen, haicheng.li,
	fengguang.wu, jeremy, konrad.wilk, dan.magenheimer, v.tolstov,
	xen-devel, linux-kernel, linux-mm, KOSAKI Motohiro

On Thu, 30 Dec 2010, Daniel Kiper wrote:

> > Looks like this patch was based on a kernel before 2.6.37-rc4 since it
> > doesn't have 20d6c96b5f (mem-hotplug: introduce {un}lock_memory_hotplug())
> 
> As I wrote in "[PATCH R2 0/7] Xen memory balloon driver with memoryhotplug
> support" this patch applies to Linux kernel Ver. 2.6.36.
> 

I'd suggest posting patches against the latest -git.

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH R2 1/7] mm: Add add_registered_memory() to memory hotplug API
  2010-12-30 18:49     ` David Rientjes
@ 2010-12-30 22:04       ` Daniel Kiper
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Kiper @ 2010-12-30 22:04 UTC (permalink / raw)
  To: David Rientjes
  Cc: Daniel Kiper, ian.campbell, Andrew Morton, Andi Kleen,
	haicheng.li, fengguang.wu, jeremy, konrad.wilk, dan.magenheimer,
	v.tolstov, xen-devel, linux-kernel, linux-mm, KOSAKI Motohiro

Hi,

On Thu, Dec 30, 2010 at 10:49:29AM -0800, David Rientjes wrote:
> On Thu, 30 Dec 2010, Daniel Kiper wrote:
>
> > > Looks like this patch was based on a kernel before 2.6.37-rc4 since it
> > > doesn't have 20d6c96b5f (mem-hotplug: introduce {un}lock_memory_hotplug())
> >
> > As I wrote in "[PATCH R2 0/7] Xen memory balloon driver with memoryhotplug
> > support" this patch applies to Linux kernel Ver. 2.6.36.
> >
>
> I'd suggest posting patches against the latest -git.

Thx, next patch will be based on latest rc.

Daniel

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2010-12-30 22:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-29 17:02 [PATCH R2 1/7] mm: Add add_registered_memory() to memory hotplug API Daniel Kiper
2010-12-30  0:50 ` David Rientjes
2010-12-30 12:30   ` Daniel Kiper
2010-12-30 18:49     ` David Rientjes
2010-12-30 22:04       ` Daniel Kiper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox