From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30087.outbound.protection.outlook.com [40.107.3.87]) by dpdk.org (Postfix) with ESMTP id 0C6FB2BD5; Tue, 24 Apr 2018 13:30:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Sb4MBptIDPAU0T6+Bt75M/yVhfE2oQNEGrLUHkz1dB0=; b=gsFdKM4BuRwK5ZWaD4p5EI8qJa3Ru2myVzm7jLmgmzQZZoDDPPS1b7FyOYihsy7Be1t16QxQ7AX0tyPxqWz2pqXhRtaN79G813Qmo8zEn5lk/1XnU8QJ02ymBy8wqK7Njkz+ZXP9ebgsJ5eqHAtNwqPkM3lg99ITVs7qh+7w10c= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM4PR0501MB2659.eurprd05.prod.outlook.com (2603:10a6:200:59::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.13; Tue, 24 Apr 2018 11:29:59 +0000 From: Matan Azrad To: Declan Doherty Cc: dev@dpdk.org, stable@dpdk.org Date: Tue, 24 Apr 2018 11:29:30 +0000 Message-Id: <1524569370-6799-1-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.9.5 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR0402CA0050.eurprd04.prod.outlook.com (2603:10a6:7:7c::39) To AM4PR0501MB2659.eurprd05.prod.outlook.com (2603:10a6:200:59::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM4PR0501MB2659; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0501MB2659; 3:95C+O95f2zaL1BSYSN9tAXWiZ79Dt89LqUC/dBwD3lvVeGSDbBY/Ez4WykyHVDazPO0sg/UDuipmhLbQNRSKlZ4/w7/4SpUZM1bRR82YnaaoOXtheEPNsJMuCVUNMBp1EDhCtqZ5rY90rZgGVtCO2PqtEgIOHqU65vinXgiNBHBaMaCq6imRHAcQIhp9GgfbNpC4G4ByQDjECE9WScTfiRRaBR/MSRbNutdHYkp6n+TGEKKkCJ0TqTWLObvToznj; 25:g3Vh/xGcUUjQHsGVUDYx3jcq7g9aeYXfVGtpaixySa3qGubS1v0oj1pObDUk9hUD9i/H5gwMpmrzJ6k4xE+6OQ9HMD5+k7H6JVIIe6shm2NO2P1UrcTa7NwtOQrR662nGMmi5DaIbcdTLYMk9z2N7b2uvEvlp8TcF/g4Jjr9T/GfhVWBZLn9q7HMq9bM5sCQe0jcwtf8m4D2uk/XvbVUTLvnFpnzFcAapvPa5LH0xnuPVSThMrvXmMb4hqeu3s2XxoGUjhJ4DrF745IBXiPxICbgd/9iNJoi8qduZ+ZaiNNDfO0yYsfmvQ0vXAYXe3NPKSC/23nCK+D6M9DyHipehA==; 31:rnuYyAEm/fapaLAWmyPuQRy1puuGt+2xBhORCnnR3naR42CkwT4/cfCU62NrUFvcz5lTVft/cRDGISjCSYQzzveLOZjJ70QA96Q6MYfMY6QFqBRYC4qr4yaZmkdUFs4nPlElmVENUPlgYR1lPv8fMroXoB0MC4wTZhdSWX8SoPHXb+dueCPMp3HkYtGhMCX7hTJS1dzL9GC7u5Tq0cUq8FTKPI31/e72DEoONTH6FCU= X-MS-TrafficTypeDiagnostic: AM4PR0501MB2659: X-Microsoft-Exchange-Diagnostics: 1; AM4PR0501MB2659; 20:HLpzbLMNpXrlzu3Vu8N2uFvq4SCg8+Y2IMzjaeW356v6Fqk9zTPffB/42+NXzlo5CzJrA4ArN0UDcAaHPNEfoWlynqx2sh7GOMVUz35K9aqiQYctt2l0uhk8zKCaH4+2VaPfRH5wER3Zi4an7ELdCgfcuV66VYnatxnoEHMAUakR0ymKssF/d4KF8GaE4LqLKawLOUA4pe7sl7LQWwBAz1TEqGgIZhokefyFfWXQlsVkSnPDx4pVegm5rlDs5QcQSwCJGjEnZdyhMHDZHfPWReNU3QIN39tnNkejpvQsgxUUPgVSi3mRiR1d1mD+l2XFhiQLg/NLYMV6HCWt4KdmEgeOxWJYwp0Ssm3H8j6/kxhVgHXiKluazeq+dR7ebnANVMd+C2i+l16gr13e+fjAbsS3Urce2YlOqQBzkgdm/9N8NmMECntRBwoqp4zPJIQboMbPRq99oca8YEZFGWoL/AtPaqsYax51EW4odcgkOAUvZIQsw4XcCNJPCY2hMbE0; 4:g5DzGTeKY04WKCcmLKgEa0bAuXg0JGEXlLtHUCswCv2UTxWtiiVeFALQ+7V7FT6dayubUX4YAQr3sVICl6igdWy4bFkO9P3HzmEeLTL2cqLJ4vXKZp+WtRE+KOoZc93VM63Fqd93fKUDTvItCRA9S+mlaeX7vxPc58iZZ1PcDwDzk7MxUM1azZKJMz1N5k7kzp+VdqfjPFbNL/mRLekj2ngAfBpikcDcBqiadO1VB7ruZ+gL13gyFVdSii/xa5fPzUawSPQ38OGk5fofvzhOOw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231232)(944501410)(52105095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:AM4PR0501MB2659; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0501MB2659; X-Forefront-PRVS: 0652EA5565 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(366004)(396003)(39380400002)(39860400002)(189003)(199004)(105586002)(21086003)(6916009)(6666003)(478600001)(69596002)(4326008)(8936002)(25786009)(50226002)(55016002)(106356001)(33026002)(66066001)(53936002)(6116002)(47776003)(81166006)(16586007)(81156014)(3846002)(7696005)(8676002)(68736007)(36756003)(5660300001)(7736002)(305945005)(386003)(48376002)(476003)(51416003)(316002)(52116002)(486006)(26005)(956004)(86362001)(186003)(59450400001)(2616005)(97736004)(16526019)(50466002)(2906002)(1857600001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0501MB2659; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR0501MB2659; 23:zACROkBRhbM84yb3g4grUI0V0Ox7JW/XjRwZmnm?= =?us-ascii?Q?Yys+6dbw/18ocTq7UZfInfDGma8vsSxh5WrDiqnk6AtwLEMvF4+uMbp9GHrL?= =?us-ascii?Q?qRhHvnHnXPCspg9p84j53GPTTacHkf3lMPTtxlcWJdulWKNrJznqpAXILbbP?= =?us-ascii?Q?PEWRBEdM3bb7E8WfgC/66T39ukyKQ6niprQ4ozi4rhqlkN/u4pyocZ7uSPlK?= =?us-ascii?Q?R08eh5PPCepyOxzF+we4lx81KIRi01panwHlQuN6x4YoPMmy2OmusQCOnu8P?= =?us-ascii?Q?59hlkPzOtuwxDpn2t/d8KwBpPZnWfsfir7xGYNKlUah+3zqVc/f/47/UaoUW?= =?us-ascii?Q?98RJkN6PemXMpLFGUktnAE6Z8fpGQdC/8o8HOH57dzwbrNJ3GbqW8YvwotuY?= =?us-ascii?Q?K3/jMhmbW8uIPRfSkyzTojD5sSiWJDxntjbg4c9KpLmu0k2ZzBBAkUvGObey?= =?us-ascii?Q?WSH3xcAX1YvajAHmsCiBgKtMhW/OqlG0DW3MvRWpvtOWPpsTGXzWETSA3b/j?= =?us-ascii?Q?gPPZ+eWUY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Qo/FEhw0frtO+RT40PghCwt0bBdOn+0KytV+Kuyj+02oQhPVaQEWWm9dxFcSA5uo2bOPzAbkuxNbHLm/uuoBjLS X-MS-Office365-Filtering-Correlation-Id: b1687134-5126-45d0-b57b-08d5a9d6b768 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2018 11:29:59.9944 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1687134-5126-45d0-b57b-08d5a9d6b768 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0501MB2659 Subject: [dpdk-stable] [PATCH] net/bonding: fix slave activation simultaneously 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, 24 Apr 2018 11:30:02 -0000 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") Cc: stable@dpdk.org Signed-off-by: Matan Azrad --- 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 2805c71..dffd12f 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -2654,14 +2654,21 @@ struct bwg_slave { 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) { @@ -2680,8 +2687,10 @@ struct bwg_slave { 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); @@ -2734,6 +2743,9 @@ struct bwg_slave { NULL); } } + + rte_spinlock_unlock(&internals->lsc_lock); + return 0; } @@ -2942,6 +2954,7 @@ struct bwg_slave { 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 94eca88..9220b61 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 */ -- 1.9.5