From patchwork Sun Nov 27 07:28:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng He X-Patchwork-Id: 1709276 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=bS3FPr/X; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NKgG04wt2z23p5 for ; Sun, 27 Nov 2022 18:29:12 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 4945F40609; Sun, 27 Nov 2022 07:29:07 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4945F40609 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=bS3FPr/X X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ljvFKFOca3KU; Sun, 27 Nov 2022 07:29:06 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 4975540176; Sun, 27 Nov 2022 07:29:05 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4975540176 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1DC4FC0032; Sun, 27 Nov 2022 07:29:05 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 76B7BC002D for ; Sun, 27 Nov 2022 07:29:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5038B408CC for ; Sun, 27 Nov 2022 07:29:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5038B408CC Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=bS3FPr/X X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DHOhFr5EmNNu for ; Sun, 27 Nov 2022 07:29:00 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D1F7F408C9 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by smtp4.osuosl.org (Postfix) with ESMTPS id D1F7F408C9 for ; Sun, 27 Nov 2022 07:28:59 +0000 (UTC) Received: by mail-pl1-x62b.google.com with SMTP id y4so7464075plb.2 for ; Sat, 26 Nov 2022 23:28:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qWO7NoySTB/Afs7MqlBPhiYZxN1dYRJUfu+/6+4ewc0=; b=bS3FPr/XeKVRDLnjOFJDKxZhzSMnBERKlL3L7OUXQy6SPwUeeL+LGICDDC/rWtemB8 ME/FjRrQJr4oYZtcITeX5e6ABl57JP0uo/OYUarO7w9mkWLB9c+HwR+RJZlED0zAXTjJ xbwUCIPFMVOzNYjae9Xq60bkZfxhIeETEM1+mvxhip2SL/p1EoKV8TMqM91UmkQBZaAz pFKOCBCs6qcXHvmH2L2X2dcz7eyV1dJ9PNiZrRPY80w3R0yJ/jElcXUK4VlMKh96XAuT cfEVK+bLS0mJwPz6puk+fwATr4XOimnSXvEuNjDJKom9RJN/z0WDlyZiWfX6aJBg1EZe lSmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qWO7NoySTB/Afs7MqlBPhiYZxN1dYRJUfu+/6+4ewc0=; b=Q6ptOIKuuTuTjQSo2h+1XtWvA1QuZtymrrXkMonHiCbRpi1pzUNEqAxC04VnaQU0l7 lm3MN5cMbni2hdAQDBuxlRTtaqIVFCZzfaBubzsDQJAJjxNFuPQ/f4BH7p2+7vZtmzli ApvZMac5+J6qxmJ86QxMibl0AD61qWlorKQd6HAaYZPDHhWGqAr2ADX2Cqg0kxISEwyi 8XDTSoRbr3KD2KO7diqnw5rn/XnmKCYkg/NFbaDqGfyRdgHKM39TDN/u2Q8GUTbyDSWn U+yM4A90+FcSTzDSbDxgWBPm2OLGLdrEIp+YIEq0nxzCTSlokNyFOxf4rweSdjEi6An6 inBg== X-Gm-Message-State: ANoB5pkvRX2lKytCEk34DKqRE4YtAxtjzsolyit/w1qtFdITAxkBrUVf hl2WA1YRFOlD3FlO7CLSHJ69vQUxWsUAJA== X-Google-Smtp-Source: AA0mqf6BrOyL8sEm8fL9Mu3ANidATxgDkkQDlwUbKHrz283mt4YUYtr9SW9izTb5qERwBU9wTkNXHQ== X-Received: by 2002:a17:90a:5787:b0:218:8398:5846 with SMTP id g7-20020a17090a578700b0021883985846mr45282916pji.241.1669534138730; Sat, 26 Nov 2022 23:28:58 -0800 (PST) Received: from localhost ([139.177.225.242]) by smtp.gmail.com with ESMTPSA id q5-20020a170902c74500b001745662d568sm6238510plq.278.2022.11.26.23.28.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Nov 2022 23:28:58 -0800 (PST) From: Peng He X-Google-Original-From: Peng He To: ovs-dev@openvswitch.org Date: Sun, 27 Nov 2022 07:28:54 +0000 Message-Id: <20221127072856.377172-1-hepeng.0320@bytedance.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [ovs-dev] [ovs-dev v7 1/3] ofproto-dpif-upcall: fix push_dp_ops 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" push_dp_ops only handles delete ops errors but ignores the modify ops results. It's better to handle all the dp operation errors in a consistent way. We observe in the production environment that sometimes a megaflow with wrong actions keep staying in datapath. The coverage command shows revalidators have dumped several times, however the correct actions are not set. This implies that the ukey's action does not equal to the meagaflow's, i.e. revalidators think the underlying megaflow's actions are correct however they are not. We also check the megaflow using the ofproto/trace command, and the actions are not matched with the ones in the actual magaflow. By performing a revalidator/purge command, the right actions are set. This patch prevents the inconsistency by considering modify failure in revalidators. To note, we cannot perform two state transitions and change ukey_state into UKEY_EVICTED directly here, because, if we do so, the sweep will remove the ukey alone and leave dp flow alive. Later, the dump will retrieve the dp flow and might even recover it. This will contribute the stats of this dp flow twice. Signed-off-by: Peng He --- ofproto/ofproto-dpif-upcall.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 7ad728adf..c2cefbeb8 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -2416,26 +2416,30 @@ push_dp_ops(struct udpif *udpif, struct ukey_op *ops, size_t n_ops) for (i = 0; i < n_ops; i++) { struct ukey_op *op = &ops[i]; - struct dpif_flow_stats *push, *stats, push_buf; - - stats = op->dop.flow_del.stats; - push = &push_buf; - - if (op->dop.type != DPIF_OP_FLOW_DEL) { - /* Only deleted flows need their stats pushed. */ - continue; - } if (op->dop.error) { - /* flow_del error, 'stats' is unusable. */ if (op->ukey) { ovs_mutex_lock(&op->ukey->mutex); - transition_ukey(op->ukey, UKEY_EVICTED); + if (op->dop.type == DPIF_OP_FLOW_DEL) { + transition_ukey(op->ukey, UKEY_EVICTED); + } else { + transition_ukey(op->ukey, UKEY_EVICTING); + } ovs_mutex_unlock(&op->ukey->mutex); } continue; } + if (op->dop.type != DPIF_OP_FLOW_DEL) { + /* Only deleted flows need their stats pushed. */ + continue; + } + + struct dpif_flow_stats *push, *stats, push_buf; + + stats = op->dop.flow_del.stats; + push = &push_buf; + if (op->ukey) { ovs_mutex_lock(&op->ukey->mutex); transition_ukey(op->ukey, UKEY_EVICTED); @@ -2848,6 +2852,14 @@ revalidator_sweep__(struct revalidator *revalidator, bool purge) continue; } ukey_state = ukey->state; + + if (ukey_state == UKEY_EVICTING) { + /* previous modify operation fails on this ukey and ukey_state + * is set to UKEY_EVICTING, issue a delete operation on this + * ukey. + */ + delete_op_init(udpif, &ops[n_ops++], ukey); + } if (ukey_state == UKEY_OPERATIONAL || (ukey_state == UKEY_VISIBLE && purge)) { struct recirc_refs recircs = RECIRC_REFS_EMPTY_INITIALIZER; From patchwork Sun Nov 27 07:28:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng He X-Patchwork-Id: 1709275 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=G0DP2AMW; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NKgG00VgWz23nt for ; Sun, 27 Nov 2022 18:29:12 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D35C981DEE; Sun, 27 Nov 2022 07:29:09 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D35C981DEE Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=G0DP2AMW X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xDwdFf3d1Qw3; Sun, 27 Nov 2022 07:29:09 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 15EE381A33; Sun, 27 Nov 2022 07:29:08 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 15EE381A33 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DDEB4C007E; Sun, 27 Nov 2022 07:29:05 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id A9EF1C002D for ; Sun, 27 Nov 2022 07:29:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 77DEB40292 for ; Sun, 27 Nov 2022 07:29:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 77DEB40292 Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=G0DP2AMW X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RUfaifUHSSnd for ; Sun, 27 Nov 2022 07:29:02 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org C134B40176 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by smtp2.osuosl.org (Postfix) with ESMTPS id C134B40176 for ; Sun, 27 Nov 2022 07:29:02 +0000 (UTC) Received: by mail-pj1-x1029.google.com with SMTP id b11so6836503pjp.2 for ; Sat, 26 Nov 2022 23:29:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XaRfJcn+MGcUEve5ATFyRCd4iAqBuVJGI3BBPNkGD58=; b=G0DP2AMWIr/3apF6RANe2OsIn6bg1eYgQDxbRJQG5U0E6oj6kGUYO87S4YnfN+fw0D k39E1uEha5JstomBnCS4Dlw3VGdRPsGI9dNahMwEsYkqRo8ug3trKUno4VCcOsYSV9rk 4X0YxTz5agaf8twWE4y5enMb/jVOwrRojXQj2AW+to3YhCfvlG2to8zfHPhU8OjjFY0q glAcJ25uwUQGsZKn3DDKJvsLgq2QQ/Y5VVPgnBx5POoZRDmk2uYxZCXCP5OeFD5CkLWi K0sn9yB16sqfaLjqjHp6sl4xhYwVPu8fjj2VHi5VzEO050cLLkbILJRYL+2aVAA/e1Gg 5WWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XaRfJcn+MGcUEve5ATFyRCd4iAqBuVJGI3BBPNkGD58=; b=B8fXQR3/KVdX9ZxPBESb4RnzJeqE8hmApxOjIALnfAs+ZzgAfnaSKzb3MkblLR/0bn 842ebjZV8Lmwk9qzDr+Z9GMe963D8u4QmfmLMPYpstDJwI4w3OYfgdZR7/iZoYjAwqO5 VMyavwVxDpiWOYJBTYkxCjMWPTxfYBMIlLoavasSyiXalbX9Hc7Ubtw3JFoAZYcpXO2t 8GseAAs4S/EJLRveSIqYo9YYwQknJCvvIoe1x/aKVLH8R7eXtruYI4K2HII7cQzUKwdD lpdGwhqeSUm7zcvjyx/cOyIqTExKh3yS8iuUk1zgsi7wYuA2oYVL/S1kfv2p1o7TuZyX aPNA== X-Gm-Message-State: ANoB5plE+6k4ayEWe1jdVCWtwjfVB3osBnII7kwd3Tu360UsymaBeMjm H6CTE2z+LnOFzDvkW9L2nMrlG8d9rLL5CQ== X-Google-Smtp-Source: AA0mqf6PzCSmXZRMyMHeF/u89EpVjFONwxy87XDtoe9B0Hogcu4abgttCEQLiW1MCz6HHMJoKcJw9g== X-Received: by 2002:a17:902:eb8f:b0:189:38a1:3106 with SMTP id q15-20020a170902eb8f00b0018938a13106mr24107648plg.2.1669534141853; Sat, 26 Nov 2022 23:29:01 -0800 (PST) Received: from localhost ([139.177.225.242]) by smtp.gmail.com with ESMTPSA id c194-20020a621ccb000000b0056a93838606sm5723080pfc.58.2022.11.26.23.29.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Nov 2022 23:29:01 -0800 (PST) From: Peng He X-Google-Original-From: Peng He To: ovs-dev@openvswitch.org Date: Sun, 27 Nov 2022 07:28:55 +0000 Message-Id: <20221127072856.377172-2-hepeng.0320@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221127072856.377172-1-hepeng.0320@bytedance.com> References: <20221127072856.377172-1-hepeng.0320@bytedance.com> MIME-Version: 1.0 Subject: [ovs-dev] [ovs-dev v7 2/3] ofproto-dpif-upcall: new ukey needs to take the old ukey's dump seq 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" The userspace datapath mananges all the magaflows by a cmap. The cmap data structrue will grow/shrink during the datapath processing and it will re-position megaflows. This might result in two revalidator threads might process a same megaflow during one dump stage. Consider a situation that, revalidator 1 processes a megaflow A, and decides to delete it from the datapath, at the mean time, this megaflow A is also queued in the process batch of revalidator 2. Normally it's ok for revalidators to process the same megaflow multiple times, as the dump_seq shows it's already dumped and the stats will not be contributed twice. Assume that right after A is deleted, a PMD thread generates again a new megaflow B which has the same match and action of A. The ukey of megaflow B will replace the one of megaflow A. Now the ukey B is new to the revalidator system and its dump seq is 0. Now since the dump seq of ukey B is 0, when processing megaflow A, the revalidator 2 will not identify this megaflow A has already been dumped by revalidator 1 and will contribute the old megaflow A's stats again, this results in an inconsistent stats between ukeys and megaflows. To fix this, the newly generated the ukey B should take the dump_seq of the replaced ukey A to avoid a same megaflow being revalidated twice in one dump stage. We observe in the production environment, the OpenFlow rules' stats sometimes are amplified compared to the actual value. Signed-off-by: Peng He Acked-by: Eelco Chaudron --- ofproto/ofproto-dpif-upcall.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index c2cefbeb8..8b5db6103 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -1877,6 +1877,7 @@ try_ukey_replace(struct umap *umap, struct udpif_key *old_ukey, ovs_mutex_lock(&new_ukey->mutex); cmap_replace(&umap->cmap, &old_ukey->cmap_node, &new_ukey->cmap_node, new_ukey->hash); + new_ukey->dump_seq = old_ukey->dump_seq; ovsrcu_postpone(ukey_delete__, old_ukey); transition_ukey(old_ukey, UKEY_DELETED); transition_ukey(new_ukey, UKEY_VISIBLE); From patchwork Sun Nov 27 07:28:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng He X-Patchwork-Id: 1709277 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=Ugz9E7on; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NKgG34Pknz23nt for ; Sun, 27 Nov 2022 18:29:15 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 215DE4168D; Sun, 27 Nov 2022 07:29:12 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 215DE4168D Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=Ugz9E7on X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UhBNV6-QJsyZ; Sun, 27 Nov 2022 07:29:11 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 8D85541608; Sun, 27 Nov 2022 07:29:09 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 8D85541608 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A0CF5C0078; Sun, 27 Nov 2022 07:29:08 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 28F35C0082 for ; Sun, 27 Nov 2022 07:29:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id EA72D408EE for ; Sun, 27 Nov 2022 07:29:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org EA72D408EE X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eeSGcPrlrsST for ; Sun, 27 Nov 2022 07:29:06 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 15003408CC Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by smtp4.osuosl.org (Postfix) with ESMTPS id 15003408CC for ; Sun, 27 Nov 2022 07:29:05 +0000 (UTC) Received: by mail-pf1-x42c.google.com with SMTP id 140so7690864pfz.6 for ; Sat, 26 Nov 2022 23:29:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t1x0NTaDb2EXidkxHPAGyh8JyaQxdPZLOJ+XrbeJv5w=; b=Ugz9E7on8tWLzxs0mEo79nXWdOneQK1sCC2mCZ263+4ovITERSRimKIU/xApSUqzCp WTUSZf/cenyUhO/cn/k6Tf7d79ZFjX7j59/eBoQbgnTCN1M5g+R8tGe6y8J3SDN3KqZv fEe37496CxcviXqiEbUDCfBKd/0Zz3eRf2vHk66x+WSMLDIoHTObbby+Xr94MxpZfwT0 2C7v5U1hL/qFSTw4APHC8e+aJnlujUfrGD9iB1aNibqezAOWqekpIlF/GxGXymbkB2fG kZS4Fc9UJZiOYljB7DKcUA1EzJI7fQrqZR3i3djimPMtFhNvR1Yt+bwUzsiMOSXo3MQ+ rngw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t1x0NTaDb2EXidkxHPAGyh8JyaQxdPZLOJ+XrbeJv5w=; b=mg4fJWLBG8IO77Uw+7Tm+gHl3eMkDd6wtj2UxchptNTL8wFEHWaNq7VZ3S9XzN0Cns BcZzn1W4K80mJwAX5gu9o9h19FscQ/BGTfUxB7D1V7OnMxOjd5wiuuDT4At5XIA2eVNL +R8yVKCY/oTbQ74OTSmsySVUrQMKV1ufKUM+BR7ZYcquOuwnQUiOLpKUbHy/uzV+/S3K NAFvjzgECOdGN+mVNqWqNkTE4ew9ODUtTCNHfPb7QW9V4t5ASAk/JzmaqMbRZry9GXtD gaRW9c2YB0g8256JWw1HNMLb8v8U5ZgEhgnUvQ2S38B4F8a3gQvIy5fxO6NFSE0iNPKn onxg== X-Gm-Message-State: ANoB5pko5BNfC73erV2CqY8EQZS05DuJxeAfjdVN3S+kBF3OmHQdc7LC t51scLMaakpKeI9D7u32l9rGurAVHpGxuw== X-Google-Smtp-Source: AA0mqf4IS3JSO0TOh/ITdcGw/jCS1rMU0NwKm2ZRiouHyLgxy6gbSEJYnXmr0BWc0uc4WyOCLEmXlw== X-Received: by 2002:a63:de01:0:b0:476:32a2:253 with SMTP id f1-20020a63de01000000b0047632a20253mr25607566pgg.133.1669534145036; Sat, 26 Nov 2022 23:29:05 -0800 (PST) Received: from localhost ([139.177.225.242]) by smtp.gmail.com with ESMTPSA id l5-20020a17090a4d4500b002135de3013fsm5408425pjh.32.2022.11.26.23.29.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Nov 2022 23:29:04 -0800 (PST) From: Peng He X-Google-Original-From: Peng He To: ovs-dev@openvswitch.org Date: Sun, 27 Nov 2022 07:28:56 +0000 Message-Id: <20221127072856.377172-3-hepeng.0320@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221127072856.377172-1-hepeng.0320@bytedance.com> References: <20221127072856.377172-1-hepeng.0320@bytedance.com> MIME-Version: 1.0 Subject: [ovs-dev] [ovs-dev v7 3/3] dpif-netdev: fix the race comments 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" The following comments (brought in at 0de8783a9): /* XXX: There's a race window where a flow covering this packet * could have already been installed since we last did the flow * lookup before upcall. This could be solved by moving the * mutex lock outside the loop, but that's an awful long time * to be locking revalidators out of making flow modifications. */ is out-dated. Back at commit 0de8783a9, the classifier is per-datapath, multiple PMDs share a same classifier. Since now we have changed into per-PMD classifier, the lookup code only prevents from the race results from megaflows installed by another threads, through either manually calling dpctl/add-flow or handler thread installing megaflow with pmd-id == PMD_ID_NULL, there are no other threads which would insert datapath flows. Signed-off-by: Peng He --- lib/dpif-netdev.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index a45b46014..597faa047 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -8297,12 +8297,11 @@ handle_packet_upcall(struct dp_netdev_pmd_thread *pmd, if (OVS_LIKELY(error != ENOSPC)) { struct dp_netdev_flow *netdev_flow; - /* XXX: There's a race window where a flow covering this packet - * could have already been installed since we last did the flow - * lookup before upcall. This could be solved by moving the - * mutex lock outside the loop, but that's an awful long time - * to be locking revalidators out of making flow modifications. */ ovs_mutex_lock(&pmd->flow_mutex); + /* Two scenarios that race could happen: + * 1) manually add megaflow through dpctl/add-flow + * 2) handler installs a megaflow with pmd-id == PMD_ID_NULL + */ netdev_flow = dp_netdev_pmd_lookup_flow(pmd, key, NULL); if (OVS_LIKELY(!netdev_flow)) { netdev_flow = dp_netdev_flow_add(pmd, &match, &ufid,