From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BE61FA0512 for ; Tue, 14 Jan 2020 19:04:08 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 780F21C12B; Tue, 14 Jan 2020 19:04:08 +0100 (CET) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20073.outbound.protection.outlook.com [40.107.2.73]) by dpdk.org (Postfix) with ESMTP id 4F0CF1C12B; Tue, 14 Jan 2020 19:04:07 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BGDryCGKaFFvK6F4m+KCZsL7te65s2s20+r8S9ZalV+TfhRtOyXd+/lZOyQO/gntGDkfeYyf/sASQmj9jV414fg7sEtlGp8fQYcdU1nN87wGFxMVsCa2A8vWekSqC80GE2L0EWuKaYXTOR+H5SIQmT8/E9xQiBICqLWpe8pliMdfVHprNgc9Sf8Hh1leu2ShhZs1hw9JPTgMY/q8TZqu5N/ETyAUaT5+zcBnbt2fIoBN7QT+VL7OTyVoJkWp9EHLlXAMBYJUQ3VfjLwaVP2yoX20W4BMm6oDvv+5rqL3de2EIoIhCTdwOi2mNTGeo04W1mydg2ouICV6CeMzhf7HpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jOgbIuy6960JoDq6lUgla3LN+gp6W+P/Tx6kr8++hIk=; b=mxEPKj4XV8qaw3JyxmaCSVwug0/ZcFjdR21sYRghZkOrYQKT1OTUJIWDWWy+wyqA9ZQmvpuQZRhLgCUSJttl3lzHbek0qZHT27Nrjc4FeWl3SO0DZahjBr6kS0/SiqK19OSldK6QoqDSGpeQuApi1YVl9xhdsqE5OJzcnVWRsjx5XGa0QdhJGIDHicuSNGb7Ds4ej9rn7v/9tCctMfSvnFS9c6utukzqNsrotnYcT7z+oTb2gG6o7daCKuDavzbdtplfDJr3bXRlV2TdRHjZNhkNRPWyEj5Sgz1mVrfl4szgGgwpSAoVEVxL8D5W1BWTogVdxvsre7FTLZfezAoMwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=dpdk.org smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=none pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jOgbIuy6960JoDq6lUgla3LN+gp6W+P/Tx6kr8++hIk=; b=P2fLAQxfJ43d8r2nPPiO8s51Fp6JJPLQxlMSxL6ktOJF4jHT2gz+akGKMI68VZKCXrrFlwtOlwh0I3bB1zKDRCugrzyjVImopHwiCw5/5rTzhPYM/PZFa/Lh1Xnp7xpYW/PgsYWRsYJcX2IHq324BaEGLf5/Ej97jSgMgQgvNME= Received: from VI1PR07CA0269.eurprd07.prod.outlook.com (2603:10a6:803:b4::36) by HE1PR0702MB3529.eurprd07.prod.outlook.com (2603:10a6:7:86::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.14; Tue, 14 Jan 2020 18:04:05 +0000 Received: from HE1EUR02FT024.eop-EUR02.prod.protection.outlook.com (2a01:111:f400:7e05::205) by VI1PR07CA0269.outlook.office365.com (2603:10a6:803:b4::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.10 via Frontend Transport; Tue, 14 Jan 2020 18:04:05 +0000 Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; Received: from oa.msg.ericsson.com (192.176.1.74) by HE1EUR02FT024.mail.protection.outlook.com (10.152.10.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2623.9 via Frontend Transport; Tue, 14 Jan 2020 18:04:05 +0000 Received: from ESESBMB501.ericsson.se (153.88.183.168) by ESESSMR503.ericsson.se (153.88.183.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 14 Jan 2020 19:04:04 +0100 Received: from selio1a020.lmera.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.184) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Tue, 14 Jan 2020 19:04:04 +0100 Received: from breslau.lmera.ericsson.se (breslau.lmera.ericsson.se [150.132.109.241]) by selio1a020.lmera.ericsson.se (8.15.1+Sun/8.15.1) with ESMTP id 00EI45oJ003453; Tue, 14 Jan 2020 19:04:05 +0100 (CET) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Date: Tue, 14 Jan 2020 19:03:38 +0100 Message-ID: <20200114180338.24635-1-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.176.1.74; IPV:; CTRY:SE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(376002)(39860400002)(346002)(396003)(136003)(189003)(199004)(54906003)(316002)(6916009)(86362001)(356004)(6666004)(1076003)(2906002)(5660300002)(478600001)(186003)(336012)(8676002)(246002)(36756003)(26005)(4326008)(956004)(2616005)(70206006)(7636002)(70586007)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0702MB3529; H:oa.msg.ericsson.com; FPR:; SPF:Pass; LANG:en; PTR:office365.se.ericsson.net; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aac0bddc-d2e8-4c5c-45ed-08d7991c2507 X-MS-TrafficTypeDiagnostic: HE1PR0702MB3529: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-Forefront-PRVS: 028256169F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2bOCeXCMQ1/WtcMRXbd8n9nn0D4cDCGsu+btqVWwcfzNVn84rwO893WvBnRQQDAgL6jBTcq7Up2+mOPjs/rpqAJNDolg10XmSTUJs0eRrq0H9PQKLBgHdM0sgN9duY/0QhLh+lcxgCiHQmWtZWjyqz06Nla64XKxz+iLvPx6K1ZFTXRkec7zAINrmSN5M5ERM/kBn0p7kIGQD+dsqTgy5HOYpnm7b7e+qFudRwNQrZPHh1bHvFBr/nLsiZPhK7txXYQ4YTGa6BzIKmuiq62nAQHe4V9mRPft8zoAevzl5csOKRKBYgBRcpH2Tiq02tKrRbLpE5fiFPBTvJRrf5XRoqfIH40yNJWMjg/ExCq+ktqJf1853HMQc1FRovplgVC6sHED/J8Rqtgvnawalip4NDSecME4PBTYnqTU+24sMVTY5QrZPYFrFGU6CNxX1AQx X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2020 18:04:05.5291 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aac0bddc-d2e8-4c5c-45ed-08d7991c2507 X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0702MB3529 Subject: [dpdk-stable] [PATCH v2] event/dsw: avoid credit leak on oversized enqueue bursts 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: , Errors-To: stable-bounces@dpdk.org Sender: "stable" If an application issues rte_event_enqueue_new_burst() or rte_event_enqueue_forward_burst() call with a burst of events longer than the configured max enqueue burst size, DSW allocates credits not only for events actually enqueued, but for the complete burst. If this process is repeated, enough credits will have leaked to cause the event device to backpressure (i.e. disallow) any new enqueue operations. In addition, the port-level enqueue xstats will log the wrong number of events enqueued for oversized enqueues. This patch makes DSW gracefully handle oversized enqueue bursts. Fixes: 1c8e3caa3bfb ("event/dsw: add event scheduling and device start/stop") Cc: stable@dpdk.org Signed-off-by: Mattias Rönnblom --- drivers/event/dsw/dsw_event.c | 38 ++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c index 1641c2d06..eae53b240 100644 --- a/drivers/event/dsw/dsw_event.c +++ b/drivers/event/dsw/dsw_event.c @@ -1018,12 +1018,12 @@ dsw_event_enqueue(void *port, const struct rte_event *ev) } static __rte_always_inline uint16_t -dsw_event_enqueue_burst_generic(void *port, const struct rte_event events[], +dsw_event_enqueue_burst_generic(struct dsw_port *source_port, + const struct rte_event events[], uint16_t events_len, bool op_types_known, uint16_t num_new, uint16_t num_release, uint16_t num_non_release) { - struct dsw_port *source_port = port; struct dsw_evdev *dsw = source_port->dsw; bool enough_credits; uint16_t i; @@ -1047,13 +1047,10 @@ dsw_event_enqueue_burst_generic(void *port, const struct rte_event events[], */ if (unlikely(events_len == 0)) { dsw_port_note_op(source_port, DSW_MAX_PORT_OPS_PER_BG_TASK); - dsw_port_flush_out_buffers(dsw, port); + dsw_port_flush_out_buffers(dsw, source_port); return 0; } - if (unlikely(events_len > source_port->enqueue_depth)) - events_len = source_port->enqueue_depth; - dsw_port_note_op(source_port, events_len); if (!op_types_known) @@ -1109,24 +1106,41 @@ uint16_t dsw_event_enqueue_burst(void *port, const struct rte_event events[], uint16_t events_len) { - return dsw_event_enqueue_burst_generic(port, events, events_len, false, - 0, 0, 0); + struct dsw_port *source_port = port; + + if (unlikely(events_len > source_port->enqueue_depth)) + events_len = source_port->enqueue_depth; + + return dsw_event_enqueue_burst_generic(source_port, events, + events_len, false, 0, 0, 0); } uint16_t dsw_event_enqueue_new_burst(void *port, const struct rte_event events[], uint16_t events_len) { - return dsw_event_enqueue_burst_generic(port, events, events_len, true, - events_len, 0, events_len); + struct dsw_port *source_port = port; + + if (unlikely(events_len > source_port->enqueue_depth)) + events_len = source_port->enqueue_depth; + + return dsw_event_enqueue_burst_generic(source_port, events, + events_len, true, events_len, + 0, events_len); } uint16_t dsw_event_enqueue_forward_burst(void *port, const struct rte_event events[], uint16_t events_len) { - return dsw_event_enqueue_burst_generic(port, events, events_len, true, - 0, 0, events_len); + struct dsw_port *source_port = port; + + if (unlikely(events_len > source_port->enqueue_depth)) + events_len = source_port->enqueue_depth; + + return dsw_event_enqueue_burst_generic(source_port, events, + events_len, true, 0, 0, + events_len); } uint16_t -- 2.17.1