Commit fd19f329 authored by Benjamin LaHaise's avatar Benjamin LaHaise Committed by David S. Miller

[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: default avatarDavid S. Miller <davem@davemloft.net>
parent 4947d3ef
...@@ -58,10 +58,10 @@ struct unix_skb_parms { ...@@ -58,10 +58,10 @@ struct unix_skb_parms {
#define UNIXCB(skb) (*(struct unix_skb_parms*)&((skb)->cb)) #define UNIXCB(skb) (*(struct unix_skb_parms*)&((skb)->cb))
#define UNIXCREDS(skb) (&UNIXCB((skb)).creds) #define UNIXCREDS(skb) (&UNIXCB((skb)).creds)
#define unix_state_rlock(s) read_lock(&unix_sk(s)->lock) #define unix_state_rlock(s) spin_lock(&unix_sk(s)->lock)
#define unix_state_runlock(s) read_unlock(&unix_sk(s)->lock) #define unix_state_runlock(s) spin_unlock(&unix_sk(s)->lock)
#define unix_state_wlock(s) write_lock(&unix_sk(s)->lock) #define unix_state_wlock(s) spin_lock(&unix_sk(s)->lock)
#define unix_state_wunlock(s) write_unlock(&unix_sk(s)->lock) #define unix_state_wunlock(s) spin_unlock(&unix_sk(s)->lock)
#ifdef __KERNEL__ #ifdef __KERNEL__
/* The AF_UNIX socket */ /* The AF_UNIX socket */
...@@ -76,7 +76,7 @@ struct unix_sock { ...@@ -76,7 +76,7 @@ struct unix_sock {
struct sock *other; struct sock *other;
struct sock *gc_tree; struct sock *gc_tree;
atomic_t inflight; atomic_t inflight;
rwlock_t lock; spinlock_t lock;
wait_queue_head_t peer_wait; wait_queue_head_t peer_wait;
}; };
#define unix_sk(__sk) ((struct unix_sock *)__sk) #define unix_sk(__sk) ((struct unix_sock *)__sk)
......
...@@ -564,7 +564,7 @@ static struct sock * unix_create1(struct socket *sock) ...@@ -564,7 +564,7 @@ static struct sock * unix_create1(struct socket *sock)
u = unix_sk(sk); u = unix_sk(sk);
u->dentry = NULL; u->dentry = NULL;
u->mnt = NULL; u->mnt = NULL;
rwlock_init(&u->lock); spin_lock_init(&u->lock);
atomic_set(&u->inflight, sock ? 0 : -1); atomic_set(&u->inflight, sock ? 0 : -1);
init_MUTEX(&u->readsem); /* single task reading lock */ init_MUTEX(&u->readsem); /* single task reading lock */
init_waitqueue_head(&u->peer_wait); init_waitqueue_head(&u->peer_wait);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment