diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-04-29 07:01:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-05-01 18:00:15 -0400 |
commit | 43815482370c510c569fd18edb57afcb0fa8cab6 (patch) | |
tree | 063efaae3758402b84f056438b704d1de68f7837 /include/net/af_unix.h | |
parent | 83d7eb2979cd3390c375470225dd2d8f2009bc70 (diff) |
net: sock_def_readable() and friends RCU conversion
sk_callback_lock rwlock actually protects sk->sk_sleep pointer, so we
need two atomic operations (and associated dirtying) per incoming
packet.
RCU conversion is pretty much needed :
1) Add a new structure, called "struct socket_wq" to hold all fields
that will need rcu_read_lock() protection (currently: a
wait_queue_head_t and a struct fasync_struct pointer).
[Future patch will add a list anchor for wakeup coalescing]
2) Attach one of such structure to each "struct socket" created in
sock_alloc_inode().
3) Respect RCU grace period when freeing a "struct socket_wq"
4) Change sk_sleep pointer in "struct sock" by sk_wq, pointer to "struct
socket_wq"
5) Change sk_sleep() function to use new sk->sk_wq instead of
sk->sk_sleep
6) Change sk_has_sleeper() to wq_has_sleeper() that must be used inside
a rcu_read_lock() section.
7) Change all sk_has_sleeper() callers to :
- Use rcu_read_lock() instead of read_lock(&sk->sk_callback_lock)
- Use wq_has_sleeper() to eventually wakeup tasks.
- Use rcu_read_unlock() instead of read_unlock(&sk->sk_callback_lock)
8) sock_wake_async() is modified to use rcu protection as well.
9) Exceptions :
macvtap, drivers/net/tun.c, af_unix use integrated "struct socket_wq"
instead of dynamically allocated ones. They dont need rcu freeing.
Some cleanups or followups are probably needed, (possible
sk_callback_lock conversion to a spinlock for example...).
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/af_unix.h')
-rw-r--r-- | include/net/af_unix.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 1614d78c60ed..20725e213aee 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h | |||
@@ -30,7 +30,7 @@ struct unix_skb_parms { | |||
30 | #endif | 30 | #endif |
31 | }; | 31 | }; |
32 | 32 | ||
33 | #define UNIXCB(skb) (*(struct unix_skb_parms*)&((skb)->cb)) | 33 | #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb)) |
34 | #define UNIXCREDS(skb) (&UNIXCB((skb)).creds) | 34 | #define UNIXCREDS(skb) (&UNIXCB((skb)).creds) |
35 | #define UNIXSID(skb) (&UNIXCB((skb)).secid) | 35 | #define UNIXSID(skb) (&UNIXCB((skb)).secid) |
36 | 36 | ||
@@ -45,21 +45,23 @@ struct unix_skb_parms { | |||
45 | struct unix_sock { | 45 | struct unix_sock { |
46 | /* WARNING: sk has to be the first member */ | 46 | /* WARNING: sk has to be the first member */ |
47 | struct sock sk; | 47 | struct sock sk; |
48 | struct unix_address *addr; | 48 | struct unix_address *addr; |
49 | struct dentry *dentry; | 49 | struct dentry *dentry; |
50 | struct vfsmount *mnt; | 50 | struct vfsmount *mnt; |
51 | struct mutex readlock; | 51 | struct mutex readlock; |
52 | struct sock *peer; | 52 | struct sock *peer; |
53 | struct sock *other; | 53 | struct sock *other; |
54 | struct list_head link; | 54 | struct list_head link; |
55 | atomic_long_t inflight; | 55 | atomic_long_t inflight; |
56 | spinlock_t lock; | 56 | spinlock_t lock; |
57 | unsigned int gc_candidate : 1; | 57 | unsigned int gc_candidate : 1; |
58 | unsigned int gc_maybe_cycle : 1; | 58 | unsigned int gc_maybe_cycle : 1; |
59 | wait_queue_head_t peer_wait; | 59 | struct socket_wq peer_wq; |
60 | }; | 60 | }; |
61 | #define unix_sk(__sk) ((struct unix_sock *)__sk) | 61 | #define unix_sk(__sk) ((struct unix_sock *)__sk) |
62 | 62 | ||
63 | #define peer_wait peer_wq.wait | ||
64 | |||
63 | #ifdef CONFIG_SYSCTL | 65 | #ifdef CONFIG_SYSCTL |
64 | extern int unix_sysctl_register(struct net *net); | 66 | extern int unix_sysctl_register(struct net *net); |
65 | extern void unix_sysctl_unregister(struct net *net); | 67 | extern void unix_sysctl_unregister(struct net *net); |