aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2008-11-20 16:06:21 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-11-20 16:17:40 -0500
commit23918b03060f6e572168fdde1798a905679d2e06 (patch)
tree4e95edb5030e461a1eb82e2f1fb9cb90a3b46013
parent0cb39aa0ac3a9dc64171b43a85d17e539d82f2d6 (diff)
SUNRPC: Fix a performance regression in the RPC authentication code
Fix a regression reported by Max Kellermann whereby kernel profiling showed that his clients were spending 45% of their time in rpcauth_lookup_credcache. It turns out that although his processes had identical uid/gid/groups, generic_match() was failing to detect this, because the task->group_info pointers were not shared. This again lead to the creation of a huge number of identical credentials at the RPC layer. The regression is fixed by comparing the contents of task->group_info if the actual pointers are not identical. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--net/sunrpc/auth_generic.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c
index 744b79fdcb19..4028502f0528 100644
--- a/net/sunrpc/auth_generic.c
+++ b/net/sunrpc/auth_generic.c
@@ -133,13 +133,29 @@ static int
133generic_match(struct auth_cred *acred, struct rpc_cred *cred, int flags) 133generic_match(struct auth_cred *acred, struct rpc_cred *cred, int flags)
134{ 134{
135 struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base); 135 struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base);
136 int i;
136 137
137 if (gcred->acred.uid != acred->uid || 138 if (gcred->acred.uid != acred->uid ||
138 gcred->acred.gid != acred->gid || 139 gcred->acred.gid != acred->gid ||
139 gcred->acred.group_info != acred->group_info ||
140 gcred->acred.machine_cred != acred->machine_cred) 140 gcred->acred.machine_cred != acred->machine_cred)
141 return 0; 141 goto out_nomatch;
142
143 /* Optimisation in the case where pointers are identical... */
144 if (gcred->acred.group_info == acred->group_info)
145 goto out_match;
146
147 /* Slow path... */
148 if (gcred->acred.group_info->ngroups != acred->group_info->ngroups)
149 goto out_nomatch;
150 for (i = 0; i < gcred->acred.group_info->ngroups; i++) {
151 if (GROUP_AT(gcred->acred.group_info, i) !=
152 GROUP_AT(acred->group_info, i))
153 goto out_nomatch;
154 }
155out_match:
142 return 1; 156 return 1;
157out_nomatch:
158 return 0;
143} 159}
144 160
145void __init rpc_init_generic_auth(void) 161void __init rpc_init_generic_auth(void)