From patchwork Wed Feb 17 16:34:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaetan Rivet X-Patchwork-Id: 1441289 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.138; helo=whitealder.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=v7TxJ0Bs; 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=l6Q8mQR7; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DgkBh46jMz9sSC for ; Thu, 18 Feb 2021 03:41:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id CEF1A86DDA; Wed, 17 Feb 2021 16:41:46 +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 mWjQQocMuqaX; Wed, 17 Feb 2021 16:41:42 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 29FAD86DEA; Wed, 17 Feb 2021 16:41:20 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0FB94C0FA7; Wed, 17 Feb 2021 16:41:20 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id A5E11C0FA7 for ; Wed, 17 Feb 2021 16:41:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 88C2F6F479 for ; Wed, 17 Feb 2021 16:41:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tgJALNsqU9fD for ; Wed, 17 Feb 2021 16:41:12 +0000 (UTC) Received: by smtp3.osuosl.org (Postfix, from userid 1001) id 96D156F5EE; Wed, 17 Feb 2021 16:41:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0 Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by smtp3.osuosl.org (Postfix) with ESMTPS id 9C4C16F5E3 for ; Wed, 17 Feb 2021 16:41:10 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 2D837580304; Wed, 17 Feb 2021 11:34:47 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 17 Feb 2021 11:34:47 -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=4jMBQb3ddbrrBdn3o+d65SiGCM bAc9hC1fPa5DXW2AQ=; b=v7TxJ0BsL0Yi+kxeiiEUTM/H69SE4sUGV8Q2iJIvL+ DXOumlFhEmQtAvtDMAeYgGAQBvsOXG6usRq4RDddo3GNZRN8DSPmiPPeBT4/XrGY /qc7BJ7/KU//KV2aie3xPxpLgBPhmdXYWScem4+40GYfMMaQ6Rd/qHSrhNcQIZzn nAwKjGNDd/k+4S+xzy/4OINp8CC0P+sOhBgcvzdWvYJoTyQ3jgoEGcpHDXx08YZq 5arA0JvmQpmJ5oAagqed6TSAgkbKtOXLiHx+AsEdNxggMY5m/Nlu8+HQHqZQga0v kGdx+YDaZR/9V5uUW5LToHqn4ck5XQDZAtrUGIZhVn0A== 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=4jMBQb3ddbrrBdn3o +d65SiGCMbAc9hC1fPa5DXW2AQ=; b=l6Q8mQR7N8pwDAns8g/AdjZn/kNzBKiHx JOlhKC0/5yUwCDyfwj5JnPT1EhaAQxn7cOGI0gB5isOORNhtK7pvUPH+0dbYgqB7 uZ/EBq8m/h5c1yOAnrloAwYZRSXWqpZ2/O3yyGEY/Lkxp2fgJkc8T7ZE3g9z/SAi DuMIMc0Ow2NyiH1M7+/2x4YfZCyOMc910VvngzWzTINLHEhMIfOcbwW3A266M2kI NCrObrUHj1KPyjwXyZAXZRPybYUv7YHvEIZLxdyhEwy5LVjZ+Y+skjwDVwaf2xcb KWjp+AH9EMzZ/HJEmV4CWZxQduCYQK3litGgQhR1EFOH+qcP9J11A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrjedvgdeihecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffoggfgsedtkeertdertd dtnecuhfhrohhmpefirggvthgrnhcutfhivhgvthcuoehgrhhivhgvsehuvdehiedrnhgv theqnecuggftrfgrthhtvghrnhepueekhfeludefieeuueehveegleevuedtfedvteevtd duieduffduhfekgeefkeehnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucfkphep keeirddvheegrddvgeefrddugeeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepghhrihhvvgesuhdvheeirdhnvght X-ME-Proxy: Received: from inocybe.home (lfbn-poi-1-930-146.w86-254.abo.wanadoo.fr [86.254.243.146]) by mail.messagingengine.com (Postfix) with ESMTPA id 3CF6C24006A; Wed, 17 Feb 2021 11:34:46 -0500 (EST) From: Gaetan Rivet To: dev@openvswitch.org Date: Wed, 17 Feb 2021 17:34:34 +0100 Message-Id: X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Cc: ameerm@nvidia.com, majd@nvidia.com Subject: [ovs-dev] [PATCH v1 0/9] conntrack: improve multithread scalability 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" Conntracks are executed within the datapath. Locks along this path are crucial and their critical section should be minimal. The global 'ct_lock' is necessary before any action taken on connection states. This lock is needed for many operations on the conntrack, slowing down the datapath. The cleanup thread 'ct_clean' will take it to do its job. As it can hold it a long time, the thread is limited in amount of connection cleaned per round, and calls are rate-limited. * Timeout policies locking is contrived to avoid deadlock. Anytime a connection state is updated, during its update it is unlocked, 'ct_lock' is taken, then the connection is locked again. Then the reverse is done for unlock. * Scalability is poor. The global ct_lock needs to be taken before applying any change to a conn object. This is backward: local changes to smaller objects should be independent, then the global lock should only be taken once the rest of the work is done, the goal being to have the smallest possible critical section. It can be improved. Using RCU-friendly structures for connections, zone limits and timeout policies, read-first workload is improved and the precedence of the global 'ct_lock' and local 'conn->lock' can be inversed. Running the conntrack benchmark we see these changes: ./tests/ovstest test-conntrack benchmark 3000000 32 code \ N 1 2 4 8 Before 2310 2766 6117 19838 (ms) After 2072 2084 2653 4541 (ms) One thread in the benchmark executes the task of a PMD, while the 'ct_clean' thread runs in background as well. Github actions: https://github.com/grivet/ovs/actions/runs/574446345 Gaetan Rivet (9): conntrack: Use rcu-lists to store conn expirations conntrack: Use a cmap to store zone limits conntrack: Init hash basis first at creation conntrack-tp: Use a cmap to store timeout policies conntrack: Inverse conn and ct lock precedence conntrack: Do not schedule zero ms timers conntrack: Do not rate limit ct-sweep conntrack: Do not log empty ct-sweep conntrack: Use an atomic conn expiration value lib/conntrack-private.h | 96 +++++++++++++------ lib/conntrack-tp.c | 137 +++++++++++++++----------- lib/conntrack.c | 206 +++++++++++++++++++++++++--------------- lib/conntrack.h | 4 +- lib/dpif-netdev.c | 5 +- 5 files changed, 280 insertions(+), 168 deletions(-) --- 2.30.0