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 330FF5A0279 for ; Thu, 30 Nov 2023 10:21:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701336086; 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=DZo/kRbjj56w1sDEq3TW44VDTEYOYDrEMXn2+GfI0yA=; b=eFBm5YLTa/LDG7Tn6hw/lwU36kVS42+/5YdkZtuDkjvNJrMh2tVedDWQzBKw/ovpBHG6Ay SWdqwcodClvfx23Zn5ofU8qWich+f9p9hxWe2LI8gCvc92zC3E8hv9q7WHQ7HDsgJxnwmB dSfKN9hMaNoUt9X6dLP64PAUqv0Wi4U= 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-127-hUmV7i1RNhW3sil9lItzPw-1; Thu, 30 Nov 2023 04:21:24 -0500 X-MC-Unique: hUmV7i1RNhW3sil9lItzPw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 0AC39101A52D; Thu, 30 Nov 2023 09:21:24 +0000 (UTC) Received: from elisabeth (unknown [10.39.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30CA61121308; Thu, 30 Nov 2023 09:21:23 +0000 (UTC) Date: Thu, 30 Nov 2023 10:21:16 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2 07/11] flow: Introduce 'sidx' type to represent one side of one flow Message-ID: <20231130102116.273f0e18@elisabeth> In-Reply-To: References: <20231126233348.1599864-1-david@gibson.dropbear.id.au> <20231126233348.1599864-8-david@gibson.dropbear.id.au> <20231129153232.6abfe53c@elisabeth> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: IGNUA5TBW6NOPJUESBYUMP7K2R6LDNOB X-Message-ID-Hash: IGNUA5TBW6NOPJUESBYUMP7K2R6LDNOB 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, 30 Nov 2023 11:37:40 +1100 David Gibson wrote: > On Wed, Nov 29, 2023 at 03:32:32PM +0100, Stefano Brivio wrote: > > On Mon, 27 Nov 2023 10:33:44 +1100 > > David Gibson wrote: > > > > > In a number of places, we use indices into the flow table to identify a > > > specific flow. We also have cases where we need to identify a particular > > > side of a particular flow, and we expect those to become more common as > > > we generalise the flow table to cover more things. > > > > > > To assist with that, introduces flow_sidx_t, an index type which identifies > > > a specific side of a specific flow in the table. > > > > > > Signed-off-by: David Gibson > > > --- > > > flow.h | 13 +++++++++++++ > > > flow_table.h | 36 ++++++++++++++++++++++++++++++++++++ > > > 2 files changed, 49 insertions(+) > > > > > > diff --git a/flow.h b/flow.h > > > index b6da516..3c90bbd 100644 > > > --- a/flow.h > > > +++ b/flow.h > > > @@ -39,6 +39,19 @@ struct flow_common { > > > #define FLOW_TABLE_PRESSURE 30 /* % of FLOW_MAX */ > > > #define FLOW_FILE_PRESSURE 30 /* % of c->nofile */ > > > > > > +/** > > > + * struct flow_sidx - ID for one side of a specific flow > > > + * @side: Side referenced (0 or 1) > > > + * @flow: Index of flow referenced > > > + */ > > > +typedef struct flow_sidx { > > > > Implying my usual argument :) ...is there any advantage over using this > > simply as a struct? > > So, usually I too would prefer to use a struct as a struct, without a > typedef. The reason I'm doing differently here, is that I want to > emphasise that for many purposes this can be treated like an index, in > particular that it's small and trivially copyable. In particular it > should be passed by value, passing by reference would be silly. Hmm, that was exactly my "not hiding" point though. The day somebody adds here: char mood[RLIMIT_STACK_VAL + 1]; /* list of side emojis */ the typedef makes it still apparently okay to pass by value. If it's a struct, one surely has to check first. > That's kind of the opposite of what one tends to be conveying by > reminding users that they're working with a struct. I see, but it's probably a matter of taste (passing structs by value doesn't personally make me nervous). -- Stefano