From patchwork Thu Dec 19 06:00:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 303185 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.180.67]) by ozlabs.org (Postfix) with ESMTP id 789BA2C009B for ; Thu, 19 Dec 2013 17:00:33 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751097Ab3LSGAL (ORCPT ); Thu, 19 Dec 2013 01:00:11 -0500 Received: from mga14.intel.com ([143.182.124.37]:18126 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750848Ab3LSGAJ (ORCPT ); Thu, 19 Dec 2013 01:00:09 -0500 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 18 Dec 2013 22:00:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,512,1384329600"; d="scan'208";a="328943595" Received: from gerry-dev.bj.intel.com ([10.238.158.74]) by AZSMGA002.ch.intel.com with ESMTP; 18 Dec 2013 22:00:04 -0800 From: Jiang Liu To: Jeff Kirsher , Jesse Brandeburg , Bruce Allan , Carolyn Wyborny , Don Skidmore , Greg Rose , Alex Duyck , John Ronciak , "David S. Miller" , Jacob Keller Cc: Jiang Liu , e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH] ixgbe: acquire RCU read lock when calling netdev_for_each_all_upper_dev_rcu() Date: Thu, 19 Dec 2013 14:00:56 +0800 Message-Id: <1387432860-14021-1-git-send-email-jiang.liu@linux.intel.com> X-Mailer: git-send-email 1.7.10.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org According to documentation for netdev_for_each_all_upper_dev_rcu(), caller should take RCU read lock, otherwise it will trigger following warnings. The simplest fix is to protect with rcu_read_lock()/ rcu_read_unlock(). And this solutions passes basic tests. Otherwise we may need to introduce netdev_for_each_all_upper_dev() as netdev_lower_get_next_private(), which assumes the caller has gained the lock to protect the list. Signed-off-by: Jiang Liu --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index cc06854..da72a5f 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -4336,6 +4336,7 @@ static void ixgbe_configure_dfwd(struct ixgbe_adapter *adapter) struct list_head *iter; int err; + rcu_read_lock(); netdev_for_each_all_upper_dev_rcu(adapter->netdev, upper, iter) { if (netif_is_macvlan(upper)) { struct macvlan_dev *dfwd = netdev_priv(upper); @@ -4348,6 +4349,7 @@ static void ixgbe_configure_dfwd(struct ixgbe_adapter *adapter) } } } + rcu_read_unlock(); } static void ixgbe_configure(struct ixgbe_adapter *adapter) @@ -4601,6 +4603,7 @@ static void ixgbe_up_complete(struct ixgbe_adapter *adapter) netif_tx_start_all_queues(adapter->netdev); /* enable any upper devices */ + rcu_read_lock(); netdev_for_each_all_upper_dev_rcu(adapter->netdev, upper, iter) { if (netif_is_macvlan(upper)) { struct macvlan_dev *vlan = netdev_priv(upper); @@ -4609,6 +4612,7 @@ static void ixgbe_up_complete(struct ixgbe_adapter *adapter) netif_tx_start_all_queues(upper); } } + rcu_read_unlock(); /* bring the link up in the watchdog, this could race with our first * link up interrupt but shouldn't be a problem */ @@ -4803,6 +4807,7 @@ void ixgbe_down(struct ixgbe_adapter *adapter) netif_tx_disable(netdev); /* disable any upper devices */ + rcu_read_lock(); netdev_for_each_all_upper_dev_rcu(adapter->netdev, upper, iter) { if (netif_is_macvlan(upper)) { struct macvlan_dev *vlan = netdev_priv(upper); @@ -4814,6 +4819,7 @@ void ixgbe_down(struct ixgbe_adapter *adapter) } } } + rcu_read_unlock(); ixgbe_irq_disable(adapter);