aboutsummaryrefslogtreecommitdiffstats
path: root/net/atm
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-04-29 07:01:49 -0400
committerDavid S. Miller <davem@davemloft.net>2010-05-01 18:00:15 -0400
commit43815482370c510c569fd18edb57afcb0fa8cab6 (patch)
tree063efaae3758402b84f056438b704d1de68f7837 /net/atm
parent83d7eb2979cd3390c375470225dd2d8f2009bc70 (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 'net/atm')
-rw-r--r--net/atm/common.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/net/atm/common.c b/net/atm/common.c
index e3e10e6f8628..b43feb1a3995 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -90,10 +90,13 @@ static void vcc_sock_destruct(struct sock *sk)
90 90
91static void vcc_def_wakeup(struct sock *sk) 91static void vcc_def_wakeup(struct sock *sk)
92{ 92{
93 read_lock(&sk->sk_callback_lock); 93 struct socket_wq *wq;
94 if (sk_has_sleeper(sk)) 94
95 wake_up(sk_sleep(sk)); 95 rcu_read_lock();
96 read_unlock(&sk->sk_callback_lock); 96 wq = rcu_dereference(sk->sk_wq);
97 if (wq_has_sleeper(wq))
98 wake_up(&wq->wait);
99 rcu_read_unlock();
97} 100}
98 101
99static inline int vcc_writable(struct sock *sk) 102static inline int vcc_writable(struct sock *sk)
@@ -106,16 +109,19 @@ static inline int vcc_writable(struct sock *sk)
106 109
107static void vcc_write_space(struct sock *sk) 110static void vcc_write_space(struct sock *sk)
108{ 111{
109 read_lock(&sk->sk_callback_lock); 112 struct socket_wq *wq;
113
114 rcu_read_lock();
110 115
111 if (vcc_writable(sk)) { 116 if (vcc_writable(sk)) {
112 if (sk_has_sleeper(sk)) 117 wq = rcu_dereference(sk->sk_wq);
113 wake_up_interruptible(sk_sleep(sk)); 118 if (wq_has_sleeper(wq))
119 wake_up_interruptible(&wq->wait);
114 120
115 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); 121 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT);
116 } 122 }
117 123
118 read_unlock(&sk->sk_callback_lock); 124 rcu_read_unlock();
119} 125}
120 126
121static struct proto vcc_proto = { 127static struct proto vcc_proto = {