All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] mm: Honor min_free_kbytes set by user
@ 2013-07-04 16:07 ` Michal Hocko
  0 siblings, 0 replies; 16+ messages in thread
From: Michal Hocko @ 2013-07-04 16:07 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Mel Gorman, KOSAKI Motohiro, linux-mm, linux-kernel

min_free_kbytes is updated during memory hotplug (by init_per_zone_wmark_min)
currently which is right thing to do in most cases but this could be
unexpected if admin increased the value to prevent from allocation
failures and the new min_free_kbytes would be decreased as a result of
memory hotadd.

This patch saves the user defined value and allows updating
min_free_kbytes only if it is higher than the saved one.

A warning is printed when the new value is ignored.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
---
 mm/page_alloc.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 22c528e..a785fad 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -204,6 +204,7 @@ static char * const zone_names[MAX_NR_ZONES] = {
 };
 
 int min_free_kbytes = 1024;
+int user_min_free_kbytes;
 
 static unsigned long __meminitdata nr_kernel_pages;
 static unsigned long __meminitdata nr_all_pages;
@@ -5592,14 +5593,22 @@ static void __meminit setup_per_zone_inactive_ratio(void)
 int __meminit init_per_zone_wmark_min(void)
 {
 	unsigned long lowmem_kbytes;
+	int new_min_free_kbytes;
 
 	lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
-
-	min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
-	if (min_free_kbytes < 128)
-		min_free_kbytes = 128;
-	if (min_free_kbytes > 65536)
-		min_free_kbytes = 65536;
+	new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
+
+	if (new_min_free_kbytes > user_min_free_kbytes) {
+		min_free_kbytes = new_min_free_kbytes;
+		if (min_free_kbytes < 128)
+			min_free_kbytes = 128;
+		if (min_free_kbytes > 65536)
+			min_free_kbytes = 65536;
+	} else {
+		printk(KERN_WARNING "min_free_kbytes is not updated to %d"
+				"because user defined value %d is preferred\n",
+				new_min_free_kbytes, user_min_free_kbytes);
+	}
 	setup_per_zone_wmarks();
 	refresh_zone_stat_thresholds();
 	setup_per_zone_lowmem_reserve();
@@ -5617,8 +5626,10 @@ int min_free_kbytes_sysctl_handler(ctl_table *table, int write,
 	void __user *buffer, size_t *length, loff_t *ppos)
 {
 	proc_dointvec(table, write, buffer, length, ppos);
-	if (write)
+	if (write) {
+		user_min_free_kbytes = min_free_kbytes;
 		setup_per_zone_wmarks();
+	}
 	return 0;
 }
 
-- 
1.8.3.1


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

* [RFC] mm: Honor min_free_kbytes set by user
@ 2013-07-04 16:07 ` Michal Hocko
  0 siblings, 0 replies; 16+ messages in thread
From: Michal Hocko @ 2013-07-04 16:07 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Mel Gorman, KOSAKI Motohiro, linux-mm, linux-kernel

min_free_kbytes is updated during memory hotplug (by init_per_zone_wmark_min)
currently which is right thing to do in most cases but this could be
unexpected if admin increased the value to prevent from allocation
failures and the new min_free_kbytes would be decreased as a result of
memory hotadd.

This patch saves the user defined value and allows updating
min_free_kbytes only if it is higher than the saved one.

A warning is printed when the new value is ignored.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
---
 mm/page_alloc.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 22c528e..a785fad 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -204,6 +204,7 @@ static char * const zone_names[MAX_NR_ZONES] = {
 };
 
 int min_free_kbytes = 1024;
+int user_min_free_kbytes;
 
 static unsigned long __meminitdata nr_kernel_pages;
 static unsigned long __meminitdata nr_all_pages;
