From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id B80C98D9D for ; Sun, 20 May 2018 15:09:21 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 6680321DCC; Sun, 20 May 2018 09:09:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 20 May 2018 09:09:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=05kQoRzK+o5aZ9cdX 8NADU3J2WELOzE9TJ96Cil3Jjo=; b=lPu7r0x1NM8dIE+ExxrRmDbERdfaQkjoE jTpSwGbpKW8ro2Rj+W2amRkt/uH1itVwdxrcgFApXZQtjTqF64/ZZkR+JlEBDYae yXamSRC3oytkor7MagtoYpIJwxgqJBUoU1sYlifG9tBFZrIFs374M1b9eUmgm5RZ yR2jdB8+QCHWC7uKSSAPQHiA/AiJl10KLRgwc8VKBSPH8rvjaFZ5JQnyulGbx2Tw ISU6ojZFxNFX6qwquK1tZgqoHAmVI5ssGVICBdpGk1bsm/wUJjqbH2lPpEIxJKO2 j/ibZA+oz24zqITs91+HvGhYkBBI5VNRMAQb76iHlWX2vebGlNfzg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=05kQoRzK+o5aZ9cdX8NADU3J2WELOzE9TJ96Cil3Jjo=; b=Xu3ID5Ca bMbGG5bHCAY/sA0csJKRYBrStrWHKOqunqlSjsjU8ulQmw6c5C1DWWosYFY6rOId koF3Pq5cx7PSAJkJKKk32TT139+crAyI2XRm2dF3Si5u/2pVyMPrHpvVY7Hr1JG/ Z1+bpd9HVxLvyQrvGDRcEyxAL/qwGgPPZKYPyJxThLVwvAITNFSpKZOxnzVS9nec AoQyeW/18sAZszvcIf1xdHLsglZUYjaKEIqtzbB3/Df8PYn/UL2bIst190ejPwmK 9aHTWVPgKEnvNa6E5eot+OHQyokwSi3eXbct+/CkUFUGNFHWhi7rbekX7N/KalvQ nXYFWYNeelDuBA== X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Received: from yuanhanliu-NB0.tencent.com (unknown [223.74.148.80]) by mail.messagingengine.com (Postfix) with ESMTPA id 9F5C41025C; Sun, 20 May 2018 09:09:19 -0400 (EDT) From: Yuanhan Liu To: Matan Azrad Cc: Declan Doherty , dpdk stable Date: Sun, 20 May 2018 21:02:40 +0800 Message-Id: <20180520130246.16287-24-yliu@fridaylinux.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180520130246.16287-1-yliu@fridaylinux.org> References: <20180520130246.16287-1-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'net/bonding: fix slave activation simultaneously' has been queued to LTS release 17.11.3 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 May 2018 13:09:22 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/27/18. So please shout if anyone has objections. Thanks. --yliu --- >>From 24cf33134dfab484e608a46bb3e6e0e6cbe7def9 Mon Sep 17 00:00:00 2001 From: Matan Azrad Date: Tue, 24 Apr 2018 11:29:30 +0000 Subject: [PATCH] net/bonding: fix slave activation simultaneously [ upstream commit 59056833cc72e6ec2431cf990380394bc96e078a ] The bonding PMD decides to activate\deactivate its slaves according to the slaves link statuses. Thus, it registers to the LSC events of the slaves ports and activates\deactivates them from its LSC callbacks called asynchronously by the host thread when the slave link status is changed. In addition, the bonding PMD uses the callback for slave activation when it tries to start it, this operation is probably called by the master thread. Consequently, a slave may be activated in the same time by two different threads and may cause a lot of optional errors, for example, slave mempool recreation with the same name causes an error. Synchronize the critical section in the LSC callback using a special new spinlock. Fixes: 414b202343ce ("bonding: fix initial link status of slave") Fixes: a45b288ef21a ("bond: support link status polling") Signed-off-by: Matan Azrad Acked-by: Declan Doherty --- drivers/net/bonding/rte_eth_bond_pmd.c | 17 +++++++++++++++-- drivers/net/bonding/rte_eth_bond_private.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index e58d8bde2..e19a4a3e8 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -2524,14 +2524,21 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type, if (!valid_slave) return rc; + /* Synchronize lsc callback parallel calls either by real link event + * from the slaves PMDs or by the bonding PMD itself. + */ + rte_spinlock_lock(&internals->lsc_lock); + /* Search for port in active port list */ active_pos = find_slave_by_id(internals->active_slaves, internals->active_slave_count, port_id); rte_eth_link_get_nowait(port_id, &link); if (link.link_status) { - if (active_pos < internals->active_slave_count) + if (active_pos < internals->active_slave_count) { + rte_spinlock_unlock(&internals->lsc_lock); return rc; + } /* if no active slave ports then set this port to be primary port */ if (internals->active_slave_count < 1) { @@ -2550,8 +2557,10 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type, internals->primary_port == port_id) bond_ethdev_primary_set(internals, port_id); } else { - if (active_pos == internals->active_slave_count) + if (active_pos == internals->active_slave_count) { + rte_spinlock_unlock(&internals->lsc_lock); return rc; + } /* Remove from active slave list */ deactivate_slave(bonded_eth_dev, port_id); @@ -2604,6 +2613,9 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type, NULL, NULL); } } + + rte_spinlock_unlock(&internals->lsc_lock); + return 0; } @@ -2771,6 +2783,7 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode) eth_dev->data->dev_flags = RTE_ETH_DEV_INTR_LSC; rte_spinlock_init(&internals->lock); + rte_spinlock_init(&internals->lsc_lock); internals->port_id = eth_dev->data->port_id; internals->mode = BONDING_MODE_INVALID; diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h index a5cfa6ac0..dae8aab02 100644 --- a/drivers/net/bonding/rte_eth_bond_private.h +++ b/drivers/net/bonding/rte_eth_bond_private.h @@ -118,6 +118,7 @@ struct bond_dev_private { uint8_t mode; /**< Link Bonding Mode */ rte_spinlock_t lock; + rte_spinlock_t lsc_lock; uint16_t primary_port; /**< Primary Slave Port */ uint16_t current_primary_port; /**< Primary Slave Port */ -- 2.11.0