Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1525711/?format=api
{ "id": 1525711, "url": "http://patchwork.ozlabs.org/api/patches/1525711/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/ea65a2a809285ec690eba27516ebda0b6da6d934.1631094144.git.grive@u256.net/", "project": { "id": 47, "url": "http://patchwork.ozlabs.org/api/projects/47/?format=api", "name": "Open vSwitch", "link_name": "openvswitch", "list_id": "ovs-dev.openvswitch.org", "list_email": "ovs-dev@openvswitch.org", "web_url": "http://openvswitch.org/", "scm_url": "git@github.com:openvswitch/ovs.git", "webscm_url": "https://github.com/openvswitch/ovs", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<ea65a2a809285ec690eba27516ebda0b6da6d934.1631094144.git.grive@u256.net>", "list_archive_url": null, "date": "2021-09-08T09:47:27", "name": "[ovs-dev,v5,03/27] tests: Add ovs-barrier unit test", "commit_ref": "aec1081c7df35e3c11968ffe6bed44de52e9caa7", "pull_url": null, "state": "accepted", "archived": false, "hash": "b529c37da69e1c91c600dd3101c1789e9c0d5800", "submitter": { "id": 78795, "url": "http://patchwork.ozlabs.org/api/people/78795/?format=api", "name": "Gaetan Rivet", "email": "grive@u256.net" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/ea65a2a809285ec690eba27516ebda0b6da6d934.1631094144.git.grive@u256.net/mbox/", "series": [ { "id": 261424, "url": "http://patchwork.ozlabs.org/api/series/261424/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=261424", "date": "2021-09-08T09:47:24", "name": "dpif-netdev: Parallel offload processing", "version": 5, "mbox": "http://patchwork.ozlabs.org/series/261424/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1525711/comments/", "check": "success", "checks": "http://patchwork.ozlabs.org/api/patches/1525711/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<ovs-dev-bounces@openvswitch.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "ovs-dev@openvswitch.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "ovs-dev@lists.linuxfoundation.org" ], "Authentication-Results": [ "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=u256.net header.i=@u256.net header.a=rsa-sha256\n header.s=fm2 header.b=p0Lw/RUY;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=messagingengine.com header.i=@messagingengine.com\n header.a=rsa-sha256 header.s=fm3 header.b=oiGY6TDX;\n\tdkim-atps=neutral", "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN>)" ], "Received": [ "from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 4H4HPs2bzgz9sW8\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 8 Sep 2021 19:48:17 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby smtp4.osuosl.org (Postfix) with ESMTP id 63BE7406EB;\n\tWed, 8 Sep 2021 09:48:12 +0000 (UTC)", "from smtp4.osuosl.org ([127.0.0.1])\n\tby localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 3Wd8zA_I7GFX; Wed, 8 Sep 2021 09:48:11 +0000 (UTC)", "from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56])\n\tby smtp4.osuosl.org (Postfix) with ESMTPS id C59FA406E8;\n\tWed, 8 Sep 2021 09:48:09 +0000 (UTC)", "from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id 9FFA5C0011;\n\tWed, 8 Sep 2021 09:48:09 +0000 (UTC)", "from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 00179C000D\n for <ovs-dev@openvswitch.org>; Wed, 8 Sep 2021 09:48:07 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n by smtp4.osuosl.org (Postfix) with ESMTP id 99684406D5\n for <ovs-dev@openvswitch.org>; Wed, 8 Sep 2021 09:48:07 +0000 (UTC)", "from smtp4.osuosl.org ([127.0.0.1])\n by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id oys7-fquN5eH for <ovs-dev@openvswitch.org>;\n Wed, 8 Sep 2021 09:48:06 +0000 (UTC)", "from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com\n [64.147.123.19])\n by smtp4.osuosl.org (Postfix) with ESMTPS id 994DB4046F\n for <ovs-dev@openvswitch.org>; Wed, 8 Sep 2021 09:48:06 +0000 (UTC)", "from compute5.internal (compute5.nyi.internal [10.202.2.45])\n by mailout.west.internal (Postfix) with ESMTP id DD5C832009BA;\n Wed, 8 Sep 2021 05:48:05 -0400 (EDT)", "from mailfrontend2 ([10.202.2.163])\n by compute5.internal (MEProxy); Wed, 08 Sep 2021 05:48:06 -0400", "by mail.messagingengine.com (Postfix) with ESMTPA; Wed,\n 8 Sep 2021 05:48:04 -0400 (EDT)" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "from auto-whitelisted by SQLgrey-1.8.0", "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=u256.net; h=from\n :to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-transfer-encoding; s=fm2; bh=yQ95iudfDfbIh\n 5LIhGWSe8RpISNIpmLMlyHOttCo72c=; b=p0Lw/RUYt6L2/8XH7yGkrl3Shum27\n 3mbcj693EDvb8Z8GzYShEahhkz7rsJUvlHbK2GkGpHgjYu/BEyk2dt7FTzqikkq0\n 8R2bUFctEHbsDoV6h3ay/TDn+Vowc/ld1E+en53QnWfaHry1oZCwIpfTiYuSp8VQ\n ig+GwTpRgOH1OSS1XWYmZUfRZkL/P0FPNjc5jhAIO3Ra7ssHjAXtOcfQ1+91NfhE\n cqEIA9fN0AA/7lTuh84jern50M/XQf8j353oFydb/XIhJR46i0mkkqdLnlb+TG8n\n ZuOFINGmNhmjYNr3cQAU6uipL57zOj7nrVkRNhfpZMjuYyX8rXc0hdODA==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=\n messagingengine.com; h=cc:content-transfer-encoding:date:from\n :in-reply-to:message-id:mime-version:references:subject:to\n :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=\n fm3; bh=yQ95iudfDfbIh5LIhGWSe8RpISNIpmLMlyHOttCo72c=; b=oiGY6TDX\n Hcd5gwwiG8X8/i0US/kWLLzDrItMv/70VzXB1adzbT3qXvaVN2XxjJRY3cMNAXCL\n 5Mb/ZKe3FQ9ee+OjZsTPvyu7Nh4AqCg7iYZktMsEB+frSIT8xNIa8qzvl0MWWpTt\n +cowjxx6JkaDc7UCbg+4/H8avPhgJYScLQ6Dv7dn+gZIC/o30uACc/rC1zdWDMfT\n P2TXKs8ufZnjN5sFgAHZbyjz5yJsbck56hI7fnpSoanpwLhN8JvzXqeusP208cUh\n nDUWeUEhTN1pnO29z+zIFcwPVftYHJEz5hWES9chz9I9f23s/HfPzXjevroGpQF2\n FdCSRYnZ8aFjXQ==" ], "X-ME-Sender": "<xms:1YY4YRaHkBYDdvwOo1ZGi94raE0ZNOvwbxjszvjf0-2Q1hejHLV3QA>\n <xme:1YY4YYZkJVnESoGVY93yQ2Ctnl4Q6C6SRkOOR9oINCUnu_WGbkeE71UjNtuFPU5jB\n EkL2TaUV5IjarLbNLU>", "X-ME-Received": "\n <xmr:1YY4YT-JJGTx5tNB98fbSyVcOusFOBhckSzRHh-z2vwpp9-zBFO7cUXZFYpBke0leMvZ6r9F2VkiDG9Fh6SIP-C4aA>", "X-ME-Proxy-Cause": "\n gggruggvucftvghtrhhoucdtuddrgedvtddrudefjedgudekucetufdoteggodetrfdotf\n fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen\n uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne\n cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefirggvthgr\n nhcutfhivhgvthcuoehgrhhivhgvsehuvdehiedrnhgvtheqnecuggftrfgrthhtvghrnh\n epudfhfeeikeeiiedutefgheekledukedtkeejheduheffteeiudehiefgkedvleefnecu\n ffhomhgrihhnpegrphgrtghhvgdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurf\n grrhgrmhepmhgrihhlfhhrohhmpehgrhhivhgvsehuvdehiedrnhgvth", "X-ME-Proxy": "<xmx:1YY4Yfp11ON3oZPnMZzSb-D6yj3HrVqPX3ffWSya4oUEfGhp0lou_Q>\n <xmx:1YY4YcqbMK6uObIMI-KY6eWVQGhzmKQFeFweSSnyQCPhJnPN-Y_PbQ>\n <xmx:1YY4YVRtyCG4SYrReEnU6CCp5E9ee81QSr82hxhlH9v20TlDfavIyw>\n <xmx:1YY4YTTvW7kjfJ8wxcb1RRhpnZMsDlesgg09_qelz3qVeo_JN9uHYg>", "From": "Gaetan Rivet <grive@u256.net>", "To": "ovs-dev@openvswitch.org", "Date": "Wed, 8 Sep 2021 11:47:27 +0200", "Message-Id": "\n <ea65a2a809285ec690eba27516ebda0b6da6d934.1631094144.git.grive@u256.net>", "X-Mailer": "git-send-email 2.31.1", "In-Reply-To": "<cover.1631094144.git.grive@u256.net>", "References": "<cover.1631094144.git.grive@u256.net>", "MIME-Version": "1.0", "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>", "Subject": "[ovs-dev] [PATCH v5 03/27] tests: Add ovs-barrier unit test", "X-BeenThere": "ovs-dev@openvswitch.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "<ovs-dev.openvswitch.org>", "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>", "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>", "List-Post": "<mailto:ovs-dev@openvswitch.org>", "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>", "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "ovs-dev-bounces@openvswitch.org", "Sender": "\"dev\" <ovs-dev-bounces@openvswitch.org>" }, "content": "No unit test exist currently for the ovs-barrier type.\nIt is however crucial as a building block and should be verified to work\nas expected.\n\nCreate a simple test verifying the basic function of ovs-barrier.\nIntegrate the test as part of the test suite.\n\nSigned-off-by: Gaetan Rivet <grive@u256.net>\nReviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n tests/automake.mk | 1 +\n tests/library.at | 5 +\n tests/test-barrier.c | 264 +++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 270 insertions(+)\n create mode 100644 tests/test-barrier.c", "diff": "diff --git a/tests/automake.mk b/tests/automake.mk\nindex 43731d097..977779765 100644\n--- a/tests/automake.mk\n+++ b/tests/automake.mk\n@@ -454,6 +454,7 @@ tests_ovstest_SOURCES = \\\n \ttests/ovstest.h \\\n \ttests/test-aes128.c \\\n \ttests/test-atomic.c \\\n+\ttests/test-barrier.c \\\n \ttests/test-bundle.c \\\n \ttests/test-byte-order.c \\\n \ttests/test-classifier.c \\\ndiff --git a/tests/library.at b/tests/library.at\nindex b2914ae6c..42a5ce1aa 100644\n--- a/tests/library.at\n+++ b/tests/library.at\n@@ -246,6 +246,11 @@ AT_SETUP([ofpbuf module])\n AT_CHECK([ovstest test-ofpbuf], [0], [])\n AT_CLEANUP\n \n+AT_SETUP([barrier module])\n+AT_KEYWORDS([barrier])\n+AT_CHECK([ovstest test-barrier], [0], [])\n+AT_CLEANUP\n+\n AT_SETUP([rcu])\n AT_CHECK([ovstest test-rcu-quiesce], [0], [])\n AT_CLEANUP\ndiff --git a/tests/test-barrier.c b/tests/test-barrier.c\nnew file mode 100644\nindex 000000000..3bc5291cc\n--- /dev/null\n+++ b/tests/test-barrier.c\n@@ -0,0 +1,264 @@\n+/*\n+ * Copyright (c) 2021 NVIDIA Corporation.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at:\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+#include <getopt.h>\n+\n+#include <config.h>\n+\n+#include \"ovs-thread.h\"\n+#include \"ovs-rcu.h\"\n+#include \"ovstest.h\"\n+#include \"random.h\"\n+#include \"util.h\"\n+\n+#define DEFAULT_N_THREADS 4\n+#define NB_STEPS 4\n+\n+static bool verbose;\n+static struct ovs_barrier barrier;\n+\n+struct blocker_aux {\n+ unsigned int tid;\n+ bool leader;\n+ int step;\n+};\n+\n+static void *\n+basic_blocker_main(void *aux_)\n+{\n+ struct blocker_aux *aux = aux_;\n+ size_t i;\n+\n+ aux->step = 0;\n+ for (i = 0; i < NB_STEPS; i++) {\n+ ovs_barrier_block(&barrier);\n+ aux->step++;\n+ ovs_barrier_block(&barrier);\n+ }\n+\n+ return NULL;\n+}\n+\n+static void\n+basic_block_check(struct blocker_aux *aux, size_t n, int expected)\n+{\n+ size_t i;\n+\n+ for (i = 0; i < n; i++) {\n+ if (verbose) {\n+ printf(\"aux[%\" PRIuSIZE \"]=%d == %d\", i, aux[i].step, expected);\n+ if (aux[i].step != expected) {\n+ printf(\" <--- X\");\n+ }\n+ printf(\"\\n\");\n+ } else {\n+ ovs_assert(aux[i].step == expected);\n+ }\n+ }\n+ ovs_barrier_block(&barrier);\n+ ovs_barrier_block(&barrier);\n+}\n+\n+/*\n+ * Basic barrier test.\n+ *\n+ * N writers and 1 reader participate in the test.\n+ * Each thread goes through M steps (=NB_STEPS).\n+ * The main thread participates as the reader.\n+ *\n+ * A Step is divided in three parts:\n+ * 1. before\n+ * (barrier)\n+ * 2. during\n+ * (barrier)\n+ * 3. after\n+ *\n+ * Each writer updates a thread-local variable with the\n+ * current step number within part 2 and waits.\n+ *\n+ * The reader checks all variables during part 3, expecting\n+ * all variables to be equal. If any variable differs, it means\n+ * its thread was not properly blocked by the barrier.\n+ */\n+static void\n+test_barrier_basic(size_t n_threads)\n+{\n+ struct blocker_aux *aux;\n+ pthread_t *threads;\n+ size_t i;\n+\n+ ovs_barrier_init(&barrier, n_threads + 1);\n+\n+ aux = xcalloc(n_threads, sizeof *aux);\n+ threads = xmalloc(n_threads * sizeof *threads);\n+ for (i = 0; i < n_threads; i++) {\n+ threads[i] = ovs_thread_create(\"ovs-barrier\",\n+ basic_blocker_main, &aux[i]);\n+ }\n+\n+ for (i = 0; i < NB_STEPS; i++) {\n+ basic_block_check(aux, n_threads, i);\n+ }\n+ ovs_barrier_destroy(&barrier);\n+\n+ for (i = 0; i < n_threads; i++) {\n+ xpthread_join(threads[i], NULL);\n+ }\n+\n+ free(threads);\n+ free(aux);\n+}\n+\n+static unsigned int *shared_mem;\n+\n+static void *\n+lead_blocker_main(void *aux_)\n+{\n+ struct blocker_aux *aux = aux_;\n+ size_t i;\n+\n+ aux->step = 0;\n+ for (i = 0; i < NB_STEPS; i++) {\n+ if (aux->leader) {\n+ shared_mem = xmalloc(sizeof *shared_mem);\n+ if (verbose) {\n+ printf(\"*T1: allocated shmem\\n\");\n+ }\n+ }\n+ xnanosleep(random_range(100) * 1000);\n+\n+ ovs_barrier_block(&barrier);\n+\n+ if (verbose) {\n+ printf(\"%cT%u: ENTER, writing\\n\",\n+ (aux->leader ? '*' : ' '), aux->tid);\n+ }\n+\n+ shared_mem[0] = 42;\n+\n+ ovs_barrier_block(&barrier);\n+\n+ if (verbose) {\n+ printf(\"%cT%u: EXIT\\n\",\n+ (aux->leader ? '*' : ' '), aux->tid);\n+ }\n+\n+ if (aux->leader) {\n+ free(shared_mem);\n+ if (verbose) {\n+ printf(\"*T1: freed shmem\\n\");\n+ }\n+ }\n+ xnanosleep(random_range(100) * 1000);\n+ }\n+\n+ return NULL;\n+}\n+\n+/*\n+ * Leader barrier test.\n+ *\n+ * N threads participates, one of which is marked as\n+ * the leader (thread 0). The main thread does not\n+ * participate.\n+ *\n+ * The test is divided in M steps (=NB_STEPS).\n+ * A Step is divided in three parts:\n+ * 1. before\n+ * (barrier)\n+ * 2. during\n+ * (barrier)\n+ * 3. after\n+ *\n+ * Part 1, the leader allocates a block of shared memory.\n+ * Part 2, all threads write to the shared memory.\n+ * Part 3: the leader frees the shared memory.\n+ *\n+ * If any thread is improperly blocked by the barrier,\n+ * the shared memory accesses will trigger a segfault\n+ * or a use-after-free if ASAN is enabled.\n+ */\n+static void\n+test_barrier_lead(size_t n_threads)\n+{\n+ struct blocker_aux *aux;\n+ pthread_t *threads;\n+ size_t i;\n+\n+ ovs_barrier_init(&barrier, n_threads);\n+\n+ aux = xcalloc(n_threads, sizeof *aux);\n+ threads = xmalloc(n_threads * sizeof *threads);\n+\n+ aux[0].leader = true;\n+\n+ for (i = 0; i < n_threads; i++) {\n+ aux[i].tid = i + 1;\n+ threads[i] = ovs_thread_create(\"ovs-barrier\",\n+ lead_blocker_main, &aux[i]);\n+ }\n+\n+ for (i = 0; i < n_threads; i++) {\n+ xpthread_join(threads[i], NULL);\n+ }\n+\n+ /* If the main thread does not participate in the barrier,\n+ * it must wait for all threads to join before destroying it.\n+ */\n+ ovs_barrier_destroy(&barrier);\n+\n+ free(threads);\n+ free(aux);\n+}\n+\n+static void\n+usage(char *test_name)\n+{\n+ fprintf(stderr, \"Usage: %s [n_threads=%d] [-v]\\n\",\n+ test_name, DEFAULT_N_THREADS);\n+}\n+\n+static void\n+test_barrier(int argc, char *argv[])\n+{\n+ size_t n_threads = DEFAULT_N_THREADS;\n+ char **args = argv + optind - 1;\n+\n+ set_program_name(argv[0]);\n+\n+ argc -= optind;\n+ if (argc > 2) {\n+ usage(args[0]);\n+ return;\n+ }\n+\n+ while (argc-- > 0) {\n+ args++;\n+ if (!strcmp(args[0], \"-v\")) {\n+ verbose = true;\n+ } else {\n+ n_threads = strtol(args[0], NULL, 10);\n+ if (n_threads > 20) {\n+ n_threads = 20;\n+ }\n+ }\n+ }\n+\n+ test_barrier_basic(n_threads);\n+ test_barrier_lead(n_threads);\n+}\n+\n+OVSTEST_REGISTER(\"test-barrier\", test_barrier);\n", "prefixes": [ "ovs-dev", "v5", "03/27" ] }