From patchwork Tue Nov 10 17:54:50 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 38077 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 902CBB7B75 for ; Wed, 11 Nov 2009 09:05:30 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756252AbZKJSHe (ORCPT ); Tue, 10 Nov 2009 13:07:34 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756168AbZKJSHd (ORCPT ); Tue, 10 Nov 2009 13:07:33 -0500 Received: from suva.vyatta.com ([76.74.103.44]:58719 "EHLO suva.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756182AbZKJSHd (ORCPT ); Tue, 10 Nov 2009 13:07:33 -0500 Received: from suva.vyatta.com (suva [127.0.0.1]) by suva.vyatta.com (8.13.7/8.13.7) with ESMTP id nAAI7Uh9000497; Tue, 10 Nov 2009 10:07:30 -0800 Received: (from shemminger@localhost) by suva.vyatta.com (8.13.7/8.13.7/Submit) id nAAI7PJR000496; Tue, 10 Nov 2009 10:07:25 -0800 Message-Id: <20091110175647.409162953@vyatta.com> References: <20091110175446.280423729@vyatta.com> User-Agent: quilt/0.46-1 Date: Tue, 10 Nov 2009 09:54:50 -0800 From: Stephen Hemminger To: David Miller , "Ed L. Cashin" , Harvey Harrison , Bartlomiej Zolnierkiewicz Cc: netdev@vger.kernel.org Subject: [PATCH 04/10] AOE: use rcu to find network device Content-Disposition: inline; filename=aoe-rcu.patch Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This gets rid of another use of read_lock(&dev_base_lock) by using RCU. Also, it only increments the reference count of the device actually used rather than holding and releasing every device Compile tested only. Signed-off-by: Stephen Hemminger Acked-by: Eric Dumazet --- a/drivers/block/aoe/aoecmd.c 2009-11-09 22:19:06.082480836 -0800 +++ b/drivers/block/aoe/aoecmd.c 2009-11-10 09:28:38.222438732 -0800 @@ -296,17 +296,18 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigne struct sk_buff *skb; struct net_device *ifp; - read_lock(&dev_base_lock); - for_each_netdev(&init_net, ifp) { - dev_hold(ifp); + rcu_read_lock(); + for_each_netdev_rcu(&init_net, ifp) { if (!is_aoe_netif(ifp)) - goto cont; + continue; skb = new_skb(sizeof *h + sizeof *ch); if (skb == NULL) { printk(KERN_INFO "aoe: skb alloc failure\n"); - goto cont; + continue; } + + dev_hold(ifp); skb_put(skb, sizeof *h + sizeof *ch); skb->dev = ifp; __skb_queue_tail(queue, skb); @@ -320,11 +321,8 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigne h->major = cpu_to_be16(aoemajor); h->minor = aoeminor; h->cmd = AOECMD_CFG; - -cont: - dev_put(ifp); } - read_unlock(&dev_base_lock); + rcu_read_unlock(); } static void