patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Yuanhan Liu <yliu@fridaylinux.org>
To: Matan Azrad <matan@mellanox.com>
Cc: Declan Doherty <declan.doherty@intel.com>, dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'net/bonding: fix slave activation simultaneously' has been queued to LTS release 17.11.3
Date: Sun, 20 May 2018 21:02:40 +0800	[thread overview]
Message-ID: <20180520130246.16287-24-yliu@fridaylinux.org> (raw)
In-Reply-To: <20180520130246.16287-1-yliu@fridaylinux.org>

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 <matan@mellanox.com>
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 <matan@mellanox.com>
Acked-by: Declan Doherty <declan.doherty@intel.com>
---
 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

  parent reply	other threads:[~2018-05-20 13:09 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-20 13:02 [dpdk-stable] patch 'event/dpaa2: remove link from info structure' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'crypto/scheduler: set null pointer after freeing' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'crypto/scheduler: fix memory leak' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/crypto-perf: check minimum lcore number' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'test/reorder: fix freeing mbuf twice' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'test/distributor: fix return type of thread function' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'test/pipeline: fix return type of stub miss' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'examples/quota_watermark: fix return type of threads' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix slave port detection' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix valid ports prints' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix forward ports update' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix forward ports Rx flush' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix synchronic port hotplug' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix removed device link status asking' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'examples/performance-thread: fix return type of threads' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'test/pipeline: fix type of table entry parameter' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'vhost: fix dead lock on closing in server mode' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/vhost: initialise device as inactive' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnxt: fix Rx mbuf and agg ring leak in dev stop' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnxt: fix usage of vnic id' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix empty list of RSS queues for flow' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/failsafe: fix probe cleanup' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/i40e: fix link status update' " Yuanhan Liu
2018-05-20 13:02 ` Yuanhan Liu [this message]
2018-05-20 13:02 ` [dpdk-stable] patch 'mempool: fix virtual address population' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnx2x: do not cast function pointers as a policy' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnx2x: fix KR2 device check' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnx2x: fix memzone name overrun' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/i40e: fix failing to disable FDIR Tx queue' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/ixgbe: fix too many interrupts' " Yuanhan Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180520130246.16287-24-yliu@fridaylinux.org \
    --to=yliu@fridaylinux.org \
    --cc=declan.doherty@intel.com \
    --cc=matan@mellanox.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).