From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from emea01-am1-obe.outbound.protection.outlook.com (mail-am1on0092.outbound.protection.outlook.com [157.56.112.92]) by dpdk.org (Postfix) with ESMTP id 44052568A for ; Wed, 10 Feb 2016 06:15:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ezchip.onmicrosoft.com; s=selector1-ezchip-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/sOqRwEE33POZS3jKKgO4YkOgp+PdQ7aQ6E+ovguDNI=; b=mIotexbcyoYPgVj4znytf9Kkp6bEeS4ckQlfiPdvw0OjvRwtTvdNZTUPVnWoHBUzHkARXYpPytWGHcLaubGYvUeEQ8Wjl+8XTmGNKTnbKZ7GKJwDlJN/C5LymBEq0EN0gz11j9JLVSZ6FFEkRcQL58Ifc29EwLNnvvcFmeUvUmg= Received: from AM4PR02CA0024.eurprd02.prod.outlook.com (10.165.239.162) by DB5PR02MB1013.eurprd02.prod.outlook.com (10.162.162.19) with Microsoft SMTP Server (TLS) id 15.1.403.16; Wed, 10 Feb 2016 05:15:24 +0000 Received: from DB3FFO11FD013.protection.gbl (2a01:111:f400:7e04::191) by AM4PR02CA0024.outlook.office365.com (2a01:111:e400:7a66::34) with Microsoft SMTP Server (TLS) id 15.1.403.16 via Frontend Transport; Wed, 10 Feb 2016 05:15:25 +0000 Authentication-Results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; ezchip.com; dkim=none (message not signed) header.d=none;ezchip.com; dmarc=none action=none header.from=ezchip.com; Received-SPF: Fail (protection.outlook.com: domain of ezchip.com does not designate 12.216.194.146 as permitted sender) receiver=protection.outlook.com; client-ip=12.216.194.146; helo=lab-14.internal.tilera.com; Received: from lab-14.internal.tilera.com (12.216.194.146) by DB3FFO11FD013.mail.protection.outlook.com (10.47.216.187) with Microsoft SMTP Server (TLS) id 15.1.409.7 via Frontend Transport; Wed, 10 Feb 2016 05:15:24 +0000 Received: (from lsun@localhost) by lab-14.internal.tilera.com (8.14.7/8.14.7/Submit) id u1A5FNur010523; Wed, 10 Feb 2016 00:15:23 -0500 From: Liming Sun To: Date: Wed, 10 Feb 2016 00:15:21 -0500 Message-ID: <1455081321-10484-1-git-send-email-lsun@ezchip.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1452263948-22485-2-git-send-email-lsun@ezchip.com> References: <1452263948-22485-2-git-send-email-lsun@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD013; 1:b61Hvc7iUv2sXrRTtenhebkC1jVUvgnn8HoUm9pMZwDzE3Y5FoBqTvE/onHYGdsaaPaae3VH8CpAsDsa3u4aw1AjPXCbkG3IAlC14Vvc2N+Qk/7hliJB96YkHGmklsrPUlnmDvE5zuWLt24Cqwk0LfHlpVLEfOnt4tG/MZqvLU14GS4bdu9ITf5GFkdyVF9ohnOMyGkhGNwIvIFcndhvuJsO//WKkkj4KK6BjMgPLMtdW6L9nQZdb0q6ef/ShQ5shdne4e5TREd4pNglfBxD8t1yHj4NtIHd4I4W1tpVIEHQHg8crwabUagq16InP+fXfL9IIrnnM1IyyOEC6cYFMAbmdobrisS+M0EFaX+/IjVoIG1zNMn5ZIBvicNFUtcRJDmr0xOH1gtDqOw5RdbUo6f1F1tWAm0WF5B5qbKPYJu2PAIBQfOoDSJRGSFho7EK6AdLVRjlmF4K7mEX/AM3zBkSW6/Hf1OiRoXTfEfxX1hbPNC9boztDwHKEj52wIZLQbBeFS3R/ywB5IVfcLO7oQ== X-Forefront-Antispam-Report: CIP:12.216.194.146; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(6806005)(106466001)(1220700001)(1096002)(92566002)(48376002)(586003)(19580405001)(2351001)(2950100001)(229853001)(36756003)(105606002)(104016004)(19580395003)(5008740100001)(2906002)(50226001)(87936001)(5001970100001)(85426001)(50466002)(33646002)(47776003)(107886002)(86362001)(4001430100002)(189998001)(5003940100001)(4326007)(110136002)(76176999)(42186005)(50986999); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR02MB1013; H:lab-14.internal.tilera.com; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB1013; 2:xPrxqGQgWFiaaWQImu0/QMIW1zfnO6/wy5eXD6q73KXtiimwxMptugr8ulMVku8sRJ5Y21u4DWRQgsLXk+wFS31MW+YVwhL1j79JuHFrYBtfCI7oCaSzA5Q7RXWzUdFC5L9TF7o55jNd/nR/nypwxA==; 3:sC3hAfZi/RhsWgO+MxguEA6h4X4LjQEvcS2p00bIfdL5moCsJ/Bhakg8L3JI8OHRa1iUd1UTQDq456wBQPUaBVi4ti47uxGG98MdGimpT6DKBX1m9G94YK2zauLO9JU4zZCHKU8Vu2ftOb48opXhG1CWp8u2pUi6fv8kOP9q4kSSb9CnpIExHYwz1Z3qhzra5nSQYs3n4yvll3/tE++zVDoyAk+0M62hO9UwSY7X67Y=; 25:P/c7CsOU+6yQml8muNXwL/fvvKFZqnAbe6yupeimvMP2ea2rfzhTGVJo8kWG5CaVnSZ2ACp+04UzKDbSsegRE++fVaDQyt5zcGLe55hccgVb2S844DPE1qhuWwf1jyljn/Z0IzpdqGnomVPst24Ru3g+9xTbw4xblNjQDoZhF6rlMEBXE8PpCy3MVyX/6Txaw7zBZwxFC1fgUagSAAyBukviU8R7ThiHm7+yHndKneN29qdm/hr1n+5gYlrciU2sNEGzHCkp48CD/ohdsNcOU24StCzMbSzuUF8Ri2kSjtuDVF1asENO27NtcjE8AQlw; 20:9MCwXTKWSHdDgmbGebIEKJO0bcaTu305H3cMkJQBjuPThOHGyvhuXBGX+bti1UD3+Eb2twGTKle9c/+zbihOWLJpwQzlET1pLVpoOkGf0L5pL86cNkg/GNUjTpVG0LHCR88qvt1nYdfSTvGxlBpuE7CmhLZmuir6U4wAI+YQn3E= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR02MB1013; X-MS-Office365-Filtering-Correlation-Id: 929916f3-3ab2-46ad-7fe1-08d331d92ec2 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(13023025)(5005006)(13024025)(13017025)(13018025)(13015025)(3002001)(10201501046); SRVR:DB5PR02MB1013; BCL:0; PCL:0; RULEID:; SRVR:DB5PR02MB1013; X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB1013; 4:P1gWQOufWCF8XoVClpMStszLFWBy09IkaVdQo7bWHn9zyUofrccfxOhYrEZZIL0gMQo+tAPLthhL6smp9d5RWjNY37v+cN/bnr8KTabMvxqeq43OyeFAGEPus8siK0QjgcsgBeTkcpoLWmO2iJVc8ug23O/6rDFeUApY9XX4PPqvykHxkErNpsHJnhOiUEeRSwQCJFHGcBsjwItL3gYjDb44T78N4BimiMrKRzxct7RDjYZX7IMl82baQd5O4nvC5Mz0PhWG1sRrrjsLGDJ/eERtJCAn/Oul+rFHzlUXf33TSCPhiVbAF5eLfJFDpKRfySKGZeDpDNLaQEuQoDYMnNa6DYpwyEpnHnLFD8aONZwD6DJRHoEVNMm5aYlperKhziIaY+DkYMJMbJjJS7Kw1wzEzgUWameAo1V5+E2AgBH5gk2tZTMNYyf+UpqLone1PbEHoTPFG6kFOMjqsDzjOw== X-Forefront-PRVS: 0848C1A6AA X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB5PR02MB1013; 23:hekqQgMLgLuCXyaaUWc+ao4wjDNPbn0k8C2/r83in?= =?us-ascii?Q?xwsVFFaVwnlQxNq/EelayzZpRD/DyvJ1h8IK+MqtiQwe1F3D5TL4VE55yWu5?= =?us-ascii?Q?xGE1xhWeHYflxbKFWAMJW+LbEeTFNpqqlV88pEUcDHizo2WSlTzw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IfxJrf/hNyfrb9wXSqOCSd6unxHsUfJkPzWO5V2F?= =?us-ascii?Q?AY3DikJyM1LrF/TbKvT+RFhLAeD?= X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB1013; 5:sTG3c33X2S+FmM5pTxz8qi3xfxT8V5VOJ77zOjI4ByJqs+60UFhgQp8yPQ4V/weQspZi2eF6y5QSDZU3eiRhsQw5sk+W13xT+ndWituGEYpanjC3zzQjW+W7UZnrxPxTRw9IRJJ/A3sICoJKp0Wd6w==; 24:oYg3Y2KFVd5mluPvoMBdrzyTlUekE/3Twj4tolXAUaqvKBLz0OGzrS7A9Xe3zZIgTyIXLYQ/MhuvZjf6eqno9F8fFoFjc9s1AYYelEsuczQ= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2016 05:15:24.7166 (UTC) X-MS-Exchange-CrossTenant-Id: 0fc16e0a-3cd3-4092-8b2f-0a42cff122c3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=0fc16e0a-3cd3-4092-8b2f-0a42cff122c3; Ip=[12.216.194.146]; Helo=[lab-14.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR02MB1013 Subject: [dpdk-dev] [PATCH v3] driver/net/mpipe: fix the crash/hung issue when testpmd quits X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Feb 2016 05:15:27 -0000 Fixes: the hung/crash issue when quitting testpmd under high traffic rate. The following issue were found and fixed. 1. edesc->size is not initialized properly in mpipe_do_xmit() and could cause buffer leak or corruption when HW buffer return is used. 2. Check the 'idesc.be' error bit in mpipe_recv_flush() to make sure buffer is valid before releasing it. This is to avoid issues when running out of buffers. 3. priv->rx_buffers counter is not accurate when HW buffer return is used. Remove this counter to simplify the code. Signed-off-by: Liming Sun Acked-by: Zhigang Lu --- drivers/net/mpipe/mpipe_tilegx.c | 46 ++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c index 8d006fa..4cb54c3 100644 --- a/drivers/net/mpipe/mpipe_tilegx.c +++ b/drivers/net/mpipe/mpipe_tilegx.c @@ -134,7 +134,6 @@ struct mpipe_dev_priv { struct rte_mempool *rx_mpool; /* mpool used by the rx queues. */ unsigned rx_offset; /* Receive head room. */ unsigned rx_size_code; /* mPIPE rx buffer size code. */ - unsigned rx_buffers; /* receive buffers on stack. */ int is_xaui:1, /* Is this an xgbe or gbe? */ initialized:1, /* Initialized port? */ running:1; /* Running port? */ @@ -529,7 +528,6 @@ mpipe_recv_fill_stack(struct mpipe_dev_priv *priv, int count) mpipe_recv_push(priv, mbuf); } - priv->rx_buffers += count; PMD_DEBUG_RX("%s: Filled %d/%d buffers\n", mpipe_name(priv), i, count); } @@ -539,10 +537,9 @@ mpipe_recv_flush_stack(struct mpipe_dev_priv *priv) const int offset = priv->rx_offset & ~RTE_MEMPOOL_ALIGN_MASK; uint8_t in_port = priv->port_id; struct rte_mbuf *mbuf; - unsigned count; void *va; - for (count = 0; count < priv->rx_buffers; count++) { + while (1) { va = gxio_mpipe_pop_buffer(priv->context, priv->stack); if (!va) break; @@ -561,10 +558,6 @@ mpipe_recv_flush_stack(struct mpipe_dev_priv *priv) __rte_mbuf_raw_free(mbuf); } - - PMD_DEBUG_RX("%s: Returned %d/%d buffers\n", - mpipe_name(priv), count, priv->rx_buffers); - priv->rx_buffers -= count; } static void @@ -1246,31 +1239,23 @@ mpipe_recv_flush(struct mpipe_dev_priv *priv) gxio_mpipe_iqueue_t *iqueue; gxio_mpipe_idesc_t idesc; struct rte_mbuf *mbuf; - int retries = 0; unsigned queue; - do { - mpipe_recv_flush_stack(priv); - - /* Flush packets sitting in recv queues. */ - for (queue = 0; queue < priv->nb_rx_queues; queue++) { - rx_queue = mpipe_rx_queue(priv, queue); - iqueue = &rx_queue->iqueue; - while (gxio_mpipe_iqueue_try_get(iqueue, &idesc) >= 0) { - mbuf = mpipe_recv_mbuf(priv, &idesc, in_port); - rte_pktmbuf_free(mbuf); - priv->rx_buffers--; - } - rte_free(rx_queue->rx_ring_mem); - } - } while (retries++ < 10 && priv->rx_buffers); + /* Release packets on the buffer stack. */ + mpipe_recv_flush_stack(priv); - if (priv->rx_buffers) { - RTE_LOG(ERR, PMD, "%s: Leaked %d receive buffers.\n", - mpipe_name(priv), priv->rx_buffers); - } else { - PMD_DEBUG_RX("%s: Returned all receive buffers.\n", - mpipe_name(priv)); + /* Flush packets sitting in recv queues. */ + for (queue = 0; queue < priv->nb_rx_queues; queue++) { + rx_queue = mpipe_rx_queue(priv, queue); + iqueue = &rx_queue->iqueue; + while (gxio_mpipe_iqueue_try_get(iqueue, &idesc) >= 0) { + /* Skip idesc with the 'buffer error' bit set. */ + if (idesc.be) + continue; + mbuf = mpipe_recv_mbuf(priv, &idesc, in_port); + rte_pktmbuf_free(mbuf); + } + rte_free(rx_queue->rx_ring_mem); } } @@ -1339,6 +1324,7 @@ mpipe_do_xmit(struct mpipe_tx_queue *tx_queue, struct rte_mbuf **tx_pkts, .xfer_size = rte_pktmbuf_data_len(mbuf), .bound = next ? 0 : 1, .stack_idx = mpipe_mbuf_stack_index(priv, mbuf), + .size = priv->rx_size_code, } }; if (mpipe_local.mbuf_push_debt[port_id] > 0) { mpipe_local.mbuf_push_debt[port_id]--; -- 1.8.3.1