@@ -5592,14 +5593,22 @@ static void __meminit setup_per_zone_inactive_ratio(void)
 int __meminit init_per_zone_wmark_min(void)
 {
 	unsigned long lowmem_kbytes;
+	int new_min_free_kbytes;
 
 	lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
-
-	min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
-	if (min_free_kbytes < 128)
-		min_free_kbytes = 128;
-	if (min_free_kbytes > 65536)
-		min_free_kbytes = 65536;
+	new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
+
+	if (new_min_free_kbytes > user_min_free_kbytes) {
+		min_free_kbytes = new_min_free_kbytes;
+		if (min_free_kbytes < 128)
+			min_free_kbytes = 128;
+		if (min_free_kbytes > 65536)
+			min_free_kbytes = 65536;
+	} else {
+		printk(KERN_WARNING "min_free_kbytes is not updated to %d"
+				"because user defined value %d is preferred\n",
+				new_min_free_kbytes, user_min_free_kbytes);
+	}
 	setup_per_zone_wmarks();
 	refresh_zone_stat_thresholds();
 	setup_per_zone_lowmem_reserve();
@@ -5617,8 +5626,10 @@ int min_free_kbytes_sysctl_handler(ctl_table *table, int write,
 	void __user *buffer, size_t *length, loff_t *ppos)
 {
 	proc_dointvec(table, write, buffer, length, ppos);
-	if (write)
+	if (write) {
+		user_min_free_kbytes = min_free_kbytes;
 		setup_per_zone_wmarks();
+	}
 	return 0;
 }
 
-- 
1.8.3.1

--
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 related	[flat|nested] 16+ messages in thread

* Re: [RFC] mm: Honor min_free_kbytes set by user
  2013-07-04 16:07 ` Michal Hocko
@ 2013-07-04 16:10   ` Joe Perches
  -1 siblings, 0 replies; 16+ messages in thread
From: Joe Perches @ 2013-07-04 16:10 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Andrew Morton, Mel Gorman, KOSAKI Motohiro, linux-mm, linux-kernel

On Thu, 2013-07-04 at 18:07 +0200, Michal Hocko wrote:
> A warning is printed when the new value is ignored.

[]

> +		printk(KERN_WARNING "min_free_kbytes is not updated to %d"
> +				"because user defined value %d is preferred\n",
> +				new_min_free_kbytes, user_min_free_kbytes);

Please use pr_warn and coalesce the format.
You'd've noticed a missing space between %d and because.



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

* Re: [RFC] mm: Honor min_free_kbytes set by user
@ 2013-07-04 16:10   ` Joe Perches
  0 siblings, 0 replies; 16+ messages in thread
From: Joe Perches @ 2013-07-04 16:10 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Andrew Morton, Mel Gorman, KOSAKI Motohiro, linux-mm, linux-kernel

On Thu, 2013-07-04 at 18:07 +0200, Michal Hocko wrote:
> A warning is printed when the new value is ignored.

[]

> +		printk(KERN_WARNING "min_free_kbytes is not updated to %d"
> +				"because user defined value %d is preferred\n",
> +				new_min_free_kbytes, user_min_free_kbytes);

Please use pr_warn and coalesce the format.
You'd've noticed a missing space between %d and because.


--
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] 16+ messages in thread

* Re: [RFC] mm: Honor min_free_kbytes set by user
  2013-07-04 16:10   ` Joe Perches
@ 2013-07-04 16:16     ` Michal Hocko
  -1 siblings, 0 replies; 16+ messages in thread
From: Michal Hocko @ 2013-07-04 16:16 UTC (permalink / raw)
  To: Joe Perches
  Cc: Andrew Morton, Mel Gorman, KOSAKI Motohiro, linux-mm, linux-kernel

On Thu 04-07-13 09:10:39, Joe Perches wrote:
> On Thu, 2013-07-04 at 18:07 +0200, Michal Hocko wrote:
> > A warning is printed when the new value is ignored.
> 
> []
> 
> > +		printk(KERN_WARNING "min_free_kbytes is not updated to %d"
> > +				"because user defined value %d is preferred\n",
> > +				new_min_free_kbytes, user_min_free_kbytes);
> 
> Please use pr_warn and coalesce the format.

Sure can do that. mm/page_alloc.c doesn't seem to be unified in that
regards (44 printks and only 4 pr_<foo>) so I used printk.

> You'd've noticed a missing space between %d and because.

True

Thanks
-- 
Michal Hocko
SUSE Labs

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

* Re: [RFC] mm: Honor min_free_kbytes set by user
@ 2013-07-04 16:16     ` Michal Hocko
  0 siblings, 0 replies; 16+ messages in thread
From: Michal Hocko @ 2013-07-04 16:16 UTC (permalink / raw)
  To: Joe Perches
  Cc: Andrew Morton, Mel Gorman, KOSAKI Motohiro, linux-mm, linux-kernel

On Thu 04-07-13 09:10:39, Joe Perches wrote:
> On Thu, 2013-07-04 at 18:07 +0200, Michal Hocko wrote:
> > A warning is printed when the new value is ignored.
> 
> []
> 
> > +		printk(KERN_WARNING "min_free_kbytes is not updated to %d"
> > +				"because user defined value %d is preferred\n",
> > +				new_min_free_kbytes, user_min_free_kbytes);
> 
> Please use pr_warn and coalesce the format.

Sure can do that. mm/page_alloc.c doesn't seem to be unified in that
regards (44 printks and only 4 pr_<foo>) so I used printk.

> You'd've noticed a missing space between %d and because.

True

Thanks
-- 
Michal Hocko
SUSE Labs

--
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] 16+ messages in thread

* Re: [RFC] mm: Honor min_free_kbytes set by user
  2013-07-04 16:16     ` Michal Hocko
@ 2013-07-04 16:20       ` Michal Hocko
  -1 siblings, 0 replies; 16+ messages in thread
