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.133.124]) by passt.top (Postfix) with ESMTP id 7C6B75A0272 for ; Thu, 28 Dec 2023 19:24:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703787895; 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=r7G57TpzIGNWWkTQ++swwSUZPCsUX7G2u+UtAAoVCuE=; b=BKcwslyBu02KmARGsPv+pV+7lZdGpG0GObP5KqdpcYwQfaWyDOTfdHaGxslmwYr7aIE60/ oNAE7USjuFiv3xXoUnvd5CCQ3puFz06D4P1aEqiU/C3zRammKYQRilhbQaXds5jEywV8sP 7kgtcLCDieapCUTf+ci5G3ypklBnzvs= 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-574-spGhqcXAPoijxzzxwU-Iwg-1; Thu, 28 Dec 2023 13:24:53 -0500 X-MC-Unique: spGhqcXAPoijxzzxwU-Iwg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 35722879840; Thu, 28 Dec 2023 18:24:53 +0000 (UTC) Received: from elisabeth (unknown [10.39.208.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A641492BE6; Thu, 28 Dec 2023 18:24:51 +0000 (UTC) Date: Thu, 28 Dec 2023 19:24:46 +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: <20231228192446.66102e44@elisabeth> In-Reply-To: <20231221061549.976358-6-david@gibson.dropbear.id.au> References: <20231221061549.976358-1-david@gibson.dropbear.id.au> <20231221061549.976358-6-david@gibson.dropbear.id.au> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: N3CJ2657NZTMIDD56IKWPGKPBMMPE5TM X-Message-ID-Hash: N3CJ2657NZTMIDD56IKWPGKPBMMPE5TM 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 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, and we'll get warnings if cppcheck's behaviour ever changes again. -- Stefano