diff options
author | Greg Banks <gnb@melbourne.sgi.com> | 2006-10-04 05:15:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-04 10:55:16 -0400 |
commit | 7b2b1fee30df7e2165525cd03f7d1d01a3a56794 (patch) | |
tree | 71740fb9ea88465b54c52d998eadd012a6f8f4a6 /net | |
parent | fce1456a19f5c08b688c29f00ef90fdfa074c79b (diff) |
[PATCH] knfsd: knfsd: cache ipmap per TCP socket
Speed up high call-rate workloads by caching the struct ip_map for the peer on
the connected struct svc_sock instead of looking it up in the ip_map cache
hashtable on every call. This helps workloads using AUTH_SYS authentication
over TCP.
Testing was on a 4 CPU 4 NIC Altix using 4 IRIX clients, each with 16
synthetic client threads simulating an rsync (i.e. recursive directory
listing) workload reading from an i386 RH9 install image (161480 regular files
in 10841 directories) on the server. That tree is small enough to fill in the
server's RAM so no disk traffic was involved. This setup gives a sustained
call rate in excess of 60000 calls/sec before being CPU-bound on the server.
Profiling showed strcmp(), called from ip_map_match(), was taking 4.8% of each
CPU, and ip_map_lookup() was taking 2.9%. This patch drops both contribution
into the profile noise.
Note that the above result overstates this value of this patch for most
workloads. The synthetic clients are all using separate IP addresses, so
there are 64 entries in the ip_map cache hash. Because the kernel measured
contained the bug fixed in commit
commit 1f1e030bf75774b6a283518e1534d598e14147d4
and was running on 64bit little-endian machine, probably all of those 64
entries were on a single chain, thus increasing the cost of ip_map_lookup().
With a modern kernel you would need more clients to see the same amount of
performance improvement. This patch has helped to scale knfsd to handle a
deployment with 2000 NFS clients.
Signed-off-by: Greg Banks <gnb@melbourne.sgi.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/svcauth_unix.c | 47 | ||||
-rw-r--r-- | net/sunrpc/svcsock.c | 2 |
2 files changed, 46 insertions, 3 deletions
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index 40d41a2831d7..e1bd933629fe 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/net/sunrpc/svcauth_unix.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/seq_file.h> | 9 | #include <linux/seq_file.h> |
10 | #include <linux/hash.h> | 10 | #include <linux/hash.h> |
11 | #include <linux/string.h> | 11 | #include <linux/string.h> |
12 | #include <net/sock.h> | ||
12 | 13 | ||
13 | #define RPCDBG_FACILITY RPCDBG_AUTH | 14 | #define RPCDBG_FACILITY RPCDBG_AUTH |
14 | 15 | ||
@@ -375,6 +376,44 @@ void svcauth_unix_purge(void) | |||
375 | cache_purge(&ip_map_cache); | 376 | cache_purge(&ip_map_cache); |
376 | } | 377 | } |
377 | 378 | ||
379 | static inline struct ip_map * | ||
380 | ip_map_cached_get(struct svc_rqst *rqstp) | ||
381 | { | ||
382 | struct ip_map *ipm = rqstp->rq_sock->sk_info_authunix; | ||
383 | if (ipm != NULL) { | ||
384 | if (!cache_valid(&ipm->h)) { | ||
385 | /* | ||
386 | * The entry has been invalidated since it was | ||
387 | * remembered, e.g. by a second mount from the | ||
388 | * same IP address. | ||
389 | */ | ||
390 | rqstp->rq_sock->sk_info_authunix = NULL; | ||
391 | cache_put(&ipm->h, &ip_map_cache); | ||
392 | return NULL; | ||
393 | } | ||
394 | cache_get(&ipm->h); | ||
395 | } | ||
396 | return ipm; | ||
397 | } | ||
398 | |||
399 | static inline void | ||
400 | ip_map_cached_put(struct svc_rqst *rqstp, struct ip_map *ipm) | ||
401 | { | ||
402 | struct svc_sock *svsk = rqstp->rq_sock; | ||
403 | |||
404 | if (svsk->sk_sock->type == SOCK_STREAM && svsk->sk_info_authunix == NULL) | ||
405 | svsk->sk_info_authunix = ipm; /* newly cached, keep the reference */ | ||
406 | else | ||
407 | cache_put(&ipm->h, &ip_map_cache); | ||
408 | } | ||
409 | |||
410 | void | ||
411 | svcauth_unix_info_release(void *info) | ||
412 | { | ||
413 | struct ip_map *ipm = info; | ||
414 | cache_put(&ipm->h, &ip_map_cache); | ||
415 | } | ||
416 | |||
378 | static int | 417 | static int |
379 | svcauth_unix_set_client(struct svc_rqst *rqstp) | 418 | svcauth_unix_set_client(struct svc_rqst *rqstp) |
380 | { | 419 | { |
@@ -384,8 +423,10 @@ svcauth_unix_set_client(struct svc_rqst *rqstp) | |||
384 | if (rqstp->rq_proc == 0) | 423 | if (rqstp->rq_proc == 0) |
385 | return SVC_OK; | 424 | return SVC_OK; |
386 | 425 | ||
387 | ipm = ip_map_lookup(rqstp->rq_server->sv_program->pg_class, | 426 | ipm = ip_map_cached_get(rqstp); |
388 | rqstp->rq_addr.sin_addr); | 427 | if (ipm == NULL) |
428 | ipm = ip_map_lookup(rqstp->rq_server->sv_program->pg_class, | ||
429 | rqstp->rq_addr.sin_addr); | ||
389 | 430 | ||
390 | if (ipm == NULL) | 431 | if (ipm == NULL) |
391 | return SVC_DENIED; | 432 | return SVC_DENIED; |
@@ -400,7 +441,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp) | |||
400 | case 0: | 441 | case 0: |
401 | rqstp->rq_client = &ipm->m_client->h; | 442 | rqstp->rq_client = &ipm->m_client->h; |
402 | kref_get(&rqstp->rq_client->ref); | 443 | kref_get(&rqstp->rq_client->ref); |
403 | cache_put(&ipm->h, &ip_map_cache); | 444 | ip_map_cached_put(rqstp, ipm); |
404 | break; | 445 | break; |
405 | } | 446 | } |
406 | return SVC_OK; | 447 | return SVC_OK; |
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 1d512337ccd9..b39e7e2b648f 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c | |||
@@ -1610,6 +1610,8 @@ svc_delete_socket(struct svc_sock *svsk) | |||
1610 | sockfd_put(svsk->sk_sock); | 1610 | sockfd_put(svsk->sk_sock); |
1611 | else | 1611 | else |
1612 | sock_release(svsk->sk_sock); | 1612 | sock_release(svsk->sk_sock); |
1613 | if (svsk->sk_info_authunix != NULL) | ||
1614 | svcauth_unix_info_release(svsk->sk_info_authunix); | ||
1613 | kfree(svsk); | 1615 | kfree(svsk); |
1614 | } else { | 1616 | } else { |
1615 | spin_unlock_bh(&serv->sv_lock); | 1617 | spin_unlock_bh(&serv->sv_lock); |