* socket poll related cleanups v2 @ 2018-07-30 7:45 Christoph Hellwig 2018-07-30 7:45 ` [PATCH] net: remove bogus RCU annotations on socket.wq Christoph Hellwig 0 siblings, 1 reply; 5+ messages in thread From: Christoph Hellwig @ 2018-07-30 7:45 UTC (permalink / raw) To: Eric Dumazet, Paul E. McKenney, netdev; +Cc: linux-kernel Eric, Paul, can you please look over the patch below? The RCU annotations here don't make any sense as we never RCU access through the annotated pointer ( we do access the underlying object through RCU and thus need to RCU free, but that is a different story). Dave doesn't seem to be convinced, though. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] net: remove bogus RCU annotations on socket.wq 2018-07-30 7:45 socket poll related cleanups v2 Christoph Hellwig @ 2018-07-30 7:45 ` Christoph Hellwig 2018-07-30 22:23 ` Eric Dumazet 2018-07-31 19:40 ` David Miller 0 siblings, 2 replies; 5+ messages in thread From: Christoph Hellwig @ 2018-07-30 7:45 UTC (permalink / raw) To: Eric Dumazet, Paul E. McKenney, netdev; +Cc: linux-kernel 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 <hch@lst.de> --- include/linux/net.h | 2 +- include/net/sock.h | 2 +- net/socket.c | 10 ++++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/linux/net.h b/include/linux/net.h index 6554d3ba4396..e0930678c8bf 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -114,7 +114,7 @@ struct socket { unsigned long flags; - struct socket_wq __rcu *wq; + struct socket_wq *wq; struct file *file; struct sock *sk; diff --git a/include/net/sock.h b/include/net/sock.h index 7927541101a8..9b6011912691 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1725,7 +1725,7 @@ static inline void sock_graft(struct sock *sk, struct socket *parent) { WARN_ON(parent->sk); write_lock_bh(&sk->sk_callback_lock); - sk->sk_wq = parent->wq; + rcu_assign_pointer(sk->sk_wq, parent->wq); parent->sk = sk; sk_set_socket(sk, parent); sk->sk_uid = SOCK_INODE(parent)->i_uid; diff --git a/net/socket.c b/net/socket.c index 5b7df6695f4f..475247e347ae 100644 --- a/net/socket.c +++ b/net/socket.c @@ -251,7 +251,7 @@ static struct inode *sock_alloc_inode(struct super_block *sb) init_waitqueue_head(&wq->wait); wq->fasync_list = NULL; wq->flags = 0; - RCU_INIT_POINTER(ei->socket.wq, wq); + ei->socket.wq = wq; ei->socket.state = SS_UNCONNECTED; ei->socket.flags = 0; @@ -265,11 +265,9 @@ static struct inode *sock_alloc_inode(struct super_block *sb) static void sock_destroy_inode(struct inode *inode) { struct socket_alloc *ei; - struct socket_wq *wq; ei = container_of(inode, struct socket_alloc, vfs_inode); - wq = rcu_dereference_protected(ei->socket.wq, 1); - kfree_rcu(wq, rcu); + kfree_rcu(ei->socket.wq, rcu); kmem_cache_free(sock_inode_cachep, ei); } @@ -603,7 +601,7 @@ static void __sock_release(struct socket *sock, struct inode *inode) module_put(owner); } - if (rcu_dereference_protected(sock->wq, 1)->fasync_list) + if (sock->wq->fasync_list) pr_err("%s: fasync list not empty!\n", __func__); if (!sock->file) { @@ -1181,7 +1179,7 @@ static int sock_fasync(int fd, struct file *filp, int on) return -EINVAL; lock_sock(sk); - wq = rcu_dereference_protected(sock->wq, lockdep_sock_is_held(sk)); + wq = sock->wq; fasync_helper(fd, filp, on, &wq->fasync_list); if (!wq->fasync_list) -- 2.18.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net: remove bogus RCU annotations on socket.wq 2018-07-30 7:45 ` [PATCH] net: remove bogus RCU annotations on socket.wq Christoph Hellwig @ 2018-07-30 22:23 ` Eric Dumazet 2018-07-31 0:51 ` Paul E. McKenney 2018-07-31 19:40 ` David Miller 1 sibling, 1 reply; 5+ messages in thread From: Eric Dumazet @ 2018-07-30 22:23 UTC (permalink / raw) To: Christoph Hellwig, Eric Dumazet, Paul E. McKenney, netdev; +Cc: linux-kernel On 07/30/2018 12:45 AM, Christoph Hellwig wrote: > 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 <hch@lst.de> Reviewed-by: Eric Dumazet <edumazet@google.com> Thanks. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: remove bogus RCU annotations on socket.wq 2018-07-30 22:23 ` Eric Dumazet @ 2018-07-31 0:51 ` Paul E. McKenney 0 siblings, 0 replies; 5+ messages in thread From: Paul E. McKenney @ 2018-07-31 0:51 UTC (permalink / raw) To: Eric Dumazet; +Cc: Christoph Hellwig, Eric Dumazet, netdev, linux-kernel On Mon, Jul 30, 2018 at 03:23:06PM -0700, Eric Dumazet wrote: > > > On 07/30/2018 12:45 AM, Christoph Hellwig wrote: > > 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 <hch@lst.de> > > Reviewed-by: Eric Dumazet <edumazet@google.com> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: remove bogus RCU annotations on socket.wq 2018-07-30 7:45 ` [PATCH] net: remove bogus RCU annotations on socket.wq Christoph Hellwig 2018-07-30 22:23 ` Eric Dumazet @ 2018-07-31 19:40 ` David Miller 1 sibling, 0 replies; 5+ messages in thread From: David Miller @ 2018-07-31 19:40 UTC (permalink / raw) To: hch; +Cc: edumazet, paulmck, netdev, linux-kernel From: Christoph Hellwig <hch@lst.de> Date: Mon, 30 Jul 2018 09:45:07 +0200 > 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 <hch@lst.de> Applied to net-next, thanks. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-07-31 19:40 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-07-30 7:45 socket poll related cleanups v2 Christoph Hellwig 2018-07-30 7:45 ` [PATCH] net: remove bogus RCU annotations on socket.wq Christoph Hellwig 2018-07-30 22:23 ` Eric Dumazet 2018-07-31 0:51 ` Paul E. McKenney 2018-07-31 19:40 ` David Miller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).