Re: [PATCH] : A better approach to compute int_sqrt inlib/int_sqrt.c

From: Peter Zijlstra
Date: Thu Jul 17 2008 - 14:26:39 EST


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.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/