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 31A715A026D for ; Fri, 3 Nov 2023 17:21:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699028504; 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=A1WUWjFJwaCCE0jbiQrVkngtf6YXPXIJ8XcRBYk3c9U=; b=TNRY5GFDMF/RF6BXIk7pHc/bFTCm62dq4RyzpekfHato97b99CkE2JjaXCJv+TMmc0qUor Zrb+zY81MOYML1IPCLs3CX+D5NggZ6YSjr/ZGm7XgMr2dLjiAVTeTkVoThRuE0Gkz8RTWx SAHy5pubWdQ+izUlhvAK13Tpif2Mu2M= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-27-TQ0LZ9gvN4K3iJBarPGGrQ-1; Fri, 03 Nov 2023 12:21:41 -0400 X-MC-Unique: TQ0LZ9gvN4K3iJBarPGGrQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 C8CF41C068CA; Fri, 3 Nov 2023 16:21:40 +0000 (UTC) Received: from elisabeth (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1E2B25C0; Fri, 3 Nov 2023 16:21:39 +0000 (UTC) Date: Fri, 3 Nov 2023 17:21:34 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 05/11] tcp_splice: Avoid awkward temporaries in tcp_splice_epoll_ctl() Message-ID: <20231103172134.5be225c9@elisabeth> In-Reply-To: <20231012015114.2612066-6-david@gibson.dropbear.id.au> References: <20231012015114.2612066-1-david@gibson.dropbear.id.au> <20231012015114.2612066-6-david@gibson.dropbear.id.au> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: J5RM65ECQPH25N3LOJYBEPCNUZY3OHEW X-Message-ID-Hash: J5RM65ECQPH25N3LOJYBEPCNUZY3OHEW 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, 12 Oct 2023 12:51:08 +1100 David Gibson wrote: > We initialise the events_a and events_b variables with > tcp_splice_conn_epoll_events() function, then immediately copy the values > into ev_a.events and ev_b.events. We can't simply pass &ev_[ab].events to > tcp_splice_conn_epoll_events(), because struct epoll_event is packed, > leading to 'pointer may be unaligned' warnings if we attempt that. > > We can, however, make tcp_splice_conn_epoll_events() take struct > epoll_event pointers rather than raw u32 pointers, avoiding the awkward > temporaries. > > Signed-off-by: David Gibson > --- > tcp_splice.c | 24 +++++++++++------------- > 1 file changed, 11 insertions(+), 13 deletions(-) > > diff --git a/tcp_splice.c b/tcp_splice.c > index 439fc1d..3419207 100644 > --- a/tcp_splice.c > +++ b/tcp_splice.c > @@ -95,25 +95,26 @@ static int tcp_sock_refill_ns(void *arg); > /** > * tcp_splice_conn_epoll_events() - epoll events masks for given state > * @events: Connection event flags > - * @a: Event mask for socket with accepted connection, set on return > - * @b: Event mask for connection target socket, set on return > + * @a: Event for socket with accepted connection, set on return > + * @b: Event for connection target socket, set on return > */ > static void tcp_splice_conn_epoll_events(uint16_t events, > - uint32_t *a, uint32_t *b) > + struct epoll_event *a, > + struct epoll_event *b) > { > - *a = *b = 0; > + a->events = b->events = 0; > > if (events & SPLICE_ESTABLISHED) { > if (!(events & B_FIN_SENT)) > - *a = EPOLLIN | EPOLLRDHUP; > + a->events = EPOLLIN | EPOLLRDHUP; > if (!(events & A_FIN_SENT)) > - *b = EPOLLIN | EPOLLRDHUP; > + b->events = EPOLLIN | EPOLLRDHUP; > } else if (events & SPLICE_CONNECT) { > - *b = EPOLLOUT; > + b->events = EPOLLOUT; > } > > - *a |= (events & A_OUT_WAIT) ? EPOLLOUT : 0; > - *b |= (events & B_OUT_WAIT) ? EPOLLOUT : 0; > + a->events |= (events & A_OUT_WAIT) ? EPOLLOUT : 0; > + a->events |= (events & B_OUT_WAIT) ? EPOLLOUT : 0; This should be b->events |= ..., but it's fixed in 7/11 anyway. -- Stefano