From: Eric Dumazet <dada1@resalehost.networksolutions.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] No need to protect current->group_info in sys_getgroups(), in_group_p() and in_egroup_p()
Date: Wed, 15 Mar 2006 10:37:11 +0100 [thread overview]
Message-ID: <4417E047.70907@cosmosbay.com> (raw)
In-Reply-To: <20060314233138.009414b4.akpm@osdl.org>
[-- Attachment #1: Type: text/plain, Size: 887 bytes --]
While doing some benchmarks of an Apache/PHP SMP server, I noticed high
oprofile numbers in in_group_p() and _atomic_dec_and_lock().
rank percent
1 4.8911 % __link_path_walk
2 4.8503 % __d_lookup
*3 4.2911 % _atomic_dec_and_lock
4 3.9307 % __copy_to_user_ll
5 4.9004 % sysenter_past_esp
*6 3.3248 % in_group_p
It appears that in_group_p() does an uncessary
get_group_info(current->group_info); /* atomic_inc() */
... /* access current->group_info */
put_group_info(current->group_info); /* _atomic_dec_and_lock */
It is not necessary to do this, because the current task holds a reference on
its own group_info, and this reference cannot change during the lookup.
This patch deletes the get_group_info()/put_group_info() pair from
sys_getgroups(), in_group_p() and in_egroup_p() functions.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
[-- Attachment #2: kernel_sys.patch --]
[-- Type: text/plain, Size: 884 bytes --]
--- a/kernel/sys.c 2006-03-15 10:14:37.000000000 +0100
+++ b/kernel/sys.c 2006-03-15 10:15:55.000000000 +0100
@@ -1433,7 +1433,6 @@
return -EINVAL;
/* no need to grab task_lock here; it cannot change */
- get_group_info(current->group_info);
i = current->group_info->ngroups;
if (gidsetsize) {
if (i > gidsetsize) {
@@ -1446,7 +1445,6 @@
}
}
out:
- put_group_info(current->group_info);
return i;
}
@@ -1487,9 +1485,7 @@
{
int retval = 1;
if (grp != current->fsgid) {
- get_group_info(current->group_info);
retval = groups_search(current->group_info, grp);
- put_group_info(current->group_info);
}
return retval;
}
@@ -1500,9 +1496,7 @@
{
int retval = 1;
if (grp != current->egid) {
- get_group_info(current->group_info);
retval = groups_search(current->group_info, grp);
- put_group_info(current->group_info);
}
return retval;
}
next prev parent reply other threads:[~2006-03-15 9:37 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 ` Eric Dumazet [this message]
2006-03-20 19:09 ` [PATCH] Use unsigned int types for a faster bsearch Eric Dumazet
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=4417E047.70907@cosmosbay.com \
--to=dada1@resalehost.networksolutions.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.