From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id D542F5A026D for ; Tue, 2 Jan 2024 19:13:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704219214; 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=hnNocNGV1XOeVSllCF1QtpEnRAhknq9YFWkmOiTn0Hc=; b=f/jKDi5B84uUj92xGgEJxckdi51uhYsxbYwTWn8lrOWCZBh7WhzTJVEasfkOA2D04bZYnK QPUXPwGUMlKS/a60KPKLlE3I0a6OWUSyhDnNYb1hXnjOVNTqWH1yj1pcoZKBoefOhw0UjW 2lESdaRvd5tmyw/WHc87Z7lbyI3Ej08= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-183-S5AcGQblN6qjxyJoEeSgDQ-1; Tue, 02 Jan 2024 13:13:33 -0500 X-MC-Unique: S5AcGQblN6qjxyJoEeSgDQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id F1B2C101A551; Tue, 2 Jan 2024 18:13:31 +0000 (UTC) Received: from elisabeth (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0CC1240C6EB9; Tue, 2 Jan 2024 18:13:30 +0000 (UTC) Date: Tue, 2 Jan 2024 19:13:28 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v3 05/13] flow, tcp: Add flow-centric dispatch for deferred flow handling Message-ID: <20240102191328.206f0fe4@elisabeth> In-Reply-To: References: <20231221061549.976358-1-david@gibson.dropbear.id.au> <20231221061549.976358-6-david@gibson.dropbear.id.au> <20231228192446.66102e44@elisabeth> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: O3BHLCADTPOK24SBOWLQFNQ4PZEMR6VH X-Message-ID-Hash: O3BHLCADTPOK24SBOWLQFNQ4PZEMR6VH X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Sun, 31 Dec 2023 16:56:30 +1100 David Gibson wrote: > On Thu, Dec 28, 2023 at 07:24:46PM +0100, Stefano Brivio wrote: > > On Thu, 21 Dec 2023 17:15:41 +1100 > > David Gibson wrote: > > > > > tcp_defer_handler(), amongst other things, scans the flow table and does > > > some processing for each TCP connection. When we add other protocols to > > > the flow table, they're likely to want some similar scanning. It makes > > > more sense for cache friendliness to perform a single scan of the flow > > > table and dispatch to the protocol specific handlers, rather than having > > > each protocol separately scan the table. > > > > > > To that end, add a new flow_defer_handler() handling all flow-linked > > > deferred operations. > > > > > > Signed-off-by: David Gibson > > > --- > > > flow.c | 23 +++++++++++++++++++++++ > > > flow.h | 1 + > > > passt.c | 1 + > > > tcp.c | 19 ++----------------- > > > tcp_conn.h | 1 + > > > 5 files changed, 28 insertions(+), 17 deletions(-) > > > > > > diff --git a/flow.c b/flow.c > > > index a1c0a34..0a0402d 100644 > > > --- a/flow.c > > > +++ b/flow.c > > > @@ -83,3 +83,26 @@ void flow_log_(const struct flow_common *f, int pri, const char *fmt, ...) > > > > > > logmsg(pri, "Flow %u (%s): %s", flow_idx(f), FLOW_TYPE(f), msg); > > > } > > > + > > > +/** > > > + * flow_defer_handler() - Handler for per-flow deferred tasks > > > + * @c: Execution context > > > + */ > > > +void flow_defer_handler(struct ctx *c) > > > +{ > > > + union flow *flow; > > > + > > > + for (flow = flowtab + c->flow_count - 1; flow >= flowtab; flow--) { > > > + switch (flow->f.type) { > > > + case FLOW_TCP: > > > + tcp_flow_defer(c, flow); > > > + break; > > > + case FLOW_TCP_SPLICE: > > > + tcp_splice_flow_defer(c, flow); > > > + break; > > > + default: > > > + /* Assume other flow types don't need any handling */ > > > + ; > > > + } > > > + } > > > +} > > > diff --git a/flow.h b/flow.h > > > index 959b461..6b17fa8 100644 > > > --- a/flow.h > > > +++ b/flow.h > > > @@ -67,6 +67,7 @@ static inline bool flow_sidx_eq(flow_sidx_t a, flow_sidx_t b) > > > union flow; > > > > > > void flow_table_compact(struct ctx *c, union flow *hole); > > > +void flow_defer_handler(struct ctx *c); > > > > > > void flow_log_(const struct flow_common *f, int pri, const char *fmt, ...) > > > __attribute__((format(printf, 3, 4))); > > > diff --git a/passt.c b/passt.c > > > index 0246b04..5f72a28 100644 > > > --- a/passt.c > > > +++ b/passt.c > > > @@ -103,6 +103,7 @@ static void post_handler(struct ctx *c, const struct timespec *now) > > > /* NOLINTNEXTLINE(bugprone-branch-clone): intervals can be the same */ > > > CALL_PROTO_HANDLER(c, now, icmp, ICMP); > > > > > > + flow_defer_handler(c); > > > #undef CALL_PROTO_HANDLER > > > } > > > > > > diff --git a/tcp.c b/tcp.c > > > index ad1a70d..9230d80 100644 > > > --- a/tcp.c > > > +++ b/tcp.c > > > @@ -1306,7 +1306,7 @@ static struct tcp_tap_conn *tcp_hash_lookup(const struct ctx *c, > > > * @c: Execution context > > > * @flow: Flow table entry for this connection > > > */ > > > -static void tcp_flow_defer(struct ctx *c, union flow *flow) > > > +void tcp_flow_defer(struct ctx *c, union flow *flow) > > > { > > > const struct tcp_tap_conn *conn = &flow->tcp; > > > > > > @@ -1364,26 +1364,11 @@ static void tcp_l2_data_buf_flush(const struct ctx *c) > > > * tcp_defer_handler() - Handler for TCP deferred tasks > > > * @c: Execution context > > > */ > > > +/* cppcheck-suppress constParameterPointer */ > > > > This needs to be: > > > > /* cppcheck-suppress [constParameterPointer, unmatchedSuppression] */ > > > > otherwise we get warnings with cppcheck 2.10, > > Drat, do we? I was hoping this was a new warning type with the newer > cppcheck, and it would ignore the suppression if it was for a warning > type it didn't know about. Yeah... go figure. On the other hand it's not really a new type in the sense that this _should_ have been covered by a "constParameter" warning, before 2.11. > > and we'll get warnings if > > cppcheck's behaviour ever changes again. > > That's actually a good thing. This one isn't a workaround for a > cppcheck false positive or weird semantic that we hope will go away. > Rhe warning is real and correct as far as it goes. The problem is > that the signature needs to match that of other deferred handlers > because of how we generate the calls from a macro. Some of those > others need write access to the context. Oops, I didn't realise. Well, in any case, then we don't expect cppcheck's behaviour to ever change in this regard, so I don't see any advantage omitting unmatchedSuppression here. -- Stefano