From patchwork Sat Jun 4 14:35:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng He X-Patchwork-Id: 1638941 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=DAcxHdea; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LFj3M0zjxz9sGG for ; Sun, 5 Jun 2022 00:35:43 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 610C36059B; Sat, 4 Jun 2022 14:35:41 +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 41GtJFpyY35L; Sat, 4 Jun 2022 14:35:40 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id A536360AD1; Sat, 4 Jun 2022 14:35:39 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6D8CFC0039; Sat, 4 Jun 2022 14:35:39 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 82A82C002D for ; Sat, 4 Jun 2022 14:35:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 72316842E7 for ; Sat, 4 Jun 2022 14:35:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com 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 GdHav48rMfJV for ; Sat, 4 Jun 2022 14:35:37 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by smtp1.osuosl.org (Postfix) with ESMTPS id EE9CC842E4 for ; Sat, 4 Jun 2022 14:35:36 +0000 (UTC) Received: by mail-pj1-x1036.google.com with SMTP id e24so9465525pjt.0 for ; Sat, 04 Jun 2022 07:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=1lDxrKMgOMSZ9zqjwtfRRifv72zpweh6n82dsgAmreY=; b=DAcxHdeajQ1Z/S2tL3ssx/gF6cBKkXppameSXZmkNKOa8i+cnUDb9+BAkFtqIxYAki sPCLL++8rA8rOZ9+XRRYeP0dYq6BNq37wkoHJy2NuBGaaZB7QNnLAo7kqR8KoSGnCOWA 5fNLIlP62oZ4GMMKiYsp+lDR1ZBpHrTXHa7JejNAUi87+PGNJfmx+z+rGgkMvnMOPlC1 PosoVmzLLLJWchDTTGnJuNGUc9F8y8mA/VO0c0KfO1CsM8UVp65/kvvlThaiDYPN9x4q vsRh+HEHM2TE0LGL2yktpw6AC2m014tKhR857SYmV36TaveH0+jxL5+ieRypUIWKzeMT 4K3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=1lDxrKMgOMSZ9zqjwtfRRifv72zpweh6n82dsgAmreY=; b=Lan70XLfe31qOHfJYfd7byOpgtSb2XC4A5YYVZfwuyY4En22ZOw49dHaZDoB1sUGMh kc2q8c08fKB8QuQfOwz4LaV/xZ0Vdsec8hUQKbdVS3JZSh3FC84KCioThwUW6/y6l5pC gKoEge6YWoRFUTmKW+KYx7zM20jr1Yn7XH+bqgnre3FR4XJz04NluYrjX+9wDNzO2whd NmEpYUntoBAmViby7YQRyX4rYngp+zS+o2Iq9M4bPHp3aD0YQ98i8jyeNWuTtXRe9JYN UH5H4ycYBuiUGBNc5kFBIQDOhzuQe3Zu2eCBtjrAAK/7XpbspIY2+ETkciAJjFo2U7uF RRPw== X-Gm-Message-State: AOAM531l1jgqrxY6EdrPq4HFopcJmknZJVHJg2HfNPRdKozm9qnVuRRR T6+iFPMQRdKJJ2RkCy2Lr3h1WbMZt9aCJg== X-Google-Smtp-Source: ABdhPJyKaebCHcR3ITZr1R8WDS6wjjLDvVnH7cHe3JOcYK3h4RsQHUIfvns+nPn1oLlzM2zv3AZHFQ== X-Received: by 2002:a17:90b:d98:b0:1e3:2a7f:4ce1 with SMTP id bg24-20020a17090b0d9800b001e32a7f4ce1mr28882938pjb.226.1654353335955; Sat, 04 Jun 2022 07:35:35 -0700 (PDT) Received: from localhost ([221.194.138.131]) by smtp.gmail.com with ESMTPSA id q6-20020a170902a3c600b0016203a92865sm1606002plb.107.2022.06.04.07.35.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jun 2022 07:35:35 -0700 (PDT) From: Peng He X-Google-Original-From: Peng He To: dev@openvswitch.org Date: Sat, 4 Jun 2022 14:35:27 +0000 Message-Id: <20220604143530.65815-1-hepeng.0320@bytedance.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [ovs-dev] [ovs-dev v1 1/4] 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. While currently the modify ops would not report any errors, it's better to handle all the dp operation errors in a consistent way. Signed-off-by: Peng He --- ofproto/ofproto-dpif-upcall.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 57f94df54..4f68f14f2 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -2407,23 +2407,26 @@ 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); ovs_mutex_unlock(&op->ukey->mutex); } + /* if it's a flow_del error, 'stats' is unusable, it's ok + * to discard the stats. + */ + continue; + } + + 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; } From patchwork Sat Jun 4 14:35:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng He X-Patchwork-Id: 1638942 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=i+Qi04hi; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LFj3Q3383z9sGG for ; Sun, 5 Jun 2022 00:35:46 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 41AF884569; Sat, 4 Jun 2022 14:35:44 +0000 (UTC) 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 kLOQS7E6snkM; Sat, 4 Jun 2022 14:35:43 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 7A5318456A; Sat, 4 Jun 2022 14:35:42 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 411BAC007B; Sat, 4 Jun 2022 14:35:42 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7EEC1C007F for ; Sat, 4 Jun 2022 14:35:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7C7A484259 for ; Sat, 4 Jun 2022 14:35:40 +0000 (UTC) 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 VqKVo7-29dim for ; Sat, 4 Jun 2022 14:35:40 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by smtp1.osuosl.org (Postfix) with ESMTPS id EED7D842E7 for ; Sat, 4 Jun 2022 14:35:39 +0000 (UTC) Received: by mail-pl1-x634.google.com with SMTP id w3so8808021plp.13 for ; Sat, 04 Jun 2022 07:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QXOJ1f3Pndqc+7GDHdqkzMJ2+CgDTvHJvLOMRueAxoA=; b=i+Qi04hi/F/onB6IJDG87M6YGmFSotHgAkX+6lks2TWRwTw341ZWMC6WxWLLnXzdcM iDVqT4NUyzN8mtcQJCXxbphCHiFM/CHulQdI27wlhOPhextzqCWX9mW+Tyqp9c8uL/IB 2RB+GLsuirWk+qWZg6eRqupBllQy1rR6/QufFx6/GtF+2+miirao92DOik0gb4Q6KxrG h4vDje3uzrjn/wjcfOvNyhSWq5OSI8s6uZp72bTy5Fa8V9QhFG3Mb9ENMPdZgPy5ONaI Ewq9jk+wmA2uZN3i4e9tFR+j/5PiqJd5hXitSHq8H07Y0bTgcg6dZEM0DjE+FQK3p/WF eUJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QXOJ1f3Pndqc+7GDHdqkzMJ2+CgDTvHJvLOMRueAxoA=; b=LCEsCLn6TOsy4Fv2TMa806fPNcrXRqRKgsSjCPoYmIMmW6YsUIxYwLrOfqigFT2eE2 zHBhZChdgitZCX4K+IdkqIVE4iU13WC4jWSzTuhwFJfpQd1RrnmrfoIvcaS7BxkR/fUK XbRjp/DljhAUwic6kq4SrAN2is/L9znfbtkSv4ce3tUjmE5S8B/mW4CBD80DwmoMaY6T vY0/oAO9nPg+yaG4ir07AlmHIC6GdEHjCmA4553har/PK8WT2E8+DU9m4PQJdoxzC+hU 53VAV77mnLsmy3d3e19L1nl93NToDjyElkNhsOKySokecKTk1mup9fOdRlcNVa8XH834 B9Ow== X-Gm-Message-State: AOAM530dAGWRovMspZ/IECEDNs1Y743xthdp+CRUpe1iynFHrvZS1MWC TjdgDPnoqgSSvHi/tKErPYS+NCThsWyxkw== X-Google-Smtp-Source: ABdhPJx+T334mB90P7fhIGCI0V10EcD4bSj46hXFRz9euqt8WuA0NFjGrfDD0WIkSK21nFwwck+xBA== X-Received: by 2002:a17:90b:390c:b0:1e2:d499:8899 with SMTP id ob12-20020a17090b390c00b001e2d4998899mr37770157pjb.161.1654353339100; Sat, 04 Jun 2022 07:35:39 -0700 (PDT) Received: from localhost ([221.194.138.131]) by smtp.gmail.com with ESMTPSA id b22-20020a056a0002d600b0050dc7628182sm5398203pft.92.2022.06.04.07.35.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jun 2022 07:35:38 -0700 (PDT) From: Peng He X-Google-Original-From: Peng He To: dev@openvswitch.org Date: Sat, 4 Jun 2022 14:35:28 +0000 Message-Id: <20220604143530.65815-2-hepeng.0320@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220604143530.65815-1-hepeng.0320@bytedance.com> References: <20220604143530.65815-1-hepeng.0320@bytedance.com> MIME-Version: 1.0 Cc: Peng He Subject: [ovs-dev] [ovs-dev v1 2/4] ofproto-dpif-upcall: fix race condition 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" There is a race condition between the revalidator threads and the handler/pmd threads. revalidator PMD threads push_dp_ops deletes a key and tries to del the dp magaflow. does the upcall, generates a new ukey, and replaces the old ukey, now the old ukey state is UKEY_DELETED dp_ops succeeds, tries to change the old ukey's state into UKEY_EVICTED, however, the old ukey's state is already UKEY_DELETED, so OVS aborts. I did not observe this in the real environment, as it takes time for PMDs to finish the upcall and replace the old ukeys. Normally, the revalidator will change ukey state into UKEY_EVICTED first. But it's better to cover this case. Signed-off-by: Peng He --- ofproto/ofproto-dpif-upcall.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 4f68f14f2..9c55e43c1 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -2411,7 +2411,9 @@ push_dp_ops(struct udpif *udpif, struct ukey_op *ops, size_t n_ops) if (op->dop.error) { if (op->ukey) { ovs_mutex_lock(&op->ukey->mutex); - transition_ukey(op->ukey, UKEY_EVICTED); + if (op->ukey->state < UKEY_EVICTED) { + transition_ukey(op->ukey, UKEY_EVICTED); + } ovs_mutex_unlock(&op->ukey->mutex); } /* if it's a flow_del error, 'stats' is unusable, it's ok @@ -2432,7 +2434,9 @@ push_dp_ops(struct udpif *udpif, struct ukey_op *ops, size_t n_ops) if (op->ukey) { ovs_mutex_lock(&op->ukey->mutex); - transition_ukey(op->ukey, UKEY_EVICTED); + if (op->ukey->state < UKEY_EVICTED) { + transition_ukey(op->ukey, UKEY_EVICTED); + } push->used = MAX(stats->used, op->ukey->stats.used); push->tcp_flags = stats->tcp_flags | op->ukey->stats.tcp_flags; push->n_packets = stats->n_packets - op->ukey->stats.n_packets; From patchwork Sat Jun 4 14:35:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng He X-Patchwork-Id: 1638943 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=XUbXOM/D; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LFj3V1Klwz9sGG for ; Sun, 5 Jun 2022 00:35:50 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 58B7D60595; Sat, 4 Jun 2022 14:35:48 +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 HJtEQGyN-sVR; Sat, 4 Jun 2022 14:35:47 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 183F960A6B; Sat, 4 Jun 2022 14:35:46 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id EE69AC007B; Sat, 4 Jun 2022 14:35:45 +0000 (UTC) X-Original-To: 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 E6AE5C002D for ; Sat, 4 Jun 2022 14:35:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id CCAFE41D4F for ; Sat, 4 Jun 2022 14:35:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com 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 ZNzY5xJ_gQUN for ; Sat, 4 Jun 2022 14:35:43 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by smtp4.osuosl.org (Postfix) with ESMTPS id CCD6241D49 for ; Sat, 4 Jun 2022 14:35:43 +0000 (UTC) Received: by mail-pg1-x52b.google.com with SMTP id s68so9405454pgs.10 for ; Sat, 04 Jun 2022 07:35:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=lw/xlPqNIeGIfYnybGNQUhb1DPqEHBDPXTfPbBidmGo=; b=XUbXOM/DaMXetx3lnre9ifJFQJ7GFusdzYkTsvI6G5eq3ZaY8GgcJ3QVXhQgzl1JX4 Jb4nc/zUk6sOjknZdJqT+3QVii43F0oEApulb+ZrujNNJYM/ulpQVH7VyMEN6ngpGqk4 DJWkIf6sfgNXJJHIAbbHXm8kz/4T6DQibCP5VuQxGLdjOiUHDJ8u+Wn1m+ItMOPakb1+ e3v9rtUaa7J5LtNjVyydhRtMUFokZ2YSfw6V/sBhSd3fhfLpxJHEkeaA5yUQyLZIRjSv yaozd0GKkQOEf25fqU2QI9oWkadHtHRbazUESya7MuvgAfubtPkGl1aYWLaEFbJhAFpv aFsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lw/xlPqNIeGIfYnybGNQUhb1DPqEHBDPXTfPbBidmGo=; b=ySVqqftb07uFHma5PjOxd0RKE4vmyxVDxCpEa3TBIxH4gZwHfz+bXLCTKZHCRezqsF R9ifSF6AtBt1g+zIPZ0hFZCI7FUQtaOneASzBkr9hxuDQQhutSZX2Djbjkcz1nNMrt/m vRQSi+BCfWdnL2fXXZPcWzLy7rGxDeyXV0ka2MXAyU6bHVpOJ5hX6DtlCx4yGvTkComy arI1/Q4oP1Ld+/SOYmhPMsEIQXWNfNEty4HsPCKGSAQ4u5jZpiiT4iGAnPf4r0moScUt aEFnKBEaYS45vEb9xJdhRTrHxu22qiQCAoKGC45H5hJOliB/sG6jra7iz7a2lQE7q3Nh cDsA== X-Gm-Message-State: AOAM530jgB7Dux+gkfrBFKozj0ThtS5kSMCbOPgG0rtJNUvKKrXvgug1 lO6KIYfgDO4/0IeStgOQ8QPwb+RyEyfCjw== X-Google-Smtp-Source: ABdhPJxNVtHAmjAzC1cMhKvDZYRB4bS5XD0bykqQDqDRnD1xjX+X36klHcPsGYMnYTxo48tNRwKVGg== X-Received: by 2002:aa7:94a6:0:b0:51b:ddb8:1fcf with SMTP id a6-20020aa794a6000000b0051bddb81fcfmr9350575pfl.23.1654353342811; Sat, 04 Jun 2022 07:35:42 -0700 (PDT) Received: from localhost ([221.194.138.131]) by smtp.gmail.com with ESMTPSA id ie12-20020a17090b400c00b001e2f0333a86sm7002441pjb.12.2022.06.04.07.35.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jun 2022 07:35:42 -0700 (PDT) From: Peng He X-Google-Original-From: Peng He To: dev@openvswitch.org Date: Sat, 4 Jun 2022 14:35:29 +0000 Message-Id: <20220604143530.65815-3-hepeng.0320@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220604143530.65815-1-hepeng.0320@bytedance.com> References: <20220604143530.65815-1-hepeng.0320@bytedance.com> MIME-Version: 1.0 Subject: [ovs-dev] [ovs-dev v1 3/4] 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. After A is deleted from datapath, revalidator 2 will take the stats info from A and contribute to the OpenFlow rules' stats. Now it's ok for revalidator 2 to process the old megaflow A again, even it's deleted, as the corresponding ukey's state is UKEY_EVICTED, and its dump_seq shows it's already dumped. 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. Now since ukey B is newly generated, the revalidator will count the stats info as new, and contribute the old megaflow A's stats again into the OpenFlow rules' stats, 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 replaced 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 --- 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 9c55e43c1..791606cc1 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -1868,6 +1868,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);