From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wang Jian Subject: [PATCH 1/1] tap: RCU usage and comment fixes Date: Fri, 17 Aug 2018 08:22:53 +0000 Message-ID: <20180817082253.2539-1-jianjian.wang1@gmail.com> Cc: Wang Jian To: davem@davemloft.net, jasowang@redhat.com, mst@redhat.com, willemb@google.com, viro@zeniv.linux.org.uk, wexu@redhat.com, netdev@vger.kernel.org Return-path: Received: from mail-ua1-f67.google.com ([209.85.222.67]:38850 "EHLO mail-ua1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726349AbeHQLZe (ORCPT ); Fri, 17 Aug 2018 07:25:34 -0400 Received: by mail-ua1-f67.google.com with SMTP id o11-v6so5266361uak.5 for ; Fri, 17 Aug 2018 01:23:07 -0700 (PDT) Sender: netdev-owner@vger.kernel.org List-ID: The tap_queue and the 'tap_dev' are loosely coupled, not 'macvlan_dev'. Taking rcu_read_lock a little later seems can slightly reduce rcu read critical section. Signed-off-by: Wang Jian --- drivers/net/tap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/tap.c b/drivers/net/tap.c index f0f7cd977667..e5e5a8e4a60d 100644 --- a/drivers/net/tap.c +++ b/drivers/net/tap.c @@ -125,7 +125,7 @@ static struct tap_dev *tap_dev_get_rcu(const struct net_device *dev) /* * RCU usage: - * The tap_queue and the macvlan_dev are loosely coupled, the + * The tap_queue and the tap_dev are loosely coupled, the * pointers from one to the other can only be read while rcu_read_lock * or rtnl is held. * @@ -720,8 +720,6 @@ static ssize_t tap_get_user(struct tap_queue *q, struct msghdr *m, __vlan_get_protocol(skb, skb->protocol, &depth) != 0) skb_set_network_header(skb, depth); - rcu_read_lock(); - tap = rcu_dereference(q->tap); /* copy skb_ubuf_info for callback when skb has no error */ if (zerocopy) { skb_shinfo(skb)->destructor_arg = m->msg_control; @@ -732,6 +730,8 @@ static ssize_t tap_get_user(struct tap_queue *q, struct msghdr *m, uarg->callback(uarg, false); } + rcu_read_lock(); + tap = rcu_dereference(q->tap); if (tap) { skb->dev = tap->dev; dev_queue_xmit(skb); -- 2.17.1