lkml.org 
[lkml]   [2008]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] : A better approach to compute int_sqrt in lib/int_sqrt.c
From
Date
On Wed, 2008-07-16 at 14:35 -0700, Soumyadip Das Mahapatra wrote:


> 0 It is better because
> o it uses only one loop instead of two
> o contains no division operator (older version has two)
> which are surely comparatively slow task in computer

As Lennart has said, gcc is smart enough to transform a division by a
power-of-two into shifts.

> 0 Currently find . -name '*.[ch]' | xargs grep int_sqrt gives me this
> ....
> ./fs/nfs/write.c: nfs_congestion_kb = (16*int_sqrt(totalram_pages)) << (PAGE_SHIFT-10);
> ./drivers/video/fbmon.c: h_period = int_sqrt(h_period);
> ./mm/page_alloc.c: min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
> ./mm/oom_kill.c: s = int_sqrt(cpu_time);
> ./mm/oom_kill.c: s = int_sqrt(int_sqrt(run_time));
> ....

fs/nfs/write.c is init code
mm/page_alloc.c is also init code
mm/oom_kill.c isn't a hot path

which leaves the fbmon case, which after a quick peek is setup code, so
not a hot path either.

So while that doesn't preclude us from changing it if you can indeed
show its a better implementation, its not on anybodies hit-list.



\
 
 \ /
  Last update: 2008-07-17 20:29    [W:0.050 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site