From patchwork Wed Feb 10 14:57:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaetan Rivet X-Patchwork-Id: 1439003 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=u256.net header.i=@u256.net header.a=rsa-sha256 header.s=fm1 header.b=cRa/UCb2; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=HM8+9eUt; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DbNQP4766z9s1l for ; Thu, 11 Feb 2021 02:06:53 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 234628737B; Wed, 10 Feb 2021 15:06:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jlFuE+0M2Pvc; Wed, 10 Feb 2021 15:06:49 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 6D1AF87377; Wed, 10 Feb 2021 15:06:49 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 40EE0C1DA9; Wed, 10 Feb 2021 15:06:49 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 882CEC013A for ; Wed, 10 Feb 2021 15:06:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 778E786776 for ; Wed, 10 Feb 2021 15:06:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dRtaRNEs2L3K for ; Wed, 10 Feb 2021 15:06:43 +0000 (UTC) X-Greylist: delayed 00:08:54 by SQLgrey-1.7.6 Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by whitealder.osuosl.org (Postfix) with ESMTPS id 03DA3866D6 for ; Wed, 10 Feb 2021 15:06:43 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailnew.west.internal (Postfix) with ESMTP id D2841B4F; Wed, 10 Feb 2021 09:57:48 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Wed, 10 Feb 2021 09:57:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=u256.net; h=from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=B2yMgGqr+RSbW3AkXXJT4AXP52 uEQhvvMJ9KeCfeYCM=; b=cRa/UCb2xRmhaE0e7//d4uLpa4IYquKm6qw6XH9Bcl HlLWf1+WQeC2be8HAj0wHA3W6halEYLgnEtocojKqg88S/DOna3J0ri9Yn4YsHIe Ip0x0b6He5e7/LnjiUKRjQVxFBM6nn8VQTg4sxY5UeZVvoRS+BOCMR4/Z9Qam2fE /gmiEwHlEhxnqWGBxEHNjruZn5NvGRbXoVvxooqgds2AeJYGcMdm9E3LmmO8rr0K 2AfiK1zrx6TH1xsaNUsT0JXi37Tzp1eLZrO4jGI8tLrZFKP7+n6gzCFYh70anEyl H6F3ig/QCrd3EEHRR01o2IOLCFnhD7FQEwV8NjheyDYg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=B2yMgGqr+RSbW3AkX XJT4AXP52uEQhvvMJ9KeCfeYCM=; b=HM8+9eUt/eld8+d3GbknllABAK/IwCLGx BGAJwPabJbmy81+STn4BEBdQwSgeRVun0K2+ehZqK1Jnkbv6Cxu2yz7dqat9i28u bDjjW51qtmbVvVVXGFAc2zffcuLHL9RXeyIho1HuSaXINXs6dCFRWhy+bFMH+7JD K4kPsRbwegF6W06Pxyq3UrjU6cd5KYKO5tU5XV32hsQpNIGxwHvEJN0nFmuSfaGl YjzVaSmLmndvM2YJDvMAxSnuwcVevLYhr5Oz4DpJK88OpMTWWk/FONCfBQl263HF 6HZEq/PXrEyuL6VhHeyug2B/2c5/JnenBUJotJWNYFx/3pTXD+V2Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrheejgdejudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffoggfgsedtkeertdertd dtnecuhfhrohhmpefirggvthgrnhcutfhivhgvthcuoehgrhhivhgvsehuvdehiedrnhgv theqnecuggftrfgrthhtvghrnhepueekhfeludefieeuueehveegleevuedtfedvteevtd duieduffduhfekgeefkeehnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucfkphep keeirddvheegrdduieegrddujeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepghhrihhvvgesuhdvheeirdhnvght X-ME-Proxy: Received: from inocybe.home (lfbn-poi-1-842-174.w86-254.abo.wanadoo.fr [86.254.164.174]) by mail.messagingengine.com (Postfix) with ESMTPA id C1E3424005C; Wed, 10 Feb 2021 09:57:46 -0500 (EST) From: Gaetan Rivet To: dev@openvswitch.org Date: Wed, 10 Feb 2021 15:57:18 +0100 Message-Id: X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Cc: elibr@nvidia.com, ameerm@nvidia.com, i.maximets@ovn.org, majd@nvidia.com Subject: [ovs-dev] [PATCH v1 00/23] dpif-netdev: Parallel offload processing X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This patch series aims to improve the performance of the management of hw-offloads in dpif-netdev. In the current version, some setup will experience high memory usage and poor latency between a flow decision and its execution regarding hardware offloading. This series starts by measuring key metrics regarding both issues Those patches are introduced first to compare the current status with each improvements introduced. Offloads enqueued and inserted, as well as the latency from queue insertion to hardware insertion is measured. A new command 'ovs-appctl dpctl/offload-stats-show' is introduced to show the current measure. In my current performance test setup I am measuring an average latency hovering between 1~2 seconds. After the optimizations, it is reduced to 500~900 ms. Finally when using multiple threads and with proper driver support[1], it is measured in the order of 1 ms. A few modules are introduced: * An ID pool with reduced capabilities, simplifying its operations and allowing better performances in both single and multi-thread setup. * A lockless queue between PMDs / revalidators and offload thread(s). As the number of PMDs increases, contention can be high on the shared queue. This queue is designed to serve as message queue between threads. * A bounded lockless MPMC ring and some helpers for calculating moving averages. * A moving average module for Cumulative and Exponential moving averages. The netdev-offload-dpdk module is made thread-safe. Internal maps are made per-netdev instead, and locks are taken for shorter critical sections within the module. CI result: https://github.com/grivet/ovs/actions/runs/554918929 [1]: The rte_flow API was made thread-safe in the 20.11 DPDK release. Drivers that do not implement those operations concurrently are protected by a lock. Others will allow better concurrency, that improve the result of this series. Gaetan Rivet (23): netdev: Add flow API de-init function netdev-offload-dpdk: Use per-netdev offload metadata netdev-offload-dpdk: Implement hw-offload statistics read dpctl: Add function to read hardware offload statistics dpif-netdev: Rename offload thread structure mov-avg: Add a moving average helper structure dpif-netdev: Implement hardware offloads stats query ovs-atomic: Expose atomic exchange operation mpsc-queue: Module for lock-free message passing llring: Add lockless MPMC bounded queue structure seq-pool: Module for faster ID generation netdev-offload: Add multi-thread API dpif-netdev: Quiesce offload thread periodically dpif-netdev: Postpone flow offload item freeing dpif-netdev: Use seq-pool for mark allocation netdev-offload-dpdk: Use per-thread HW offload stats netdev-offload-dpdk: Lock rte_flow map access netdev-offload-dpdk: Protect concurrent offload destroy/query dpif-netdev: Use lockless queue to manage offloads dpif-netdev: Make megaflow and mark mappings thread objects dpif-netdev: Replace port mutex by rwlock dpif-netdev: Use one or more offload threads netdev-dpdk: Remove rte-flow API access locks lib/automake.mk | 7 + lib/dpctl.c | 36 +++ lib/dpif-netdev.c | 506 ++++++++++++++++++++--------- lib/dpif-netlink.c | 1 + lib/dpif-provider.h | 7 + lib/dpif.c | 8 + lib/dpif.h | 9 + lib/llring.c | 153 +++++++++ lib/llring.h | 76 +++++ lib/mov-avg.h | 171 ++++++++++ lib/mpsc-queue.c | 190 +++++++++++ lib/mpsc-queue.h | 149 +++++++++ lib/netdev-dpdk.c | 6 - lib/netdev-offload-dpdk.c | 270 ++++++++++++++-- lib/netdev-offload-provider.h | 4 + lib/netdev-offload.c | 92 +++++- lib/netdev-offload.h | 21 ++ lib/ovs-atomic-c++.h | 3 + lib/ovs-atomic-clang.h | 5 + lib/ovs-atomic-gcc4+.h | 5 + lib/ovs-atomic-gcc4.7+.h | 5 + lib/ovs-atomic-i586.h | 5 + lib/ovs-atomic-locked.h | 9 + lib/ovs-atomic-msvc.h | 22 ++ lib/ovs-atomic-pthreads.h | 5 + lib/ovs-atomic-x86_64.h | 5 + lib/ovs-atomic.h | 8 +- lib/seq-pool.c | 198 ++++++++++++ lib/seq-pool.h | 66 ++++ tests/automake.mk | 2 + tests/library.at | 10 + tests/test-mpsc-queue.c | 580 ++++++++++++++++++++++++++++++++++ tests/test-seq-pool.c | 543 +++++++++++++++++++++++++++++++ vswitchd/vswitch.xml | 16 + 34 files changed, 3007 insertions(+), 186 deletions(-) create mode 100644 lib/llring.c create mode 100644 lib/llring.h create mode 100644 lib/mov-avg.h create mode 100644 lib/mpsc-queue.c create mode 100644 lib/mpsc-queue.h create mode 100644 lib/seq-pool.c create mode 100644 lib/seq-pool.h create mode 100644 tests/test-mpsc-queue.c create mode 100644 tests/test-seq-pool.c --- 2.30.0