From: Michal Hocko @ 2013-07-04 16:20 UTC (permalink / raw)
  To: Joe Perches
  Cc: Andrew Morton, Mel Gorman, KOSAKI Motohiro, linux-mm, linux-kernel

On Thu 04-07-13 18:16:41, Michal Hocko wrote:
> On Thu 04-07-13 09:10:39, Joe Perches wrote:
> > On Thu, 2013-07-04 at 18:07 +0200, Michal Hocko wrote:
> > > A warning is printed when the new value is ignored.
> > 
> > []
> > 
> > > +		printk(KERN_WARNING "min_free_kbytes is not updated to %d"
> > > +				"because user defined value %d is preferred\n",
> > > +				new_min_free_kbytes, user_min_free_kbytes);
> > 
> > Please use pr_warn and coalesce the format.
> 
> Sure can do that. mm/page_alloc.c doesn't seem to be unified in that
> regards (44 printks and only 4 pr_<foo>) so I used printk.
> 
> > You'd've noticed a missing space between %d and because.
> 
> True
> 

Checkpatch fixes
---
>From 5f089c0b2a57ff6c08710ac9698d65aede06079f Mon Sep 17 00:00:00 2001
From: Michal Hocko <mhocko@suse.cz>
Date: Thu, 4 Jul 2013 17:15:54 +0200
Subject: [PATCH] mm: Honor min_free_kbytes set by user

min_free_kbytes is updated during memory hotplug (by init_per_zone_wmark_min)
currently which is right thing to do in most cases but this could be
unexpected if admin increased the value to prevent from allocation
failures and the new min_free_kbytes would be decreased as a result of
memory hotadd.

This patch saves the user defined value and allows updating
min_free_kbytes only if it is higher than the saved one.

A warning is printed when the new value is ignored.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
---
 mm/page_alloc.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 22c528e..9c011fc 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -204,6 +204,7 @@ static char * const zone_names[MAX_NR_ZONES] = {
 };
 
 int min_free_kbytes = 1024;
+int user_min_free_kbytes;
 
 static unsigned long __meminitdata nr_kernel_pages;
 static unsigned long __meminitdata nr_all_pages;
