From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BRD6p1fy; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id 1EE3F5A0272 for ; Tue, 21 Jan 2025 09:40:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737448811; 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=qOy/KvhfLRuQtZZpn4ubYVK1298XNVpsU6J4I1/vh8M=; b=BRD6p1fyh93H6pGZQ7nVCiJxjQNZSul6crsQrAIPpehC50qZ8k5pdoLgO4MhyaB9RFP+68 uXhGfZmJy9dV3bWM+TmMxMq7h1i33EzH6+LgKgBnj/PUhnMEDGPYsb7kgCvYgy1r7NtPfv zMi05eN+Nl5S5N3yxcRRxABOGT8F9s0= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-205-l7Y3IvLpPC-w0Vfjc80y3g-1; Tue, 21 Jan 2025 03:40:09 -0500 X-MC-Unique: l7Y3IvLpPC-w0Vfjc80y3g-1 X-Mimecast-MFC-AGG-ID: l7Y3IvLpPC-w0Vfjc80y3g Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4361c040ba8so29109295e9.1 for ; Tue, 21 Jan 2025 00:40:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737448807; x=1738053607; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=qOy/KvhfLRuQtZZpn4ubYVK1298XNVpsU6J4I1/vh8M=; b=tGzE9hhhTZ/bOPUbPEiyrGetKFUmvl+nxlT6cnD2iWxWpNBMHvy7uv/0HASgiMRna6 20qSOWfh1ZJnwmWkpG0abUE2ylIgnRts1LJEks9vucTlyoZvyptsc47gjU/JuhhSPfQD DQp9NAEc2kovJpQMG6D7XdLc2ZtW1mQ0WYBVNhWM3FQ2ktSyETY72kiyrQSDRMUQnUxs 5CUon0rm16mtRuGsCFXX82Ngu/fOmlirILkwcLj5qe+6fnZoWHRqRe16Lstjee1SBNUd LhvNLKpp8iFVqkykgkViXzSaoSx7eBvTWxuy04BooW6TdJV/bTWUA18lXrcnFj92SLiZ H4nw== X-Gm-Message-State: AOJu0YwS5yTgPvpADtmMObCpI7lSvfamxhveddB2wvKjT2zfV3MqoeUO QqaBoz+Oao+p1D2H4LbqV0N3or0qByWyGS1fDojR+f+iV+75wYs9mxgUfXW0W/lIbfCsehys1Ag mnV/jMuVrRASPfeEUAi5vRNu7zdM96eZSb2kFRck3zQeuOQVKdAReFQqtvzBj X-Gm-Gg: ASbGncv5UnnfGxKok68QYxCM36k9CO1SO5QW8+JSR+kfQjBJKRKDBxkC7U0//bIL0JT jLDKe64pZQp3JSMb5fXFaB5/wYJxAwBFoj+UKGTqX8AtPL5KCNEoTnjBtiXYSbrEsYUD/VJBR7c 2B4UkKr4ULxEa5+40ikjfF8/6v0gNltACHCHQclL95oxUY03J91yBbcov/jrlRXJJQ8BbPht8Z0 9tr9Nfx7JT1Y2M5l3GUGNkHAjQkqdxUArWAl6EQ3TFwgCtWSdnfYgHvdqTFhOHSGkkMN1rrugze asz6plLhla7Oj/q7fw5pWeE= X-Received: by 2002:a05:600c:3b02:b0:434:a7f1:6545 with SMTP id 5b1f17b1804b1-43891441f27mr139645375e9.27.1737448807132; Tue, 21 Jan 2025 00:40:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEx40Y7/0zuEsGj2bNG0corFlIj8KBuJ8ZhV8+rtURfxn58+N3s3MW2/Uu4pc2S0MYCtTbI/g== X-Received: by 2002:a05:600c:3b02:b0:434:a7f1:6545 with SMTP id 5b1f17b1804b1-43891441f27mr139645145e9.27.1737448806682; Tue, 21 Jan 2025 00:40:06 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-437c749956fsm233463245e9.4.2025.01.21.00.40.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2025 00:40:05 -0800 (PST) Date: Tue, 21 Jan 2025 09:40:02 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2] tcp: Disable Nagle's algorithm (set TCP_NODELAY) on all sockets Message-ID: <20250121094002.7d73f1be@elisabeth> In-Reply-To: References: <20250120172816.2102833-1-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: EXOOhlmSdTMXxAIES7UrkxCKp4INJA8JwdEeBItkV3s_1737448808 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: I5YMBWN65UVCJ3ZWQT5J5KD2X3D25TOC X-Message-ID-Hash: I5YMBWN65UVCJ3ZWQT5J5KD2X3D25TOC 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, 21 Jan 2025 13:31:03 +1030 David Gibson wrote: > On Mon, Jan 20, 2025 at 06:28:16PM +0100, Stefano Brivio wrote: > > Following up on 725acd111ba3 ("tcp_splice: Set (again) TCP_NODELAY on > > both sides"), David argues that, in general, we don't know what kind > > of TCP traffic we're dealing with, on any side or path. > > > > TCP segments might have been delivered to our socket with a PSH flag, > > but we don't have a way to know about it. > > > > Similarly, the guest might send us segments with PSH or URG set, but > > we don't know if we should generally TCP_CORK sockets and uncork on > > those flags, because that would assume they're running a Linux kernel > > (and a particular version of it) matching the kernel that delivers > > outbound packets for us. > > > > Given that we can't make any assumption and everything might very well > > be interactive traffic, disable Nagle's algorithm on all non-spliced > > sockets as well. > > > > After all, John Nagle himself is nowadays recommending that delayed > > ACKs should never be enabled together with his algorithm, but we > > don't have a practical way to ensure that our environment is free from > > delayed ACKs (TCP_QUICKACK is not really usable for this purpose): > > > > https://news.ycombinator.com/item?id=34180239 > > > > Suggested-by: David Gibson > > Signed-off-by: Stefano Brivio > > --- > > v2: Set TCP_NODELAY on inbound socket after accept4(), not on the > > listening sockets, and change failure message to debug() > > instead of trace() > > Uh.. you've moved it to after accept() for incoming connections, but > it looks like you've accidentally removed the call for outgoing > connections (tcp_conn_new_sock()). Uh... no? It's here: > > tcp.c | 15 +++++++++++++++ > > 1 file changed, 15 insertions(+) > > > > diff --git a/tcp.c b/tcp.c > > index a012b81..4d6a6b3 100644 > > --- a/tcp.c > > +++ b/tcp.c > > @@ -756,6 +756,19 @@ static void tcp_sock_set_bufsize(const struct ctx *c, int s) > > trace("TCP: failed to set SO_SNDBUF to %i", v); > > } > > > > +/** > > + * tcp_sock_set_nodelay() - Set TCP_NODELAY option (disable Nagle's algorithm) > > + * @s: Socket, can be -1 to avoid check in the caller > > + */ > > +static void tcp_sock_set_nodelay(int s) > > +{ > > + if (s == -1) > > + return; > > + > > + if (setsockopt(s, SOL_TCP, TCP_NODELAY, &((int){ 1 }), sizeof(int))) > > + debug("TCP: failed to set TCP_NODELAY on socket %i", s); > > +} > > + > > /** > > * tcp_update_csum() - Calculate TCP checksum > > * @psum: Unfolded partial checksum of the IPv4 or IPv6 pseudo-header > > @@ -1285,6 +1298,7 @@ static int tcp_conn_new_sock(const struct ctx *c, sa_family_t af) ^^^^^^^^^^^^^^^^^ > > return -errno; > > > > tcp_sock_set_bufsize(c, s); > > + tcp_sock_set_nodelay(s); ^^^^^^^^^^^^^^^^^^^^^^^^ ...am I missing something? > > > > return s; > > } > > @@ -2058,6 +2072,7 @@ void tcp_listen_handler(const struct ctx *c, union epoll_ref ref, > > goto cancel; > > > > tcp_sock_set_bufsize(c, s); > > + tcp_sock_set_nodelay(s); > > > > /* FIXME: When listening port has a specific bound address, record that > > * as our address -- Stefano