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 489CC5A026F for ; Wed, 27 Sep 2023 19:05:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695834306; 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=Gbmz7rLYvnvzgGTz8rs1QCpAAbE+rKgI7vewJrwDyuI=; b=Vbrl9tDRFJKEF17TwM+0FDz4YQG5MU9Km87PxdK1HBXI904+LqX8yr1w9JmzlHOMtTs5E9 oqp7vI4rxhPKEWxokUi6gnPL5xiW/Gbgza827uIa2lX8sId/N//uuL/Xnk6YdvHcITct+Q KrevldVXVwa5YUjZdkpUNiCY3tJ81IY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-DJQZ3GLsOXSQ5VpGa9tNNA-1; Wed, 27 Sep 2023 13:05:04 -0400 X-MC-Unique: DJQZ3GLsOXSQ5VpGa9tNNA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC77F3816C8D; Wed, 27 Sep 2023 17:05:03 +0000 (UTC) Received: from elisabeth (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E01AA176E0; Wed, 27 Sep 2023 17:05:02 +0000 (UTC) Date: Wed, 27 Sep 2023 19:05:00 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 10/10] siphash: Use incremental rather than all-at-once siphash functions Message-ID: <20230927190500.3b81dcd6@elisabeth> In-Reply-To: References: <20230922140630.3184256-1-david@gibson.dropbear.id.au> <20230922140630.3184256-11-david@gibson.dropbear.id.au> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: G5RZSVULYX6SBGZJHMWKOE3D32BCPPEJ X-Message-ID-Hash: G5RZSVULYX6SBGZJHMWKOE3D32BCPPEJ 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 Tue, 26 Sep 2023 17:02:19 +1000 David Gibson wrote: > On Tue, Sep 26, 2023 at 04:23:45PM +1000, David Gibson wrote: > > On Sat, Sep 23, 2023 at 12:06:30AM +1000, David Gibson wrote: > > > We have a bunch of variants of the siphash functions for different data > > > sizes. The callers, in tcp.c, need to pack the various values they want to > > > hash into a temporary structure, then call the appropriate version. We can > > > avoid the copy into the temporary by directly using the incremental > > > siphash functions. > > > > > > The length specific hash functions also have an undocumented constraint > > > that the data pointer they take must, in fact, be aligned to avoid > > > unaligned accesses, which may cause crashes on some architectures. > > > > > > So, prefer the incremental approach and remove the length-specific > > > functions. > > > > > > Signed-off-by: David Gibson > > > --- > > > Makefile | 2 +- > > > inany.h | 16 ++++++- > > > siphash.c | 121 --------------------------------------------------- > > > tcp.c | 32 +++++--------- > > > tcp_splice.c | 1 + > > > 5 files changed, 27 insertions(+), 145 deletions(-) > > > delete mode 100644 siphash.c > > > > > > diff --git a/Makefile b/Makefile > > > index 4435bd6..ec3c3fb 100644 > > > --- a/Makefile > > > +++ b/Makefile > > > @@ -45,7 +45,7 @@ FLAGS += -DDUAL_STACK_SOCKETS=$(DUAL_STACK_SOCKETS) > > > > > > PASST_SRCS = arch.c arp.c checksum.c conf.c dhcp.c dhcpv6.c icmp.c igmp.c \ > > > isolation.c lineread.c log.c mld.c ndp.c netlink.c packet.c passt.c \ > > > - pasta.c pcap.c siphash.c tap.c tcp.c tcp_splice.c udp.c util.c > > > + pasta.c pcap.c tap.c tcp.c tcp_splice.c udp.c util.c > > > QRAP_SRCS = qrap.c > > > SRCS = $(PASST_SRCS) $(QRAP_SRCS) > > > > > > diff --git a/inany.h b/inany.h > > > index aadb20b..266d101 100644 > > > --- a/inany.h > > > +++ b/inany.h > > > @@ -14,8 +14,9 @@ > > > * @v4mapped.zero: All zero-bits for an IPv4 address > > > * @v4mapped.one: All one-bits for an IPv4 address > > > * @v4mapped.a4: If @a6 is an IPv4 mapped address, the IPv4 address > > > + * @u64: As an array of u64s (solely for hashing) > > > * > > > - * @v4mapped shouldn't be accessed except via helpers. > > > + * @v4mapped and @u64 shouldn't be accessed except via helpers. > > > */ > > > union inany_addr { > > > struct in6_addr a6; > > > @@ -24,7 +25,9 @@ union inany_addr { > > > uint8_t one[2]; > > > struct in_addr a4; > > > } v4mapped; > > > + uint64_t u64[2]; > > > > I realised this change alters the alignment of inany from 4 bytes to 8 > > bytes, which causes problems for things I have in the works. Revised > > version coming. > > Actually, I might as well wait for any comments you have on v1, before > folding that into v2. Nothing else from my side. -- Stefano