From: Eric Dumazet <dada1@cosmosbay.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Use unsigned int types for a faster bsearch
Date: Mon, 20 Mar 2006 20:09:57 +0100 [thread overview]
Message-ID: <441EFE05.8040506@cosmosbay.com> (raw)
In-Reply-To: <4417E047.70907@cosmosbay.com>
[-- Attachment #1: Type: text/plain, Size: 574 bytes --]
This patch avoids arithmetic on 'signed' types that are slower than
'unsigned'. This saves space and cpu cycles.
size of kernel/sys.o before the patch (gcc-3.4.5)
text data bss dec hex filename
10924 252 4 11180 2bac kernel/sys.o
size of kernel/sys.o after the patch
text data bss dec hex filename
10903 252 4 11159 2b97 kernel/sys.o
I noticed that gcc-4.1.0 (from Fedora Core 5) even uses idiv instruction for
(a+b)/2 if a and b are signed.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
[-- Attachment #2: groups_search.patch --]
[-- Type: text/plain, Size: 540 bytes --]
--- a/kernel/sys.c 2006-03-20 18:42:41.000000000 +0100
+++ b/kernel/sys.c 2006-03-20 19:00:43.000000000 +0100
@@ -1375,7 +1375,7 @@
/* a simple bsearch */
int groups_search(struct group_info *group_info, gid_t grp)
{
- int left, right;
+ unsigned int left, right;
if (!group_info)
return 0;
@@ -1383,7 +1383,7 @@
left = 0;
right = group_info->ngroups;
while (left < right) {
- int mid = (left+right)/2;
+ unsigned int mid = (left+right)/2;
int cmp = grp - GROUP_AT(group_info, mid);
if (cmp > 0)
left = mid + 1;
next prev parent reply other threads:[~2006-03-20 19:10 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-12 2:04 More than 8 CPUs detected and CONFIG_X86_PC cannot handle it on 2.6.16-rc6 Krzysztof Oledzki
2006-03-12 5:03 ` Andrew Morton
2006-03-12 11:04 ` Krzysztof Oledzki
2006-03-12 11:25 ` Andrew Morton
2006-03-12 13:05 ` Krzysztof Oledzki
2006-03-12 15:35 ` Venkatesh Pallipadi
2006-03-12 21:13 ` Krzysztof Oledzki
2006-03-12 22:30 ` Andrew Morton
2006-03-13 19:36 ` Ashok Raj
2006-03-13 19:51 ` Andrew Morton
2006-03-13 20:05 ` Ashok Raj
2006-03-13 22:22 ` Andrew Morton
2006-03-13 23:04 ` Ashok Raj
2006-03-15 5:44 ` Nathan Lynch
2006-03-15 6:18 ` Shaohua Li
2006-03-15 7:31 ` Andrew Morton
2006-03-15 9:37 ` [PATCH] No need to protect current->group_info in sys_getgroups(), in_group_p() and in_egroup_p() Eric Dumazet
2006-03-20 19:09 ` Eric Dumazet [this message]
2006-03-22 5:06 ` [PATCH] Use __read_mostly on some hot fs variables Eric Dumazet
2006-03-22 5:15 ` Nick Piggin
2006-03-22 6:23 ` [RFC, PATCH] avoid some atomics in open()/close() for monothreaded processes Eric Dumazet
2006-03-22 6:41 ` Andrew Morton
2006-03-22 6:59 ` Eric Dumazet
2006-03-22 7:03 ` Andrew Morton
2006-03-15 18:09 ` More than 8 CPUs detected and CONFIG_X86_PC cannot handle it on 2.6.16-rc6 Ashok Raj
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=441EFE05.8040506@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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