lkml.org 
[lkml]   [2009]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH -mmotm] mm: init_per_zone_pages_min - get rid of sqrt call on small machines
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.


\
 
 \ /
  Last update: 2009-05-06 08:39    [W:0.030 / U:3.456 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site