From patchwork Sun Dec 8 13:22:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205664 X-Patchwork-Delegate: i.maximets@samsung.com 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.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6Tz70Vhz9sPK for ; Mon, 9 Dec 2019 00:23:51 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7C2CF8698B; Sun, 8 Dec 2019 13:23:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b2EPaWPTrdqu; Sun, 8 Dec 2019 13:23:48 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9CCDA8652A; Sun, 8 Dec 2019 13:23:34 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 86882C1D83; Sun, 8 Dec 2019 13:23:34 +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 2100EC1D7F for ; Sun, 8 Dec 2019 13:23:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 0EA4486C4A for ; Sun, 8 Dec 2019 13:23:29 +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 6BSUPritgDBE for ; Sun, 8 Dec 2019 13:23:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by whitealder.osuosl.org (Postfix) with ESMTP id C83E686BF9 for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:20 +0200 Received: from dev-r-vrt-215.mtr.labs.mlnx. (dev-r-vrt-215.mtr.labs.mlnx [10.212.215.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id xB8DNJh2002052; Sun, 8 Dec 2019 15:23:20 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:53 +0000 Message-Id: <20191208132304.15521-9-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 08/19] netdev-offload-dpdk: Protect UFID map by mutex 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: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Flow deletion and dumping for statistics collection are called from different threads. As a pre-step towards collecting HW statistics, protect the UFID map by mutex to make it thread safe. Signed-off-by: Eli Britstein --- lib/netdev-offload-dpdk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index b2ec05cec..5568400b6 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -51,6 +51,7 @@ static struct vlog_rate_limit error_rl = VLOG_RATE_LIMIT_INIT(100, 5); * A mapping from ufid to dpdk rte_flow. */ static struct cmap ufid_to_rte_flow = CMAP_INITIALIZER; +static struct ovs_mutex ufid_map_mutex = OVS_MUTEX_INITIALIZER; struct ufid_to_rte_flow_data { struct cmap_node node; @@ -630,8 +631,11 @@ netdev_offload_dpdk_destroy_flow(struct netdev *netdev, struct rte_flow *rte_flow) { struct rte_flow_error error; - int ret = netdev_dpdk_rte_flow_destroy(netdev, rte_flow, &error); + int ret; + + ovs_mutex_lock(&ufid_map_mutex); + ret = netdev_dpdk_rte_flow_destroy(netdev, rte_flow, &error); if (ret == 0) { ufid_to_rte_flow_disassociate(ufid); VLOG_DBG("%s: removed rte flow %p associated with ufid " UUID_FMT "\n", @@ -642,6 +646,7 @@ netdev_offload_dpdk_destroy_flow(struct netdev *netdev, netdev_get_name(netdev), error.message, error.type); } + ovs_mutex_unlock(&ufid_map_mutex); return ret; }