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 5E69FA04F3; Fri, 3 Jan 2020 12:32:22 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A99D21D165; Fri, 3 Jan 2020 12:32:21 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70081.outbound.protection.outlook.com [40.107.7.81]) by dpdk.org (Postfix) with ESMTP id 77BC91C2A3; Fri, 3 Jan 2020 12:32:20 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BQwPVYqky7LSeOLUcL+hVC6uFVO3KZTCpfDSZfAPxj6gkiVC+Ky3m5r5w0p7qGgSgUg8D84sSK7ZYHtEaat/3iylmIK7Wk5+FXvN70qmpnNkK5a/E4xUAPniDZAy5hOA0bidUjr+v4rBmChDIXVWYR+OEZGcYygD5hF3FM5pmMO7rjyALuKPmvVSpUavqcTHpJeEzTlv1xfd0yue9i7feR0ogXfbDrE0hiE5uIo2OLI/NEMnHryg+gN5xgwMGKlNpsTs18WeqaAGGw3Iq1OKUE/nrZkQ3s0JJI2K68PSJeuYYlb7fxlVjtsJ7pbkym8EyJF3sH3wzIBPOlOfbZMmTQ== 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=kJXfHTo7WjXQGLkV3IO7U5rpX5OLUi9HNabfSI2rNJ0=; b=m0X95DCgz7DQZVYap9CuoQ4rTmicJSZqTshgt6G1woQcwoViganeW/Oj/0vrmBmr6zaPilh+l/GcIRo/OwYkPC9biiF+OiT39G1Sw6nXTap6jSvSGLqcsmeYVduaIkYe2+EBzRSWKL9y8z05CbVWMEHauGo0hL0H4zNfD1hWaKH+DRety7nugeNqO0UzR7vzhvwNGR7W7bq3bJ6GlhQPVozY6UG6PrRqN/O/UNWLrc0LQCBXbqy/y4jZhBTkjzh1OHxgpNUsZ2fwK/t/TCwBAuhtcC7vP3ekkL7ThMY5Mx/6Pmlaoxd15loDsk+q9Eut7ev27xTSJF2/ni/ZMjxY/g== 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=kJXfHTo7WjXQGLkV3IO7U5rpX5OLUi9HNabfSI2rNJ0=; b=pqI/NVoHnr9RhYUrz4PJl+CglNveTNCDxw4YTgOOj0aiT3imGo+BHOp5UyCuN8rEcN8MCPbhZz4xpJ8Cd+5PAEaVY0ylJl9PSQozRYiPfseV3U+4PdkCcnv8o+OD7MvR5M+fJnEYW/XEa2JjorHW592sn4uPh+qDA6uryHMg7q8= Received: from HE1PR07CA0019.eurprd07.prod.outlook.com (2603:10a6:7:67::29) by AM0PR07MB4562.eurprd07.prod.outlook.com (2603:10a6:208:77::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.9; Fri, 3 Jan 2020 11:32:19 +0000 Received: from VE1EUR02FT040.eop-EUR02.prod.protection.outlook.com (2a01:111:f400:7e06::200) by HE1PR07CA0019.outlook.office365.com (2603:10a6:7:67::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2623.4 via Frontend Transport; Fri, 3 Jan 2020 11:32:19 +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 VE1EUR02FT040.mail.protection.outlook.com (10.152.13.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2602.11 via Frontend Transport; Fri, 3 Jan 2020 11:32:18 +0000 Received: from ESESBMB505.ericsson.se (153.88.183.172) by ESESSMR506.ericsson.se (153.88.183.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 3 Jan 2020 12:32:07 +0100 Received: from selio1a020.lmera.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.188) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Fri, 3 Jan 2020 12:32:07 +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 003BW81x001841; Fri, 3 Jan 2020 12:32:08 +0100 (CET) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Date: Fri, 3 Jan 2020 12:31:57 +0100 Message-ID: <20200103113157.7928-1-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.17.1 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)(346002)(396003)(39860400002)(136003)(189003)(199004)(36756003)(356004)(478600001)(336012)(8936002)(1076003)(2616005)(86362001)(6666004)(956004)(8676002)(70206006)(186003)(6916009)(246002)(70586007)(26005)(7636002)(5660300002)(2906002)(54906003)(4326008)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR07MB4562; 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: 6a1e1f21-b29e-4848-a719-08d79040977e X-MS-TrafficTypeDiagnostic: AM0PR07MB4562: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-Forefront-PRVS: 0271483E06 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sBZncLvSfi/dsBnzYp/dL34otkUxnxEUINsf/I+JR/4JtJg0oYsyGTqtfLuSlPcoS5R0ygPmEylTnrtBCUAy2R84AWevC8TsHXyujE4TdM16QjP/aNfoaPLKlxXM3z03+gB8vVlsw03NYVZDzSqWlqpwCcxJNUPEmEj4szgxfdpexGKosAFLqZwoMjWrobrNUkbjKAaI9nbxd0mmKrZavof7tI7IrCwjxVJlYCd+ltHhE8nFnBWBeTOtIo0RDfyrHo6nUdg9LaQZ4hTiZakxJZTy11R0uvRsubaARkIyJJznhAh2DNcmyzYE1xwmQAMH6pg0HNGTtokrl8ZPRr3H/b2PYcpTYxs0UdcDEgy6n9hVK6vHl1SZntBpaMY41vkqKI2qY4X84f66lGbss0hThP7YP3rK01aK4Hpypg/SrinQAvhBNAYjd7lYjIzkxSFd X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2020 11:32:18.9370 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a1e1f21-b29e-4848-a719-08d79040977e 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: AM0PR07MB4562 Subject: [dpdk-dev] [PATCH] event/dsw: avoid credit leak on oversized enqueue bursts X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 | 36 ++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c index 61a66fabf..b919244c6 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; @@ -1050,9 +1050,6 @@ dsw_event_enqueue_burst_generic(void *port, const struct rte_event events[], 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) @@ -1108,24 +1105,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