From: Peter Zijlstra <peterz@infradead.org>
To: Soumyadip Das Mahapatra <soumya.linux@yahoo.com>
Cc: linux-kernel@vger.kernel.org,
Lennart Sorensen <lsorense@csclub.uwaterloo.ca>
Subject: Re: [PATCH] : A better approach to compute int_sqrt in lib/int_sqrt.c
Date: Thu, 17 Jul 2008 20:26:55 +0200 [thread overview]
Message-ID: <1216319215.5232.116.camel@twins> (raw)
In-Reply-To: <848307.13278.qm@web59505.mail.ac4.yahoo.com>
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.
next prev parent reply other threads:[~2008-07-17 18:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-16 21:35 [PATCH] : A better approach to compute int_sqrt in lib/int_sqrt.c Soumyadip Das Mahapatra
2008-07-16 22:05 ` Lennart Sorensen
2008-07-17 18:00 ` Lennart Sorensen
2008-07-17 4:08 ` Vadim Lobanov
2008-07-17 18:10 ` Lennart Sorensen
2008-07-17 18:26 ` Peter Zijlstra [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-07-16 20:19 Soumyadip Das Mahapatra
2008-07-16 20:51 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1216319215.5232.116.camel@twins \
--to=peterz@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lsorense@csclub.uwaterloo.ca \
--cc=soumya.linux@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox