From patchwork Mon Sep 30 20:50:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valerio X-Patchwork-Id: 1991195 X-Patchwork-Delegate: aconole@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Bl6Ry/C2; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XHYC2109Zz1xt8 for ; Tue, 1 Oct 2024 06:51:25 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E0074810F7; Mon, 30 Sep 2024 20:51:23 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id XT50LKer7I1k; Mon, 30 Sep 2024 20:51:22 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 82803810EF Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Bl6Ry/C2 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 82803810EF; Mon, 30 Sep 2024 20:51:22 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 51F02C0894; Mon, 30 Sep 2024 20:51:22 +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 D6203C002A for ; Mon, 30 Sep 2024 20:51:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id C5361402C1 for ; Mon, 30 Sep 2024 20:51:20 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id FR7zVTPtg8CD for ; Mon, 30 Sep 2024 20:51:20 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=pvalerio@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org E4233402BB Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org E4233402BB Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Bl6Ry/C2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id E4233402BB for ; Mon, 30 Sep 2024 20:51:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727729478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8g15JO8SIoLvRY5rRZzaTwBVwUlCNT3fR+CA+tQ0BZI=; b=Bl6Ry/C2JY6T5AuH065HqPiCHpkoAKssC1vY/t+X6JXeXOuq4VBz0nO2Mddq9tV90vNOyQ 60vA3peJnlzP/rCxd2bFI+vhf6ES3zwD23yzmchKTpt57i1yDesjp83l1rp6cGUBm4j5I6 i6TZ2nwqIjWuunGzTDZnpGA+Sh4zP0o= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-617-5A_ybPaaNV20qvPGYtbmtw-1; Mon, 30 Sep 2024 16:51:17 -0400 X-MC-Unique: 5A_ybPaaNV20qvPGYtbmtw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42cb115566eso48598525e9.2 for ; Mon, 30 Sep 2024 13:51:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727729475; x=1728334275; 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=szwWbskAQY3MnlC6LMQivey0e86+4Sz0aq28aSVtIeM=; b=cIMo3vPFWVCFcG9P6FtLpJNztDIgd00GySwgNEItEUZAoOOg3m3Ptu/SevoLSK4lDu OziNcSllZCzMU8bSUeV4ORWxPTXqluG3oXkGtHu6R//G3KvvdjutK39GvO0OyJF9OCwe dHEAXz/5JAkMHygPzRrNOP/JDu1+0ezd/zs8gDRE/BcWQQSl6uhDWR2/9piKjxhNkIpH BEikTU9KxcOdbysryFzVbX9MN6+YWob8ZKicOB2Ei+4lchnVxZLbnuppTWKT0ToCUqy/ XDTkoTRpehLcyB1VSXBtXWAvHYP4LV+ppqoOr0lhoFM9CuvVLdEReOXGQKLUly43LzU7 DVJA== X-Gm-Message-State: AOJu0YzBwBIBQUXOm7dy24i2qE5q/+Ass8PeCrqF3Y/E1rFHDfvnAWrw 7HZ6zEbr47GZ2cml7DaYQUlKVzldIzijP41pwvxt7Ru/PwbnQrHmhRWIbs1wKz6eopSGzodDxcH bIjCDxtEZj0s6etZJycX4a5pAbFU91HYJ5fcjw+xMAh4+/FOyU88lZAUNX+PEI9fTPs4Cjh9/F6 xXfbAgtgCg4S/TEZpY04Ev2NK540gKYTUeJaOUjq4= X-Received: by 2002:a05:600c:1d1e:b0:42b:ac3d:3abc with SMTP id 5b1f17b1804b1-42f584976b0mr134901995e9.24.1727729474808; Mon, 30 Sep 2024 13:51:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4M/SBxgYrQYEMhBamUuP+NaCVZV/sOtfYM25T1jkuneSo6jnB46hmYSp2t4jXbQcPsxlsog== X-Received: by 2002:a05:600c:1d1e:b0:42b:ac3d:3abc with SMTP id 5b1f17b1804b1-42f584976b0mr134901795e9.24.1727729474202; Mon, 30 Sep 2024 13:51:14 -0700 (PDT) Received: from localhost (net-188-216-80-179.cust.vodafonedsl.it. [188.216.80.179]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e969ffcd5sm162574845e9.26.2024.09.30.13.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 13:51:13 -0700 (PDT) From: Paolo Valerio To: ovs-dev@openvswitch.org Date: Mon, 30 Sep 2024 22:50:31 +0200 Message-ID: <20240930205034.65484-3-pvalerio@redhat.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20240930205034.65484-1-pvalerio@redhat.com> References: <20240930205034.65484-1-pvalerio@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v2 3/6] conntrack: Do not use atomics to report zones info. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Atomics are not needed when reporting zone limits. Remove the restriction by defining a non-atomic common structure to report such data. The change also access atomics using the related operations to retrieve atomics reporting only the fields required by the requesting level instead of relying of struct copy. Signed-off-by: Paolo Valerio --- lib/conntrack-private.h | 8 ++++++++ lib/conntrack.c | 11 ++++++----- lib/conntrack.h | 9 ++++----- lib/dpif-netdev.c | 6 +++--- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/conntrack-private.h b/lib/conntrack-private.h index 6c65caa07..2c625d710 100644 --- a/lib/conntrack-private.h +++ b/lib/conntrack-private.h @@ -198,6 +198,14 @@ enum ct_ephemeral_range { #define FOR_EACH_PORT_IN_RANGE(curr, min, max) \ FOR_EACH_PORT_IN_RANGE__(curr, min, max, OVS_JOIN(idx, __COUNTER__)) + +struct conntrack_zone_limit { + int32_t zone; + uint32_t limit; + atomic_count count; + uint32_t zone_limit_seq; /* Used to disambiguate zone limit counts. */ +}; + struct conntrack { struct ovs_mutex ct_lock; /* Protects the following fields. */ struct cmap conns[UINT16_MAX + 1] OVS_GUARDED; diff --git a/lib/conntrack.c b/lib/conntrack.c index 8cf200e06..112d43216 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -330,18 +330,19 @@ zone_limit_lookup_or_default(struct conntrack *ct, int32_t zone) return zl ? zl : zone_limit_lookup(ct, DEFAULT_ZONE); } -struct conntrack_zone_limit +struct conntrack_zone_info zone_limit_get(struct conntrack *ct, int32_t zone) { - struct conntrack_zone_limit czl = { + struct conntrack_zone_info czl = { .zone = DEFAULT_ZONE, .limit = 0, - .count = ATOMIC_COUNT_INIT(0), - .zone_limit_seq = 0, + .count = 0, }; struct zone_limit *zl = zone_limit_lookup_or_default(ct, zone); if (zl) { - czl = zl->czl; + czl.zone = zl->czl.zone; + czl.limit = zl->czl.limit; + czl.count = atomic_count_get(&zl->czl.count); } return czl; } diff --git a/lib/conntrack.h b/lib/conntrack.h index 13bb02ea9..c3136e955 100644 --- a/lib/conntrack.h +++ b/lib/conntrack.h @@ -115,11 +115,10 @@ struct conntrack_dump { uint16_t current_zone; }; -struct conntrack_zone_limit { +struct conntrack_zone_info { int32_t zone; uint32_t limit; - atomic_count count; - uint32_t zone_limit_seq; /* Used to disambiguate zone limit counts. */ + unsigned int count; }; struct timeout_policy { @@ -161,8 +160,8 @@ int conntrack_set_sweep_interval(struct conntrack *ct, uint32_t ms); uint32_t conntrack_get_sweep_interval(struct conntrack *ct); bool conntrack_get_tcp_seq_chk(struct conntrack *ct); struct ipf *conntrack_ipf_ctx(struct conntrack *ct); -struct conntrack_zone_limit zone_limit_get(struct conntrack *ct, - int32_t zone); +struct conntrack_zone_info zone_limit_get(struct conntrack *ct, + int32_t zone); int zone_limit_update(struct conntrack *ct, int32_t zone, uint32_t limit); int zone_limit_delete(struct conntrack *ct, int32_t zone); diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 3d262463f..2a529f272 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -9732,7 +9732,7 @@ dpif_netdev_ct_get_limits(struct dpif *dpif, struct ovs_list *zone_limits_reply) { struct dp_netdev *dp = get_dp_netdev(dpif); - struct conntrack_zone_limit czl; + struct conntrack_zone_info czl; if (!ovs_list_is_empty(zone_limits_request)) { struct ct_dpif_zone_limit *zone_limit; @@ -9741,7 +9741,7 @@ dpif_netdev_ct_get_limits(struct dpif *dpif, if (czl.zone == zone_limit->zone || czl.zone == DEFAULT_ZONE) { ct_dpif_push_zone_limit(zone_limits_reply, zone_limit->zone, czl.limit, - atomic_count_get(&czl.count)); + czl.count); } else { return EINVAL; } @@ -9757,7 +9757,7 @@ dpif_netdev_ct_get_limits(struct dpif *dpif, czl = zone_limit_get(dp->conntrack, z); if (czl.zone == z) { ct_dpif_push_zone_limit(zone_limits_reply, z, czl.limit, - atomic_count_get(&czl.count)); + czl.count); } } }