diff options
author | Benjamin LaHaise <bcrl@kvack.org> | 2006-01-03 17:10:46 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-01-03 17:10:46 -0500 |
commit | fd19f329a32bdc4eb07885e0b3889567cfe00aa7 (patch) | |
tree | c69943e8294cae13df6af3dc8b8c25abab8c9cfb | |
parent | 4947d3ef8de7b4f42aed6ea9ba689dc8fb45b5a5 (diff) |
[AF_UNIX]: Convert to use a spinlock instead of rwlock
From: Benjamin LaHaise <bcrl@kvack.org>
In af_unix, a rwlock is used to protect internal state. At least on my
P4 with HT it is faster to use a spinlock due to the simpler memory
barrier used to unlock. This patch raises bw_unix to ~690K/s.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/af_unix.h | 10 | ||||
-rw-r--r-- | net/unix/af_unix.c | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 3f302ae98c03..bfc1779fc753 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h | |||
@@ -58,10 +58,10 @@ struct unix_skb_parms { | |||
58 | #define UNIXCB(skb) (*(struct unix_skb_parms*)&((skb)->cb)) | 58 | #define UNIXCB(skb) (*(struct unix_skb_parms*)&((skb)->cb)) |
59 | #define UNIXCREDS(skb) (&UNIXCB((skb)).creds) | 59 | #define UNIXCREDS(skb) (&UNIXCB((skb)).creds) |
60 | 60 | ||
61 | #define unix_state_rlock(s) read_lock(&unix_sk(s)->lock) | 61 | #define unix_state_rlock(s) spin_lock(&unix_sk(s)->lock) |
62 | #define unix_state_runlock(s) read_unlock(&unix_sk(s)->lock) | 62 | #define unix_state_runlock(s) spin_unlock(&unix_sk(s)->lock) |
63 | #define unix_state_wlock(s) write_lock(&unix_sk(s)->lock) | 63 | #define unix_state_wlock(s) spin_lock(&unix_sk(s)->lock) |
64 | #define unix_state_wunlock(s) write_unlock(&unix_sk(s)->lock) | 64 | #define unix_state_wunlock(s) spin_unlock(&unix_sk(s)->lock) |
65 | 65 | ||
66 | #ifdef __KERNEL__ | 66 | #ifdef __KERNEL__ |
67 | /* The AF_UNIX socket */ | 67 | /* The AF_UNIX socket */ |
@@ -76,7 +76,7 @@ struct unix_sock { | |||
76 | struct sock *other; | 76 | struct sock *other; |
77 | struct sock *gc_tree; | 77 | struct sock *gc_tree; |
78 | atomic_t inflight; | 78 | atomic_t inflight; |
79 | rwlock_t lock; | 79 | spinlock_t lock; |
80 | wait_queue_head_t peer_wait; | 80 | wait_queue_head_t peer_wait; |
81 | }; | 81 | }; |
82 | #define unix_sk(__sk) ((struct unix_sock *)__sk) | 82 | #define unix_sk(__sk) ((struct unix_sock *)__sk) |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 7d3fe6aebcdb..1ddd36d50091 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -564,7 +564,7 @@ static struct sock * unix_create1(struct socket *sock) | |||
564 | u = unix_sk(sk); | 564 | u = unix_sk(sk); |
565 | u->dentry = NULL; | 565 | u->dentry = NULL; |
566 | u->mnt = NULL; | 566 | u->mnt = NULL; |
567 | rwlock_init(&u->lock); | 567 | spin_lock_init(&u->lock); |
568 | atomic_set(&u->inflight, sock ? 0 : -1); | 568 | atomic_set(&u->inflight, sock ? 0 : -1); |
569 | init_MUTEX(&u->readsem); /* single task reading lock */ | 569 | init_MUTEX(&u->readsem); /* single task reading lock */ |
570 | init_waitqueue_head(&u->peer_wait); | 570 | init_waitqueue_head(&u->peer_wait); |