Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2218450/?format=api
{ "id": 2218450, "url": "http://patchwork.ozlabs.org/api/patches/2218450/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/20260401091318.2671624-2-elibr@nvidia.com/", "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": "<20260401091318.2671624-2-elibr@nvidia.com>", "list_archive_url": null, "date": "2026-04-01T09:13:08", "name": "[ovs-dev,v3,01/11] ovs-rcu: Add support for embedded variant.", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "d62f4645c7d3a594d95d389e0a206d0fe3773624", "submitter": { "id": 79848, "url": "http://patchwork.ozlabs.org/api/people/79848/?format=api", "name": "Eli Britstein", "email": "elibr@nvidia.com" }, "delegate": { "id": 75123, "url": "http://patchwork.ozlabs.org/api/users/75123/?format=api", "username": "echaudron", "first_name": "Eelco", "last_name": "Chaudron", "email": "echaudro@redhat.com" }, "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/20260401091318.2671624-2-elibr@nvidia.com/mbox/", "series": [ { "id": 498297, "url": "http://patchwork.ozlabs.org/api/series/498297/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=498297", "date": "2026-04-01T09:13:07", "name": "netdev-doca", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/498297/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2218450/comments/", "check": "fail", "checks": "http://patchwork.ozlabs.org/api/patches/2218450/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<ovs-dev-bounces@openvswitch.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "dev@openvswitch.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "ovs-dev@lists.linuxfoundation.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256\n header.s=selector2 header.b=uIGQjV1C;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org)", "smtp2.osuosl.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key,\n unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256\n header.s=selector2 header.b=uIGQjV1C", "smtp2.osuosl.org;\n dmarc=pass (p=reject dis=none) header.from=nvidia.com" ], "Received": [ "from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4flzpn41xdz1yGH\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 01 Apr 2026 20:15:13 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby smtp2.osuosl.org (Postfix) with ESMTP id D92F340862;\n\tWed, 1 Apr 2026 09:15:06 +0000 (UTC)", "from smtp2.osuosl.org ([127.0.0.1])\n by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id hu6_OMAShtpO; Wed, 1 Apr 2026 09:15:05 +0000 (UTC)", "from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56])\n\tby smtp2.osuosl.org (Postfix) with ESMTPS id 7DF3240873;\n\tWed, 1 Apr 2026 09:15:05 +0000 (UTC)", "from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id 5C82BC0070;\n\tWed, 1 Apr 2026 09:15:05 +0000 (UTC)", "from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 03D50C003D\n for <dev@openvswitch.org>; Wed, 1 Apr 2026 09:15:05 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n by smtp2.osuosl.org (Postfix) with ESMTP id 4B3B040862\n for <dev@openvswitch.org>; Wed, 1 Apr 2026 09:14:54 +0000 (UTC)", "from smtp2.osuosl.org ([127.0.0.1])\n by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id RaFWWJyYitCQ for <dev@openvswitch.org>;\n Wed, 1 Apr 2026 09:14:53 +0000 (UTC)", "from CH4PR04CU002.outbound.protection.outlook.com\n (mail-northcentralusazlp170130007.outbound.protection.outlook.com\n [IPv6:2a01:111:f403:c105::7])\n by smtp2.osuosl.org (Postfix) with ESMTPS id 13E8F4084C\n for <dev@openvswitch.org>; Wed, 1 Apr 2026 09:14:52 +0000 (UTC)", "from PH7PR02CA0019.namprd02.prod.outlook.com (2603:10b6:510:33d::25)\n by BY5PR12MB4068.namprd12.prod.outlook.com (2603:10b6:a03:203::12)\n with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.17; Wed, 1 Apr\n 2026 09:14:44 +0000", "from SA2PEPF000015C8.namprd03.prod.outlook.com\n (2603:10b6:510:33d:cafe::f6) by PH7PR02CA0019.outlook.office365.com\n (2603:10b6:510:33d::25) with Microsoft SMTP Server (version=TLS1_3,\n cipher=TLS_AES_256_GCM_SHA384) id 15.20.9745.29 via Frontend Transport; Wed,\n 1 Apr 2026 09:14:33 +0000", "from mail.nvidia.com (216.228.117.161) by\n SA2PEPF000015C8.mail.protection.outlook.com (10.167.241.198) with Microsoft\n SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.20.9769.17 via Frontend Transport; Wed, 1 Apr 2026 09:14:44 +0000", "from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com\n (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 1 Apr\n 2026 02:14:28 -0700", "from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com\n (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 1 Apr\n 2026 02:14:25 -0700" ], "X-Virus-Scanned": [ "amavis at osuosl.org", "amavis at osuosl.org" ], "X-Comment": "SPF check N/A for local connections - client-ip=140.211.9.56;\n helo=lists.linuxfoundation.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN> ", "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 smtp2.osuosl.org 7DF3240873", "OpenDKIM Filter v2.11.0 smtp2.osuosl.org 13E8F4084C" ], "Received-SPF": [ "Pass (mailfrom) identity=mailfrom;\n client-ip=2a01:111:f403:c105::7;\n helo=ch4pr04cu002.outbound.protection.outlook.com;\n envelope-from=elibr@nvidia.com; receiver=<UNKNOWN>", "Pass (protection.outlook.com: domain of nvidia.com designates\n 216.228.117.161 as permitted sender) receiver=protection.outlook.com;\n client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 smtp2.osuosl.org 13E8F4084C", "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n b=Efm+jrq4L7eax5ZQwnoKqdjfd1p7dLqKEfxAuqtmceigKLFUFSAXg5V9xjHwqjJ5kU6IsSxua/7MsfRDVzE3O5pV39f79Un9vn60/Of7SBSrKl8aZMK/NEFecut6bQW2RdE14N4gSf0+MGCEUb1FcODzowRczr0t0fp84UQRuhw7c9QWthbryOzKekDEjt/NCybeYKkalRY5gXRC3s4qt0WvgvBvhWNOcN/bJpvWUD2+WdzhihDZGlV9NF6y93U7EKHSsnWmRW7OK5AduWTkAl66JWSfFFLWtsJdVTUvPADHwcME4W/RUfJTzJkeZPO6CfClXpEhL1xov0aE7ZGJHQ==", "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector10001;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n bh=i6NbXI/09akD65mFf5bYBBfoswTg0BTeVgwSDt2f26c=;\n b=fAKcNcnaWMZALLH/3P7Dd+kuEYI4jfH1Yo3EcagCmd1ccACrdGlqP7fgW1O9bSHom4oC/FKRz7Oc/txlAkqjrtIbgkYHyZSMPE7kM5BPdNgoe9pCvsL066i6H7mWL+4kwezcoxJS9u/q3JoQCAXCi/6xksp1iE/HkgUQnGGDEdvBgTk3n9fS48dIJDYEXahwYzFdeSnVpJqlfUgejeiCuEiPAqMWPltqBFHJJXIcxH+PH/aI8Z3vO1Aig7zAac2iODdsXo4weUFqvodoiF3p9QGwI/tI7izm6AyYbVboxSjr55k78ORt+sym0DhoJJSPeRQJhP42MTC5Wn78REecTA==", "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass (sender ip is\n 216.228.117.161) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com;\n dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com;\n dkim=none (message not signed); arc=none (0)", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com;\n s=selector2;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=i6NbXI/09akD65mFf5bYBBfoswTg0BTeVgwSDt2f26c=;\n b=uIGQjV1Cpy4ehbgfAFkRGUdjq9sFDV+n2MqQkEpIh7ioIhNcdZn/JqxZynhzgCZKqYHLwAn8eqspJMct3Ui3pSzbPHo4NXuQfGgY2Pac7lzG8vTVOrq6q5g5GMysXk20j/5kqosxjxq+sgEZsVr7zqwyetI0xHb+iD/coX+GgO5ymgBhAU2o5JU/1wsvKmklKJ7xt2Q3lLBO6lmD8uQRFaH4OPcT9Vil2EQVxYcgXBkhK6jHoq835GluJu5FzHFtlqeLifx+10eOS8b5+N/uyTJAt/5RdDEIZnLidcGNPlHtlPPtUk5PAYAElN/jOxypqymYtlHSv2eWDEEeG2+m5w==", "X-MS-Exchange-Authentication-Results": "spf=pass (sender IP is 216.228.117.161)\n smtp.mailfrom=nvidia.com;\n dkim=none (message not signed)\n header.d=none;dmarc=pass action=none header.from=nvidia.com;", "From": "Eli Britstein <elibr@nvidia.com>", "To": "<dev@openvswitch.org>", "Date": "Wed, 1 Apr 2026 12:13:08 +0300", "Message-ID": "<20260401091318.2671624-2-elibr@nvidia.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20260401091318.2671624-1-elibr@nvidia.com>", "References": "<20260401091318.2671624-1-elibr@nvidia.com>", "MIME-Version": "1.0", "X-Originating-IP": "[10.126.231.35]", "X-ClientProxiedBy": "rnnvmail203.nvidia.com (10.129.68.9) To\n rnnvmail201.nvidia.com (10.129.68.8)", "X-EOPAttributedMessage": "0", "X-MS-PublicTrafficType": "Email", "X-MS-TrafficTypeDiagnostic": "SA2PEPF000015C8:EE_|BY5PR12MB4068:EE_", "X-MS-Office365-Filtering-Correlation-Id": "f96aba90-0d28-425c-0126-08de8fcf1d6c", "X-MS-Exchange-SenderADCheck": "1", "X-MS-Exchange-AntiSpam-Relay": "0", "X-Microsoft-Antispam": "BCL:0;\n ARA:13230040|1800799024|82310400026|376014|36860700016|22082099003|56012099003|18002099003;", "X-Microsoft-Antispam-Message-Info": "\n pYfGJ6n/twdur+zfQPwu2FPP6RI20egkrxrXgSolUUodVXYCc+3aqBWwU1rPsb8PvCWor3Xe7ldzR2QbDUQcmgtD2KVdtdjR/hftYObwpt8UZurUTroC66TVVflEp6FvpT+uFPouF9rKTucyLEp78aI5x49FKeVHZciEQFN2MVtHUC7hJ9l28unE8PtQT0In/ZFsG6ciUtmmMLlgV9nzREg8ZHwJP4h1CIfkhmBV+cThTzPiKZoVR0m6p55IJNBMRQmUdTP91W370sGahWWpcB6ujh1Ql4+iWrEHimdSVPtSero+fB3beJNQ8cItpKL+fLy9o10VWeOh3O7rAykKK6mO55Fu+Y+R1risPL26h9H+p8awqD4OCpbdwm0cEn3YQ2gnUAld+xuimyI5uYu8ZWbgO0oC1vufudk4eWKAZGAu5jVss2pzCF6/hhl4S9reO3efURqtcueK31VgwjDDyvTqLudU2aIUJSYyyCs2FS6hAig7PlDdLa7c6nkzKL9ftUCmg3upM4rylrKNgf+3xJDK3h2eSPFHJGguk6w60MnZSWWV5Nm0fHDSpK/CvVvneCogrXxNKN55xZOzRn2XPscUiDk4aXRHQsEKolPgLDhe64I9Fcr0AbJyY1kZ10p8VQ5ID8rl/yRmEzyVlvMcai5ijXZF0LTkznyI7zlBcXPzFrFI0iXj0T3b1F8GZcsmbtfqrMy6EUlZ1rn8ya9V5eP/amaQj2UrKif9mPT/+sKy+tcHmBRYCRNpg1U8qwB9kJSvj30HAeo77bqHnSq8dQ==", "X-Forefront-Antispam-Report": "CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1;\n SRV:;\n IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE;\n SFS:(13230040)(1800799024)(82310400026)(376014)(36860700016)(22082099003)(56012099003)(18002099003);\n DIR:OUT; SFP:1101;", "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1", "X-MS-Exchange-AntiSpam-MessageData-0": "\n jHQMndCd71VQara+bJMoT57tc82CHq0e+NspU39DkugQ/8mGH9FxUFefH2QXoTh1UY3QX6GbHcpdE4C0B5tXzPLdM3K+MgOHilUh1lmDxJLCRIPTHDfcVmRuRn5cSyCcC5XkEernCNVRbvI8fvKyqtt4++09hl3Lo1H+ntkEKKnY53OjfxvtU1i5XV9jjOyXKfaFFLmP76sYGpDPJuCPn5s+0IKvtC4/NFAc2ze0ibtPmuVBkX90KQTXKEfxU+KlNk/JcyAIR71eFMRE6LAhr1X5TqZW5XBCLG4w/LjXTTfzHJLnOtiUhANqzIEZoXd0sLs4HmKYSYbRz8stBxQQJ2BJr+bSvAPCYPEcNJeDDUn8Rw0pEKLAI2u40nRjmx0ria61M0L+oBhiApQj9PdH1jqceSztiGfcdQKwTFXaWkyiE4nQmjLPWKnPqbhw8leh", "X-OriginatorOrg": "Nvidia.com", "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "01 Apr 2026 09:14:44.6742 (UTC)", "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n f96aba90-0d28-425c-0126-08de8fcf1d6c", "X-MS-Exchange-CrossTenant-Id": "43083d15-7273-40c1-b7db-39efd9ccc17a", "X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp": "\n TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161];\n Helo=[mail.nvidia.com]", "X-MS-Exchange-CrossTenant-AuthSource": "\n SA2PEPF000015C8.namprd03.prod.outlook.com", "X-MS-Exchange-CrossTenant-AuthAs": "Anonymous", "X-MS-Exchange-CrossTenant-FromEntityHeader": "HybridOnPrem", "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "BY5PR12MB4068", "Subject": "[ovs-dev] [PATCH v3 01/11] ovs-rcu: Add support for embedded\n variant.", "X-BeenThere": "ovs-dev@openvswitch.org", "X-Mailman-Version": "2.1.30", "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>", "Cc": "Eli Britstein <elibr@nvidia.com>, Ilya Maximets <i.maximets@ovn.org>,\n David Marchand <david.marchand@redhat.com>, Maor Dickman <maord@nvidia.com>", "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": "From: Gaetan Rivet <gaetanr@nvidia.com>\n\nAdd a way to schedule executions with the RCU using memory embedded\nwithin the object being scheduled, if applicable.\n\nThis way, freeing a high volume of objects does not require many small\nallocations, potentially increasing heap fragmentation and memory\npressure.\n\nSigned-off-by: Gaetan Rivet <gaetanr@nvidia.com>\nCo-authored-by: Eli Britstein <elibr@nvidia.com>\nSigned-off-by: Eli Britstein <elibr@nvidia.com>\n---\n lib/guarded-list.c | 10 ++++\n lib/guarded-list.h | 2 +\n lib/ovs-rcu.c | 110 ++++++++++++++++++++++---------------\n lib/ovs-rcu.h | 39 ++++++++++++++\n tests/test-rcu.c | 131 +++++++++++++++++++++++++++++++++++++++++++++\n 5 files changed, 249 insertions(+), 43 deletions(-)", "diff": "diff --git a/lib/guarded-list.c b/lib/guarded-list.c\nindex 2186d074e..bb77fb55f 100644\n--- a/lib/guarded-list.c\n+++ b/lib/guarded-list.c\n@@ -65,6 +65,16 @@ guarded_list_push_back(struct guarded_list *list,\n return retval;\n }\n \n+void\n+guarded_list_push_back_all(struct guarded_list *list,\n+ struct ovs_list *nodes, size_t n)\n+{\n+ ovs_mutex_lock(&list->mutex);\n+ ovs_list_push_back_all(&list->list, nodes);\n+ list->n += n;\n+ ovs_mutex_unlock(&list->mutex);\n+}\n+\n struct ovs_list *\n guarded_list_pop_front(struct guarded_list *list)\n {\ndiff --git a/lib/guarded-list.h b/lib/guarded-list.h\nindex 80ce22c12..b575dc425 100644\n--- a/lib/guarded-list.h\n+++ b/lib/guarded-list.h\n@@ -40,6 +40,8 @@ bool guarded_list_is_empty(const struct guarded_list *);\n \n size_t guarded_list_push_back(struct guarded_list *, struct ovs_list *,\n size_t max);\n+void guarded_list_push_back_all(struct guarded_list *, struct ovs_list *,\n+ size_t n);\n struct ovs_list *guarded_list_pop_front(struct guarded_list *);\n size_t guarded_list_pop_all(struct guarded_list *, struct ovs_list *);\n \ndiff --git a/lib/ovs-rcu.c b/lib/ovs-rcu.c\nindex 49afcc55c..54e6c469d 100644\n--- a/lib/ovs-rcu.c\n+++ b/lib/ovs-rcu.c\n@@ -38,7 +38,7 @@ struct ovsrcu_cb {\n };\n \n struct ovsrcu_cbset {\n- struct ovs_list list_node;\n+ struct ovsrcu_node rcu_node;\n struct ovsrcu_cb *cbs;\n size_t n_allocated;\n int n_cbs;\n@@ -49,6 +49,8 @@ struct ovsrcu_perthread {\n \n uint64_t seqno;\n struct ovsrcu_cbset *cbset;\n+ struct ovs_list pending; /* Thread-local list of ovsrcu_node. */\n+ size_t n_pending;\n char name[16]; /* This thread's name. */\n };\n \n@@ -58,15 +60,15 @@ static pthread_key_t perthread_key;\n static struct ovs_list ovsrcu_threads;\n static struct ovs_mutex ovsrcu_threads_mutex;\n \n-static struct guarded_list flushed_cbsets;\n-static struct seq *flushed_cbsets_seq;\n+static struct guarded_list flushed_nodes;\n+static struct seq *flushed_nodes_seq;\n \n static struct latch postpone_exit;\n static struct ovs_barrier postpone_barrier;\n \n static void ovsrcu_init_module(void);\n-static void ovsrcu_flush_cbset__(struct ovsrcu_perthread *, bool);\n-static void ovsrcu_flush_cbset(struct ovsrcu_perthread *);\n+static void ovsrcu_flush_nodes__(struct ovsrcu_perthread *, bool);\n+static void ovsrcu_flush_nodes(struct ovsrcu_perthread *);\n static void ovsrcu_unregister__(struct ovsrcu_perthread *);\n static bool ovsrcu_call_postponed(void);\n static void *ovsrcu_postpone_thread(void *arg OVS_UNUSED);\n@@ -85,6 +87,8 @@ ovsrcu_perthread_get(void)\n perthread = xmalloc(sizeof *perthread);\n perthread->seqno = seq_read(global_seqno);\n perthread->cbset = NULL;\n+ ovs_list_init(&perthread->pending);\n+ perthread->n_pending = 0;\n ovs_strlcpy(perthread->name, name[0] ? name : \"main\",\n sizeof perthread->name);\n \n@@ -153,9 +157,7 @@ ovsrcu_quiesce(void)\n \n perthread = ovsrcu_perthread_get();\n perthread->seqno = seq_read(global_seqno);\n- if (perthread->cbset) {\n- ovsrcu_flush_cbset(perthread);\n- }\n+ ovsrcu_flush_nodes(perthread);\n seq_change(global_seqno);\n \n ovsrcu_quiesced();\n@@ -171,9 +173,7 @@ ovsrcu_try_quiesce(void)\n perthread = ovsrcu_perthread_get();\n if (!seq_try_lock()) {\n perthread->seqno = seq_read(global_seqno);\n- if (perthread->cbset) {\n- ovsrcu_flush_cbset__(perthread, true);\n- }\n+ ovsrcu_flush_nodes__(perthread, true);\n seq_change_protected(global_seqno);\n seq_unlock();\n ovsrcu_quiesced();\n@@ -264,10 +264,10 @@ ovsrcu_exit(void)\n /* Repeatedly:\n *\n * - Wait for a grace period. One important side effect is to push the\n- * running thread's cbset into 'flushed_cbsets' so that the next call\n+ * running thread's nodes into 'flushed_nodes' so that the next call\n * has something to call.\n *\n- * - Call all the callbacks in 'flushed_cbsets'. If there aren't any,\n+ * - Call all the callbacks in 'flushed_nodes'. If there aren't any,\n * we're done, otherwise the callbacks themselves might have requested\n * more deferred callbacks so we go around again.\n *\n@@ -282,6 +282,32 @@ ovsrcu_exit(void)\n }\n }\n \n+static void\n+ovsrcu_run_cbset(void *aux)\n+{\n+ struct ovsrcu_cbset *cbset = aux;\n+ struct ovsrcu_cb *cb;\n+\n+ for (cb = cbset->cbs; cb < &cbset->cbs[cbset->n_cbs]; cb++) {\n+ cb->function(cb->aux);\n+ }\n+\n+ free(cbset->cbs);\n+ free(cbset);\n+}\n+\n+void\n+ovsrcu_postpone_embedded__(void (*function)(void *aux), void *aux,\n+ struct ovsrcu_node *rcu_node)\n+{\n+ struct ovsrcu_perthread *perthread = ovsrcu_perthread_get();\n+\n+ rcu_node->cb = function;\n+ rcu_node->aux = aux;\n+ ovs_list_push_back(&perthread->pending, &rcu_node->list_node);\n+ perthread->n_pending++;\n+}\n+\n /* Registers 'function' to be called, passing 'aux' as argument, after the\n * next grace period.\n *\n@@ -314,6 +340,7 @@ ovsrcu_postpone__(void (*function)(void *aux), void *aux)\n cbset->cbs = xmalloc(MIN_CBS * sizeof *cbset->cbs);\n cbset->n_allocated = MIN_CBS;\n cbset->n_cbs = 0;\n+ ovsrcu_postpone_embedded(ovsrcu_run_cbset, cbset, rcu_node);\n }\n \n if (cbset->n_cbs == cbset->n_allocated) {\n@@ -329,24 +356,18 @@ ovsrcu_postpone__(void (*function)(void *aux), void *aux)\n static bool OVS_NO_SANITIZE_FUNCTION\n ovsrcu_call_postponed(void)\n {\n- struct ovsrcu_cbset *cbset;\n- struct ovs_list cbsets;\n+ struct ovs_list nodes = OVS_LIST_INITIALIZER(&nodes);\n+ struct ovsrcu_node *node;\n \n- guarded_list_pop_all(&flushed_cbsets, &cbsets);\n- if (ovs_list_is_empty(&cbsets)) {\n+ guarded_list_pop_all(&flushed_nodes, &nodes);\n+ if (ovs_list_is_empty(&nodes)) {\n return false;\n }\n \n ovsrcu_synchronize();\n \n- LIST_FOR_EACH_POP (cbset, list_node, &cbsets) {\n- struct ovsrcu_cb *cb;\n-\n- for (cb = cbset->cbs; cb < &cbset->cbs[cbset->n_cbs]; cb++) {\n- cb->function(cb->aux);\n- }\n- free(cbset->cbs);\n- free(cbset);\n+ LIST_FOR_EACH_POP (node, list_node, &nodes) {\n+ node->cb(node->aux);\n }\n \n return true;\n@@ -358,9 +379,9 @@ ovsrcu_postpone_thread(void *arg OVS_UNUSED)\n pthread_detach(pthread_self());\n \n while (!latch_is_set(&postpone_exit)) {\n- uint64_t seqno = seq_read(flushed_cbsets_seq);\n+ uint64_t cb_seqno = seq_read(flushed_nodes_seq);\n if (!ovsrcu_call_postponed()) {\n- seq_wait(flushed_cbsets_seq, seqno);\n+ seq_wait(flushed_nodes_seq, cb_seqno);\n latch_wait(&postpone_exit);\n poll_block();\n }\n@@ -371,33 +392,36 @@ ovsrcu_postpone_thread(void *arg OVS_UNUSED)\n }\n \n static void\n-ovsrcu_flush_cbset__(struct ovsrcu_perthread *perthread, bool protected)\n+ovsrcu_flush_nodes__(struct ovsrcu_perthread *perthread, bool protected)\n {\n- struct ovsrcu_cbset *cbset = perthread->cbset;\n+ if (ovs_list_is_empty(&perthread->pending)) {\n+ return;\n+ }\n \n- if (cbset) {\n- guarded_list_push_back(&flushed_cbsets, &cbset->list_node, SIZE_MAX);\n- perthread->cbset = NULL;\n+ perthread->cbset = NULL;\n+ guarded_list_push_back_all(&flushed_nodes, &perthread->pending,\n+ perthread->n_pending);\n+ ovs_list_init(&perthread->pending);\n+ perthread->n_pending = 0;\n \n- if (protected) {\n- seq_change_protected(flushed_cbsets_seq);\n- } else {\n- seq_change(flushed_cbsets_seq);\n- }\n+ if (protected) {\n+ seq_change_protected(flushed_nodes_seq);\n+ } else {\n+ seq_change(flushed_nodes_seq);\n }\n }\n \n static void\n-ovsrcu_flush_cbset(struct ovsrcu_perthread *perthread)\n+ovsrcu_flush_nodes(struct ovsrcu_perthread *perthread)\n {\n- ovsrcu_flush_cbset__(perthread, false);\n+ ovsrcu_flush_nodes__(perthread, false);\n }\n \n static void\n ovsrcu_unregister__(struct ovsrcu_perthread *perthread)\n {\n- if (perthread->cbset) {\n- ovsrcu_flush_cbset(perthread);\n+ if (!ovs_list_is_empty(&perthread->pending)) {\n+ ovsrcu_flush_nodes(perthread);\n }\n \n ovs_mutex_lock(&ovsrcu_threads_mutex);\n@@ -438,8 +462,8 @@ ovsrcu_init_module(void)\n ovs_list_init(&ovsrcu_threads);\n ovs_mutex_init(&ovsrcu_threads_mutex);\n \n- guarded_list_init(&flushed_cbsets);\n- flushed_cbsets_seq = seq_create();\n+ guarded_list_init(&flushed_nodes);\n+ flushed_nodes_seq = seq_create();\n \n ovsthread_once_done(&once);\n }\ndiff --git a/lib/ovs-rcu.h b/lib/ovs-rcu.h\nindex a1c15c126..efd43a1a2 100644\n--- a/lib/ovs-rcu.h\n+++ b/lib/ovs-rcu.h\n@@ -125,6 +125,22 @@\n * ovs_mutex_unlock(&mutex);\n * }\n *\n+ * As an alternative to ovsrcu_postpone(), the same deferred execution can be\n+ * achieved using ovsrcu_postpone_embedded():\n+ *\n+ * struct deferrable {\n+ * struct ovsrcu_node rcu_node;\n+ * };\n+ *\n+ * void\n+ * deferred_free(struct deferrable *d)\n+ * {\n+ * ovsrcu_postpone_embedded(free, d, rcu_node);\n+ * }\n+ *\n+ * Using embedded fields can be preferred sometimes to avoid the small\n+ * allocations done in ovsrcu_postpone().\n+ *\n * In some rare cases an object may not be addressable with a pointer, but only\n * through an array index (e.g. because it's provided by another library). It\n * is still possible to have RCU semantics by using the ovsrcu_index type.\n@@ -173,6 +189,8 @@\n #include \"compiler.h\"\n #include \"ovs-atomic.h\"\n \n+#include \"openvswitch/list.h\"\n+\n #if __GNUC__\n #define OVSRCU_TYPE(TYPE) struct { ATOMIC(TYPE) p; }\n #define OVSRCU_INITIALIZER(VALUE) { VALUE }\n@@ -256,6 +274,27 @@ void ovsrcu_postpone__(void (*function)(void *aux), void *aux);\n (void) sizeof(*(ARG)), \\\n ovsrcu_postpone__((void (*)(void *))(FUNCTION), ARG))\n \n+struct ovsrcu_node {\n+ struct ovs_list list_node;\n+ void (*cb)(void *aux);\n+ void *aux;\n+};\n+\n+/* Calls FUNCTION passing ARG as its pointer-type argument, which\n+ * contains an 'ovsrcu_node' as a field named MEMBER. The function\n+ * is called following the next grace period. See 'Usage' above for an\n+ * example.\n+ */\n+void ovsrcu_postpone_embedded__(void (*function)(void *aux), void *aux,\n+ struct ovsrcu_node *node);\n+#define ovsrcu_postpone_embedded(FUNCTION, ARG, MEMBER) \\\n+ (/* Verify that ARG is appropriate for FUNCTION. */ \\\n+ (void) sizeof((FUNCTION)(ARG), 1), \\\n+ /* Verify that ARG is a pointer type. */ \\\n+ (void) sizeof(*(ARG)), \\\n+ ovsrcu_postpone_embedded__((void (*)(void *))(FUNCTION), ARG, \\\n+ &(ARG)->MEMBER))\n+\n /* An array index protected by RCU semantics. This is an easier alternative to\n * an RCU protected pointer to a malloc'd int. */\n typedef struct { atomic_int v; } ovsrcu_index;\ndiff --git a/tests/test-rcu.c b/tests/test-rcu.c\nindex bb17092bf..26150e7d9 100644\n--- a/tests/test-rcu.c\n+++ b/tests/test-rcu.c\n@@ -17,11 +17,16 @@\n #include <config.h>\n #undef NDEBUG\n #include \"fatal-signal.h\"\n+#include \"ovs-atomic.h\"\n #include \"ovs-rcu.h\"\n #include \"ovs-thread.h\"\n #include \"ovstest.h\"\n+#include \"seq.h\"\n+#include \"timeval.h\"\n #include \"util.h\"\n \n+#include \"openvswitch/poll-loop.h\"\n+\n static void *\n quiescer_main(void *aux OVS_UNUSED)\n {\n@@ -67,10 +72,136 @@ test_rcu_barrier(void)\n ovs_assert(count == 10);\n }\n \n+struct element {\n+ struct ovsrcu_node rcu_node;\n+ struct seq *trigger;\n+ atomic_bool wait;\n+};\n+\n+static void\n+trigger_cb(void *e_)\n+{\n+ struct element *e = (struct element *) e_;\n+\n+ seq_change(e->trigger);\n+}\n+\n+static void *\n+wait_main(void *aux)\n+{\n+ struct element *e = aux;\n+\n+ for (;;) {\n+ bool wait;\n+\n+ atomic_read(&e->wait, &wait);\n+ if (!wait) {\n+ break;\n+ }\n+ }\n+\n+ seq_wait(e->trigger, seq_read(e->trigger));\n+ poll_block();\n+\n+ return NULL;\n+}\n+\n+static void\n+test_rcu_postpone_embedded(bool multithread)\n+{\n+ long long int timeout;\n+ pthread_t waiter;\n+ struct element e;\n+ uint64_t seqno;\n+\n+ atomic_init(&e.wait, true);\n+\n+ if (multithread) {\n+ waiter = ovs_thread_create(\"waiter\", wait_main, &e);\n+ }\n+\n+ e.trigger = seq_create();\n+ seqno = seq_read(e.trigger);\n+\n+ ovsrcu_postpone_embedded(trigger_cb, &e, rcu_node);\n+\n+ /* Check that GC holds out until all threads are quiescent. */\n+ timeout = time_msec();\n+ if (multithread) {\n+ timeout += 200;\n+ }\n+ while (time_msec() <= timeout) {\n+ ovs_assert(seq_read(e.trigger) == seqno);\n+ }\n+\n+ atomic_store(&e.wait, false);\n+\n+ seq_wait(e.trigger, seqno);\n+ poll_timer_wait_until(time_msec() + 200);\n+ poll_block();\n+\n+ /* Verify that GC executed. */\n+ ovs_assert(seq_read(e.trigger) != seqno);\n+ seq_destroy(e.trigger);\n+\n+ if (multithread) {\n+ xpthread_join(waiter, NULL);\n+ }\n+}\n+\n+#define N_ORDER_CBS 5\n+\n+struct order_element {\n+ struct ovsrcu_node rcu_node;\n+ int id;\n+ int *log;\n+ int *log_idx;\n+};\n+\n+static void\n+order_cb(void *aux)\n+{\n+ struct order_element *e = aux;\n+ e->log[(*e->log_idx)++] = e->id;\n+}\n+\n+static void\n+test_rcu_ordering(void)\n+{\n+ struct order_element elems[N_ORDER_CBS];\n+ int log[N_ORDER_CBS];\n+ int log_idx = 0;\n+\n+ for (int i = 0; i < N_ORDER_CBS; i++) {\n+ elems[i].id = i;\n+ elems[i].log = log;\n+ elems[i].log_idx = &log_idx;\n+ ovsrcu_postpone_embedded(order_cb, &elems[i], rcu_node);\n+ }\n+\n+ ovsrcu_barrier();\n+\n+ ovs_assert(log_idx == N_ORDER_CBS);\n+ for (int i = 0; i < N_ORDER_CBS; i++) {\n+ if (log[i] != i) {\n+ ovs_abort(0, \"RCU embedded callback ordering violated: \"\n+ \"expected cb %d at position %d, got %d\",\n+ i, i, log[i]);\n+ }\n+ }\n+}\n+\n static void\n test_rcu(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) {\n+ const bool multithread = true;\n+\n+ /* Execute single-threaded check before spawning additional threads. */\n+ test_rcu_postpone_embedded(!multithread);\n+ test_rcu_postpone_embedded(multithread);\n+\n test_rcu_quiesce();\n test_rcu_barrier();\n+ test_rcu_ordering();\n }\n \n OVSTEST_REGISTER(\"test-rcu\", test_rcu);\n", "prefixes": [ "ovs-dev", "v3", "01/11" ] }