From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id A683B1B892 for ; Tue, 15 May 2018 15:53:40 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id f8-v6so1275786wmc.4 for ; Tue, 15 May 2018 06:53:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i0gQ7/xOAx609/VD2ckY/5kGtQL2mdZv8Z7g2yQ4+a0=; b=l1GRCSvuBgYHmsudckhHjaZBNzLO8QRByNIS/u/BI7F1qhlTVSkbIf8I8ClqHj0nVy 04LminokK6sU384TNFEjcngaG7m8BwnWive6BKxHvlkxVUs2JzRwENPOgYdlyuf5IwnY OeNM1EB1mHl8kJFtocGIAhC7CKxrLiHM7dVM9tkeoSCYuI2DTqe5mbc7Yr3kXvJVZ50A gkxwDIsflCy6BOUasMggRCbj5BH77J5+sHgM76wn5o/cC1NvfvTY2tByCAC7KKFYldSf rHcl0a0Km+pqTgNQsn/MIU0WooJ3R5eyPomzfy3xpJZLSH4I6sJQpyy+3VqTym6wBQoC Q7BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=i0gQ7/xOAx609/VD2ckY/5kGtQL2mdZv8Z7g2yQ4+a0=; b=YQd3l/6SvkdWkYDQ79Deqk9/GX9qEKabhPen2WeB8yzt2GC1lxhLF0bacNqCAAhws7 6xJDVq+dzFFWFiN0O5NYJekWmyXSUOBijzm3gGNEyPRhso9A+rHOISkZYfiEJD0c4JuB f/uGevIBo/bePywlkUnaybNZ2MTwzidfXHG2awhjeJYlcj31wBRAKIWgA4kzOU/Nop/c k0++MvAbs5OvcO9tHLngo3/1bDf0EQCQuMcqx/tKHCWnF0QlJvnoEjTjgH34txEUkVNp biPXqnzpKBowm5EFa3GSB9gxFc0t4CO2qhrNpHTzBRbF40uN+Z2zGl6SGlxvh+yNmbFF IoDw== X-Gm-Message-State: ALKqPwcxYtbm8vQxPMG4N7fjna7l2wcLcfqPIsjevFX3+KZER+XFbhBV E00DFP10gbmpcd7sEJcgJC8= X-Google-Smtp-Source: AB8JxZrPLeKypNO+cVXS/K+TsdGOQwyvqiuP2Sgt/jltar6YptqrXObhpqeuDtd+2yv1LbFSUHysXg== X-Received: by 2002:a1c:4489:: with SMTP id r131-v6mr8793912wma.140.1526392420298; Tue, 15 May 2018 06:53:40 -0700 (PDT) Received: from localhost (slip139-92-244-193.lon.uk.prserv.net. [139.92.244.193]) by smtp.gmail.com with ESMTPSA id h81-v6sm757954wmd.0.2018.05.15.06.53.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 06:53:39 -0700 (PDT) From: luca.boccassi@gmail.com To: Matan Azrad Cc: Declan Doherty , dpdk stable Date: Tue, 15 May 2018 14:53:29 +0100 Message-Id: <20180515135335.10459-2-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180515135335.10459-1-luca.boccassi@gmail.com> References: <20180515134731.9337-72-luca.boccassi@gmail.com> <20180515135335.10459-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'net/bonding: fix slave activation simultaneously' has been queued to stable release 18.02.2 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: Tue, 15 May 2018 13:53:40 -0000 Hi, FYI, your patch has been queued to stable release 18.02.2 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/16/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From d17bd55481294300771de19e9e98968d447ddee4 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 32613703b..324753484 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -2638,14 +2638,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) { @@ -2664,8 +2671,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); @@ -2718,6 +2727,9 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type, NULL); } } + + rte_spinlock_unlock(&internals->lsc_lock); + return 0; } @@ -2922,6 +2934,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 92e15f8cc..2fad25fe1 100644 --- a/drivers/net/bonding/rte_eth_bond_private.h +++ b/drivers/net/bonding/rte_eth_bond_private.h @@ -89,6 +89,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.14.2