linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -mmotm] mm: init_per_zone_pages_min - get rid of sqrt call on small machines
@ 2009-05-06  6:19 Cyrill Gorcunov
  2009-05-06  6:36 ` David Rientjes
  0 siblings, 1 reply; 3+ messages in thread
From: Cyrill Gorcunov @ 2009-05-06  6:19 UTC (permalink / raw)
  To: Andrew Morton, David Rientjes; +Cc: LMMML, LKML

For small machines we may eliminate call for int_sqrt
by using precaulculated value.

CC: David Rientjes <rientjes@google.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 mm/page_alloc.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Index: linux-2.6.git/mm/page_alloc.c
=====================================================================
--- linux-2.6.git.orig/mm/page_alloc.c
+++ linux-2.6.git/mm/page_alloc.c
@@ -4610,11 +4610,15 @@ static int __init init_per_zone_pages_mi
 
 	lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
 
-	min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
-	if (min_free_kbytes < 128)
+	/* for small values we may eliminate sqrt operation completely */
+	if (lowmem_kbytes < 1024)
 		min_free_kbytes = 128;
-	if (min_free_kbytes > 65536)
-		min_free_kbytes = 65536;
+	else {
+		min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
+		if (min_free_kbytes > 65536)
+			min_free_kbytes = 65536;
+	}
+
 	setup_per_zone_pages_min();
 	setup_per_zone_lowmem_reserve();
 	setup_per_zone_inactive_ratio();

--
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 -mmotm] mm: init_per_zone_pages_min - get rid of sqrt call on small machines
  2009-05-06  6:19 [PATCH -mmotm] mm: init_per_zone_pages_min - get rid of sqrt call on small machines Cyrill Gorcunov
@ 2009-05-06  6:36 ` David Rientjes
  2009-05-06  6:44   ` Cyrill Gorcunov
  0 siblings, 1 reply; 3+ messages in thread
From: David Rientjes @ 2009-05-06  6:36 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: Andrew Morton, LMMML, LKML

On Wed, 6 May 2009, Cyrill Gorcunov wrote:

> Index: linux-2.6.git/mm/page_alloc.c
> =====================================================================
> --- linux-2.6.git.orig/mm/page_alloc.c
> +++ linux-2.6.git/mm/page_alloc.c
> @@ -4610,11 +4610,15 @@ static int __init init_per_zone_pages_mi
>  
>  	lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
>  
> -	min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
> -	if (min_free_kbytes < 128)
> +	/* for small values we may eliminate sqrt operation completely */
> +	if (lowmem_kbytes < 1024)
>  		min_free_kbytes = 128;
> -	if (min_free_kbytes > 65536)
> -		min_free_kbytes = 65536;
> +	else {
> +		min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
> +		if (min_free_kbytes > 65536)
> +			min_free_kbytes = 65536;
> +	}
> +
>  	setup_per_zone_pages_min();
>  	setup_per_zone_lowmem_reserve();
>  	setup_per_zone_inactive_ratio();

For a function that's called once, this just isn't worth it.  int_sqrt() 
isn't expensive enough to warrant the assault on the readability of the 
code.

--
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 -mmotm] mm: init_per_zone_pages_min - get rid of sqrt call on small machines
  2009-05-06  6:36 ` David Rientjes
@ 2009-05-06  6:44   ` Cyrill Gorcunov
  0 siblings, 0 replies; 3+ messages in thread
From: Cyrill Gorcunov @ 2009-05-06  6:44 UTC (permalink / raw)
  To: David Rientjes; +Cc: Andrew Morton, LMMML, LKML

[David Rientjes - Tue, May 05, 2009 at 11:36:38PM -0700]
| On Wed, 6 May 2009, Cyrill Gorcunov wrote:
| 
| > Index: linux-2.6.git/mm/page_alloc.c
| > =====================================================================
| > --- linux-2.6.git.orig/mm/page_alloc.c
| > +++ linux-2.6.git/mm/page_alloc.c
| > @@ -4610,11 +4610,15 @@ static int __init init_per_zone_pages_mi
| >  
| >  	lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
| >  
| > -	min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
| > -	if (min_free_kbytes < 128)
| > +	/* for small values we may eliminate sqrt operation completely */
| > +	if (lowmem_kbytes < 1024)
| >  		min_free_kbytes = 128;
| > -	if (min_free_kbytes > 65536)
| > -		min_free_kbytes = 65536;
| > +	else {
| > +		min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
| > +		if (min_free_kbytes > 65536)
| > +			min_free_kbytes = 65536;
| > +	}
| > +
| >  	setup_per_zone_pages_min();
| >  	setup_per_zone_lowmem_reserve();
| >  	setup_per_zone_inactive_ratio();
| 
| For a function that's called once, this just isn't worth it.  int_sqrt() 
| isn't expensive enough to warrant the assault on the readability of the 
| code.
| 

ok, then we could just drop it.

	-- Cyrill

--
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

end of thread, other threads:[~2009-05-06  6:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-06  6:19 [PATCH -mmotm] mm: init_per_zone_pages_min - get rid of sqrt call on small machines Cyrill Gorcunov
2009-05-06  6:36 ` David Rientjes
2009-05-06  6:44   ` Cyrill Gorcunov

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).