@@ -5592,14 +5593,21 @@ static void __meminit setup_per_zone_inactive_ratio(void)
 int __meminit init_per_zone_wmark_min(void)
 {
 	unsigned long lowmem_kbytes;
+	int new_min_free_kbytes;
 
 	lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
-
-	min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
-	if (min_free_kbytes < 128)
-		min_free_kbytes = 128;
-	if (min_free_kbytes > 65536)
-		min_free_kbytes = 65536;
+	new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
+
+	if (new_min_free_kbytes > user_min_free_kbytes) {
+		min_free_kbytes = new_min_free_kbytes;
+		if (min_free_kbytes < 128)
+			min_free_kbytes = 128;
+		if (min_free_kbytes > 65536)
+			min_free_kbytes = 65536;
+	} else {
+		pr_warn("min_free_kbytes is not updated to %d because user defined value %d is preferred\n",
+				new_min_free_kbytes, user_min_free_kbytes);
+	}
 	setup_per_zone_wmarks();
 	refresh_zone_stat_thresholds();
 	setup_per_zone_lowmem_reserve();
@@ -5617,8 +5625,10 @@ int min_free_kbytes_sysctl_handler(ctl_table *table, int write,
 	void __user *buffer, size_t *length, loff_t *ppos)
 {
 	proc_dointvec(table, write, buffer, length, ppos);
-	if (write)
+	if (write) {
+		user_min_free_kbytes = min_free_kbytes;
 		setup_per_zone_wmarks();
+	}
 	return 0;
 }
 
-- 
1.8.3.1

-- 
Michal Hocko
SUSE Labs

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

* Re: [RFC] mm: Honor min_free_kbytes set by user
@ 2013-07-04 16:20       ` Michal Hocko
  0 siblings, 0 replies; 16+ messages in thread
From: Michal Hocko @ 2013-07-04 16:20 UTC (permalink / raw)
  To: Joe Perches
  Cc: Andrew Morton, Mel Gorman, KOSAKI Motohiro, linux-mm, linux-kernel

On Thu 04-07-13 18:16:41, Michal Hocko wrote:
> On Thu 04-07-13 09:10:39, Joe Perches wrote:
> > On Thu, 2013-07-04 at 18:07 +0200, Michal Hocko wrote:
> > > A warning is printed when the new value is ignored.
> > 
> > []
> > 
> > > +		printk(KERN_WARNING "min_free_kbytes is not updated to %d"
> > > +				"because user defined value %d is preferred\n",
> > > +				new_min_free_kbytes, user_min_free_kbytes);
> > 
> > Please use pr_warn and coalesce the format.
> 
> Sure can do that. mm/page_alloc.c doesn't seem to be unified in that
> regards (44 printks and only 4 pr_<foo>) so I used printk.
> 
> > You'd've noticed a missing space between %d and because.
> 
> True
> 

Checkpatch fixes
---

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

* Re: [RFC] mm: Honor min_free_kbytes set by user
  2013-07-04 16:20       ` Michal Hocko
@ 2013-07-04 16:35         ` Zhang Yanfei
  -1 siblings, 0 replies; 16+ messages in thread
From: Zhang Yanfei @ 2013-07-04 16:35 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Joe Perches, Andrew Morton, Mel Gorman, KOSAKI Motohiro,
	linux-mm, linux-kernel

On 07/05/2013 12:20 AM, Michal Hocko wrote:

[snip]

> ---
> From 5f089c0b2a57ff6c08710ac9698d65aede06079f Mon Sep 17 00:00:00 2001
> From: Michal Hocko <mhocko@suse.cz>
> Date: Thu, 4 Jul 2013 17:15:54 +0200
> Subject: [PATCH] mm: Honor min_free_kbytes set by user
> 
> min_free_kbytes is updated during memory hotplug (by init_per_zone_wmark_min)
> currently which is right thing to do in most cases but this could be
> unexpected if admin increased the value to prevent from allocation
> failures and the new min_free_kbytes would be decreased as a result of
> memory hotadd.
> 
> This patch saves the user defined value and allows updating
> min_free_kbytes only if it is higher than the saved one.
> 
> A warning is printed when the new value is ignored.

Looks reasonable.

Acked-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>

> 
> Signed-off-by: Michal Hocko <mhocko@suse.cz>
> ---
>  mm/page_alloc.c | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 22c528e..9c011fc 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -204,6 +204,7 @@ static char * const zone_names[MAX_NR_ZONES] = {
>  };
>  
>  int min_free_kbytes = 1024;
> +int user_min_free_kbytes;
>  
>  static unsigned long __meminitdata nr_kernel_pages;
>  static unsigned long __meminitdata nr_all_pages;
> @@ -5592,14 +5593,21 @@ static void __meminit setup_per_zone_inactive_ratio(void)
>  int __meminit init_per_zone_wmark_min(void)
>  {
>  	unsigned long lowmem_kbytes;
> +	int new_min_free_kbytes;
>  
>  	lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
> -
> -	min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
> -	if (min_free_kbytes < 128)
> -		min_free_kbytes = 128;
> -	if (min_free_kbytes > 65536)
> -		min_free_kbytes = 65536;
> +	new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
> +
> +	if (new_min_free_kbytes > user_min_free_kbytes) {
> +		min_free_kbytes = new_min_free_kbytes;
> +		if (min_free_kbytes < 128)
> +			min_free_kbytes = 128;
> +		if (min_free_kbytes > 65536)
> +			min_free_kbytes = 65536;
> +	} else {
> +		pr_warn("min_free_kbytes is not updated to %d because user defined value %d is preferred\n",
> +				new_min_free_kbytes, user_min_free_kbytes);
> +	}
>  	setup_per_zone_wmarks();
>  	refresh_zone_stat_thresholds();
>  	setup_per_zone_lowmem_reserve();
> @@ -5617,8 +5625,10 @@ int min_free_kbytes_sysctl_handler(ctl_table *table, int write,
>  	void __user *buffer, size_t *length, loff_t *ppos)
>  {
>  	proc_dointvec(table, write, buffer, length, ppos);
> -	if (write)
> +	if (write) {
> +		user_min_free_kbytes = min_free_kbytes;
>  		setup_per_zone_wmarks();
> +	}
>  	return 0;
>  }
>  


-- 
Thanks.
Zhang Yanfei

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

* Re: [RFC] mm: Honor min_free_kbytes set by user
@ 2013-07-04 16:35         ` Zhang Yanfei
  0 siblings, 0 replies; 16+ messages in thread
From: Zhang Yanfei @ 2013-07-04 16:35 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Joe Perches, Andrew Morton, Mel Gorman, KOSAKI Motohiro,
	linux-mm, linux-kernel

On 07/05/2013 12:20 AM, Michal Hocko wrote:

[snip]

> ---
> From 5f089c0b2a57ff6c08710ac9698d65aede06079f Mon Sep 17 00:00:00 2001
> From: Michal Hocko <mhocko@suse.cz>
> Date: Thu, 4 Jul 2013 17:15:54 +0200
> Subject: [PATCH] mm: Honor min_free_kbytes set by user
> 
> min_free_kbytes is updated during memory hotplug (by init_per_zone_wmark_min)
> currently which is right thing to do in most cases but this could be
> unexpected if admin increased the value to prevent from allocation
> failures and the new min_free_kbytes would be decreased as a result of
> memory hotadd.
> 
> This patch saves the user defined value and allows updating
> min_free_kbytes only if it is higher than the saved one.
> 
> A warning is printed when the new value is ignored.

Looks reasonable.

Acked-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>

> 
> Signed-off-by: Michal Hocko <mhocko@suse.cz>
> ---
>  mm/page_alloc.c | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 22c528e..9c011fc 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -204,6 +204,7 @@ static char * const zone_names[MAX_NR_ZONES] = {
>  };
>  
>  int min_free_kbytes = 1024;
> +int user_min_free_kbytes;
>  
>  static unsigned long __meminitdata nr_kernel_pages;
>  static unsigned long __meminitdata nr_all_pages;
> @@ -5592,14 +5593,21 @@ static void __meminit setup_per_zone_inactive_ratio(void)
>  int __meminit init_per_zone_wmark_min(void)
>  {
>  	unsigned long lowmem_kbytes;
> +	int new_min_free_kbytes;
>  
>  	lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
> -
> -	min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
> -	if (min_free_kbytes < 128)
> -		min_free_kbytes = 128;
> -	if (min_free_kbytes > 65536)
> -		min_free_kbytes = 65536;
> +	new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
> +
> +	if (new_min_free_kbytes > user_min_free_kbytes) {
> +		min_free_kbytes = new_min_free_kbytes;
> +		if (min_free_kbytes < 128)
> +			min_free_kbytes = 128;
> +		if (min_free_kbytes > 65536)
> +			min_free_kbytes = 65536;
> +	} else {
> +		pr_warn("min_free_kbytes is not updated to %d because user defined value %d is preferred\n",
> +				new_min_free_kbytes, user_min_free_kbytes);
> +	}
>  	setup_per_zone_wmarks();
>  	refresh_zone_stat_thresholds();
>  	setup_per_zone_lowmem_reserve();
> @@ -5617,8 +5625,10 @@ int min_free_kbytes_sysctl_handler(ctl_table *table, int write,
>  	void __user *buffer, size_t *length, loff_t *ppos)
>  {
>  	proc_dointvec(table, write, buffer, length, ppos);
> -	if (write)
> +	if (write) {
> +		user_min_free_kbytes = min_free_kbytes;
>  		setup_per_zone_wmarks();
> +	}
>  	return 0;
>  }
>  


-- 
Thanks.
Zhang Yanfei

--
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] 16+ messages in thread

* Re: [RFC] mm: Honor min_free_kbytes set by user
  2013-07-04 16:20       ` Michal Hocko
@ 2013-07-08 18:48         ` KOSAKI Motohiro
  -1 siblings, 0 replies; 16+ messages in thread
From: KOSAKI Motohiro @ 2013-07-08 18:48 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Joe Perches, Andrew Morton, Mel Gorman, KOSAKI Motohiro,
	linux-mm, linux-kernel

> Checkpatch fixes
> ---
>  From 5f089c0b2a57ff6c08710ac9698d65aede06079f Mon Sep 17 00:00:00 2001
> From: Michal Hocko <mhocko@suse.cz>
> Date: Thu, 4 Jul 2013 17:15:54 +0200
> Subject: [PATCH] mm: Honor min_free_kbytes set by user
>
> min_free_kbytes is updated during memory hotplug (by init_per_zone_wmark_min)
> currently which is right thing to do in most cases but this could be
> unexpected if admin increased the value to prevent from allocation
> failures and the new min_free_kbytes would be decreased as a result of
> memory hotadd.
>
> This patch saves the user defined value and allows updating
> min_free_kbytes only if it is higher than the saved one.
>
> A warning is printed when the new value is ignored.
>
> Signed-off-by: Michal Hocko <mhocko@suse.cz>

Thank you. I have similar patch and I have been bothered long time to
refine and post it.
Yes, current logic is not memory hotplug aware and could be dangerous.

Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>







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

* Re: [RFC] mm: Honor min_free_kbytes set by user
@ 2013-07-08 18:48         ` KOSAKI Motohiro
  0 siblings, 0 replies; 16+ messages in thread
From: KOSAKI Motohiro @ 2013-07-08 18:48 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Joe Perches, Andrew Morton, Mel Gorman, KOSAKI Motohiro,
	linux-mm, linux-kernel

> Checkpatch fixes
> ---
>  From 5f089c0b2a57ff6c08710ac9698d65aede06079f Mon Sep 17 00:00:00 2001
> From: Michal Hocko <mhocko@suse.cz>
> Date: Thu, 4 Jul 2013 17:15:54 +0200
> Subject: [PATCH] mm: Honor min_free_kbytes set by user
>
> min_free_kbytes is updated during memory hotplug (by init_per_zone_wmark_min)
> currently which is right thing to do in most cases but this could be
> unexpected if admin increased the value to prevent from allocation
> failures and the new min_free_kbytes would be decreased as a result of
> memory hotadd.
>
> This patch saves the user defined value and allows updating
> min_free_kbytes only if it is higher than the saved one.
>
> A warning is printed when the new value is ignored.
>
> Signed-off-by: Michal Hocko <mhocko@suse.cz>

Thank you. I have similar patch and I have been bothered long time to
refine and post it.
Yes, current logic is not memory hotplug aware and could be dangerous.

Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>






--
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] 16+ messages in thread

* Re: [RFC] mm: Honor min_free_kbytes set by user
  2013-07-04 16:20       ` Michal Hocko
@ 2013-07-09 23:40         ` Jiri Kosina
  -1 siblings, 0 replies; 16+ messages in thread
From: Jiri Kosina @ 2013-07-09 23:40 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Joe Perches, Andrew Morton, Mel Gorman, KOSAKI Motohiro,
	linux-mm, linux-kernel

On Thu, 4 Jul 2013, Michal Hocko wrote:

> On Thu 04-07-13 18:16:41, Michal Hocko wrote:
> > On Thu 04-07-13 09:10:39, Joe Perches wrote:
> > > On Thu, 2013-07-04 at 18:07 +0200, Michal Hocko wrote:
> > > > A warning is printed when the new value is ignored.
> > > 
> > > []
> > > 
> > > > +		printk(KERN_WARNING "min_free_kbytes is not updated to %d"
> > > > +				"because user defined value %d is preferred\n",
> > > > +				new_min_free_kbytes, user_min_free_kbytes);
> > > 
> > > Please use pr_warn and coalesce the format.
> > 
> > Sure can do that. mm/page_alloc.c doesn't seem to be unified in that
> > regards (44 printks and only 4 pr_<foo>) so I used printk.
> > 
> > > You'd've noticed a missing space between %d and because.
> > 
> > True
> > 
> 
> Checkpatch fixes
> ---
> >From 5f089c0b2a57ff6c08710ac9698d65aede06079f Mon Sep 17 00:00:00 2001
> From: Michal Hocko <mhocko@suse.cz>
> Date: Thu, 4 Jul 2013 17:15:54 +0200
> Subject: [PATCH] mm: Honor min_free_kbytes set by user
> 
> min_free_kbytes is updated during memory hotplug (by init_per_zone_wmark_min)
> currently which is right thing to do in most cases but this could be
> unexpected if admin increased the value to prevent from allocation
> failures and the new min_free_kbytes would be decreased as a result of
> memory hotadd.
> 
> This patch saves the user defined value and allows updating
> min_free_kbytes only if it is higher than the saved one.
> 
> A warning is printed when the new value is ignored.
> 
> Signed-off-by: Michal Hocko <mhocko@suse.cz>
> ---
>  mm/page_alloc.c | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 22c528e..9c011fc 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -204,6 +204,7 @@ static char * const zone_names[MAX_NR_ZONES] = {
>  };
>  
>  int min_free_kbytes = 1024;
> +int user_min_free_kbytes;

Minor nit: any reason this can't be static?

>  
>  static unsigned long __meminitdata nr_kernel_pages;
>  static unsigned long __meminitdata nr_all_pages;
> @@ -5592,14 +5593,21 @@ static void __meminit setup_per_zone_inactive_ratio(void)
>  int __meminit init_per_zone_wmark_min(void)
>  {
>  	unsigned long lowmem_kbytes;
> +	int new_min_free_kbytes;
>  
>  	lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
> -
> -	min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
> -	if (min_free_kbytes < 128)
> -		min_free_kbytes = 128;
> -	if (min_free_kbytes > 65536)
> -		min_free_kbytes = 65536;
> +	new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
> +
> +	if (new_min_free_kbytes > user_min_free_kbytes) {
> +		min_free_kbytes = new_min_free_kbytes;
> +		if (min_free_kbytes < 128)
> +			min_free_kbytes = 128;
> +		if (min_free_kbytes > 65536)
> +			min_free_kbytes = 65536;
> +	} else {
> +		pr_warn("min_free_kbytes is not updated to %d because user defined value %d is preferred\n",
> +				new_min_free_kbytes, user_min_free_kbytes);
> +	}
>  	setup_per_zone_wmarks();
>  	refresh_zone_stat_thresholds();
>  	setup_per_zone_lowmem_reserve();
> @@ -5617,8 +5625,10 @@ int min_free_kbytes_sysctl_handler(ctl_table *table, int write,
>  	void __user *buffer, size_t *length, loff_t *ppos)
>  {
>  	proc_dointvec(table, write, buffer, length, ppos);
> -	if (write)
> +	if (write) {
> +		user_min_free_kbytes = min_free_kbytes;
>  		setup_per_zone_wmarks();
> +	}
>  	return 0;
>  }
>  
> 

-- 
Jiri Kosina
SUSE Labs


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

* Re: [RFC] mm: Honor min_free_kbytes set by user
@ 2013-07-09 23:40         ` Jiri Kosina
  0 siblings, 0 replies; 16+ messages in thread
From: Jiri Kosina @ 2013-07-09 23:40 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Joe Perches, Andrew Morton, Mel Gorman, KOSAKI Motohiro,
	linux-mm, linux-kernel

On Thu, 4 Jul 2013, Michal Hocko wrote:

> On Thu 04-07-13 18:16:41, Michal Hocko wrote:
> > On Thu 04-07-13 09:10:39, Joe Perches wrote:
> > > On Thu, 2013-07-04 at 18:07 +0200, Michal Hocko wrote:
> > > > A warning is printed when the new value is ignored.
> > > 
> > > []
> > > 
> > > > +		printk(KERN_WARNING "min_free_kbytes is not updated to %d"
> > > > +				"because user defined value %d is preferred\n",
> > > > +				new_min_free_kbytes, user_min_free_kbytes);
> > > 
> > > Please use pr_warn and coalesce the format.
> > 
> > Sure can do that. mm/page_alloc.c doesn't seem to be unified in that
> > regards (44 printks and only 4 pr_<foo>) so I used printk.
> > 
> > > You'd've noticed a missing space between %d and because.
> > 
> > True
> > 
> 
> Checkpatch fixes
> ---
> >From 5f089c0b2a57ff6c08710ac9698d65aede06079f Mon Sep 17 00:00:00 2001
> From: Michal Hocko <mhocko@suse.cz>
> Date: Thu, 4 Jul 2013 17:15:54 +0200
> Subject: [PATCH] mm: Honor min_free_kbytes set by user
> 
> min_free_kbytes is updated during memory hotplug (by init_per_zone_wmark_min)
> currently which is right thing to do in most cases but this could be
> unexpected if admin increased the value to prevent from allocation
> failures and the new min_free_kbytes would be decreased as a result of
> memory hotadd.
> 
> This patch saves the user defined value and allows updating
> min_free_kbytes only if it is higher than the saved one.
> 
> A warning is printed when the new value is ignored.
> 
> Signed-off-by: Michal Hocko <mhocko@suse.cz>
> ---
>  mm/page_alloc.c | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 22c528e..9c011fc 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -204,6 +204,7 @@ static char * const zone_names[MAX_NR_ZONES] = {
>  };
>  
>  int min_free_kbytes = 1024;
> +int user_min_free_kbytes;

Minor nit: any reason this can't be static?

>  
>  static unsigned long __meminitdata nr_kernel_pages;
>  static unsigned long __meminitdata nr_all_pages;
> @@ -5592,14 +5593,21 @@ static void __meminit setup_per_zone_inactive_ratio(void)
>  int __meminit init_per_zone_wmark_min(void)
>  {
>  	unsigned long lowmem_kbytes;
> +	int new_min_free_kbytes;
>  
>  	lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
> -
> -	min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
> -	if (min_free_kbytes < 128)
> -		min_free_kbytes = 128;
> -	if (min_free_kbytes > 65536)
> -		min_free_kbytes = 65536;
> +	new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
> +
> +	if (new_min_free_kbytes > user_min_free_kbytes) {
> +		min_free_kbytes = new_min_free_kbytes;
> +		if (min_free_kbytes < 128)
> +			min_free_kbytes = 128;
> +		if (min_free_kbytes > 65536)
> +			min_free_kbytes = 65536;
> +	} else {
> +		pr_warn("min_free_kbytes is not updated to %d because user defined value %d is preferred\n",
> +				new_min_free_kbytes, user_min_free_kbytes);
> +	}
>  	setup_per_zone_wmarks();
>  	refresh_zone_stat_thresholds();
>  	setup_per_zone_lowmem_reserve();
> @@ -5617,8 +5625,10 @@ int min_free_kbytes_sysctl_handler(ctl_table *table, int write,
>  	void __user *buffer, size_t *length, loff_t *ppos)
>  {
>  	proc_dointvec(table, write, buffer, length, ppos);
> -	if (write)
> +	if (write) {
> +		user_min_free_kbytes = min_free_kbytes;
>  		setup_per_zone_wmarks();
> +	}
>  	return 0;
>  }
>  
> 

-- 
Jiri Kosina
SUSE Labs

--
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] 16+ messages in thread

* Re: [RFC] mm: Honor min_free_kbytes set by user
  2013-07-09 23:40         ` Jiri Kosina
@ 2013-07-10  6:57           ` Michal Hocko
  -1 siblings, 0 replies; 16+ messages in thread
From: Michal Hocko @ 2013-07-10  6:57 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Joe Perches, Andrew Morton, Mel Gorman, KOSAKI Motohiro,
	linux-mm, linux-kernel

On Wed 10-07-13 01:40:06, Jiri Kosina wrote:
> On Thu, 4 Jul 2013, Michal Hocko wrote:
[...]
> > >From 5f089c0b2a57ff6c08710ac9698d65aede06079f Mon Sep 17 00:00:00 2001
> > From: Michal Hocko <mhocko@suse.cz>
> > Date: Thu, 4 Jul 2013 17:15:54 +0200
> > Subject: [PATCH] mm: Honor min_free_kbytes set by user
> > 
> > min_free_kbytes is updated during memory hotplug (by init_per_zone_wmark_min)
> > currently which is right thing to do in most cases but this could be
> > unexpected if admin increased the value to prevent from allocation
> > failures and the new min_free_kbytes would be decreased as a result of
> > memory hotadd.
> > 
> > This patch saves the user defined value and allows updating
> > min_free_kbytes only if it is higher than the saved one.
> > 
> > A warning is printed when the new value is ignored.
> > 
> > Signed-off-by: Michal Hocko <mhocko@suse.cz>
> > ---
> >  mm/page_alloc.c | 24 +++++++++++++++++-------
> >  1 file changed, 17 insertions(+), 7 deletions(-)
> > 
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 22c528e..9c011fc 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -204,6 +204,7 @@ static char * const zone_names[MAX_NR_ZONES] = {
> >  };
> >  
> >  int min_free_kbytes = 1024;
> > +int user_min_free_kbytes;
> 
> Minor nit: any reason this can't be static?

Yes, it can and should be static. Care to queue a fix in your trivial
tree? I can post a fix if you want.

Thanks
-- 
Michal Hocko
SUSE Labs

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

* Re: [RFC] mm: Honor min_free_kbytes set by user
@ 2013-07-10  6:57           ` Michal Hocko
  0 siblings, 0 replies; 16+ messages in thread
From: Michal Hocko @ 2013-07-10  6:57 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Joe Perches, Andrew Morton, Mel Gorman, KOSAKI Motohiro,
	linux-mm, linux-kernel

On Wed 10-07-13 01:40:06, Jiri Kosina wrote:
> On Thu, 4 Jul 2013, Michal Hocko wrote:
[...]
> > >From 5f089c0b2a57ff6c08710ac9698d65aede06079f Mon Sep 17 00:00:00 2001
> > From: Michal Hocko <mhocko@suse.cz>
> > Date: Thu, 4 Jul 2013 17:15:54 +0200
> > Subject: [PATCH] mm: Honor min_free_kbytes set by user
> > 
> > min_free_kbytes is updated during memory hotplug (by init_per_zone_wmark_min)
> > currently which is right thing to do in most cases but this could be
> > unexpected if admin increased the value to prevent from allocation
> > failures and the new min_free_kbytes would be decreased as a result of
> > memory hotadd.
> > 
> > This patch saves the user defined value and allows updating
> > min_free_kbytes only if it is higher than the saved one.
> > 
> > A warning is printed when the new value is ignored.
> > 
> > Signed-off-by: Michal Hocko <mhocko@suse.cz>
> > ---
> >  mm/page_alloc.c | 24 +++++++++++++++++-------
> >  1 file changed, 17 insertions(+), 7 deletions(-)
> > 
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 22c528e..9c011fc 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -204,6 +204,7 @@ static char * const zone_names[MAX_NR_ZONES] = {
> >  };
> >  
> >  int min_free_kbytes = 1024;
> > +int user_min_free_kbytes;
> 
> Minor nit: any reason this can't be static?

Yes, it can and should be static. Care to queue a fix in your trivial
tree? I can post a fix if you want.

Thanks
-- 
Michal Hocko
SUSE Labs

--
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] 16+ messages in thread

end of thread, other threads:[~2013-07-10  6:57 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-04 16:07 [RFC] mm: Honor min_free_kbytes set by user Michal Hocko
2013-07-04 16:07 ` Michal Hocko
2013-07-04 16:10 ` Joe Perches
2013-07-04 16:10   ` Joe Perches
2013-07-04 16:16   ` Michal Hocko
2013-07-04 16:16     ` Michal Hocko
2013-07-04 16:20     ` Michal Hocko
2013-07-04 16:20       ` Michal Hocko
2013-07-04 16:35       ` Zhang Yanfei
2013-07-04 16:35         ` Zhang Yanfei
2013-07-08 18:48       ` KOSAKI Motohiro
2013-07-08 18:48         ` KOSAKI Motohiro
2013-07-09 23:40       ` Jiri Kosina
2013-07-09 23:40         ` Jiri Kosina
2013-07-10  6:57         ` Michal Hocko
2013-07-10  6:57           ` Michal Hocko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.