Skip to content

Commit e6476c2

Browse files
Christoph Hellwigdavem330
authored andcommitted
net: remove bogus RCU annotations on socket.wq
We never use RCU protection for it, just a lot of cargo-cult rcu_deference_protects calls. Note that we do keep the kfree_rcu call for it, as the references through struct sock are RCU protected and thus might require a grace period before freeing. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Acked-by: Paul E. McKenney <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d46eeea commit e6476c2

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

include/linux/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ struct socket {
114114

115115
unsigned long flags;
116116

117-
struct socket_wq __rcu *wq;
117+
struct socket_wq *wq;
118118

119119
struct file *file;
120120
struct sock *sk;

include/net/sock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,7 @@ static inline void sock_graft(struct sock *sk, struct socket *parent)
17881788
{
17891789
WARN_ON(parent->sk);
17901790
write_lock_bh(&sk->sk_callback_lock);
1791-
sk->sk_wq = parent->wq;
1791+
rcu_assign_pointer(sk->sk_wq, parent->wq);
17921792
parent->sk = sk;
17931793
sk_set_socket(sk, parent);
17941794
sk->sk_uid = SOCK_INODE(parent)->i_uid;

net/socket.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static struct inode *sock_alloc_inode(struct super_block *sb)
251251
init_waitqueue_head(&wq->wait);
252252
wq->fasync_list = NULL;
253253
wq->flags = 0;
254-
RCU_INIT_POINTER(ei->socket.wq, wq);
254+
ei->socket.wq = wq;
255255

256256
ei->socket.state = SS_UNCONNECTED;
257257
ei->socket.flags = 0;
@@ -265,11 +265,9 @@ static struct inode *sock_alloc_inode(struct super_block *sb)
265265
static void sock_destroy_inode(struct inode *inode)
266266
{
267267
struct socket_alloc *ei;
268-
struct socket_wq *wq;
269268

270269
ei = container_of(inode, struct socket_alloc, vfs_inode);
271-
wq = rcu_dereference_protected(ei->socket.wq, 1);
272-
kfree_rcu(wq, rcu);
270+
kfree_rcu(ei->socket.wq, rcu);
273271
kmem_cache_free(sock_inode_cachep, ei);
274272
}
275273

@@ -603,7 +601,7 @@ static void __sock_release(struct socket *sock, struct inode *inode)
603601
module_put(owner);
604602
}
605603

606-
if (rcu_dereference_protected(sock->wq, 1)->fasync_list)
604+
if (sock->wq->fasync_list)
607605
pr_err("%s: fasync list not empty!\n", __func__);
608606

609607
if (!sock->file) {
@@ -1181,7 +1179,7 @@ static int sock_fasync(int fd, struct file *filp, int on)
11811179
return -EINVAL;
11821180

11831181
lock_sock(sk);
1184-
wq = rcu_dereference_protected(sock->wq, lockdep_sock_is_held(sk));
1182+
wq = sock->wq;
11851183
fasync_helper(fd, filp, on, &wq->fasync_list);
11861184

11871185
if (!wq->fasync_list)

0 commit comments

Comments
 (0)