From nobody Fri Oct 02 02:54:10 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hwtfC44XJz6v7Fh for ; Fri, 02 Oct 2026 02:54:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hwtfB5sShz3Hrd for ; Fri, 02 Oct 2026 02:54:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790909650; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KGkM0mN4KGvaaLwU8YHwozNf+o7FNawg+0DcsX3sGb4=; b=hORP8CpGaGYTuB0r6yqwAr+qA7BLoDtdYHaSDfaY1h158sFTamuLVlf3FgF2XHnogC8RX6 3Bp43zSu6Xczeo8cDW0XisrzAtjgQcmmSWDzDua+QFfgW7ZreHtGDOXHnsxRScA6A1/jP/ 3JskXVBHkbdf4DRA8oMh8AfxrC8HD5YJ8jQ5JEmv9sKQ19tJGolHWxgUAW7ZzxuvNQslg4 Sewcf6rIgYRn98z5/5xdA68w5YErT5M/G+oJ0IIbnbswKoQ1XyD63pMbjdZXVIplriURiH UjOw7sl0S/Z336UZTOS4mG68oZWHb+XLaKK9xgQ04vhTxatzx+ho20U87WVP3g== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1790909650; b=G2QrI1hcb6nqEKJQnHrQh86wqsWCJ3VHzjqXz8TqYWgguDvDGOAh0+35iyMXI8qFHLYr3s y4Ycugy8MBTQ9kCdnagc+fubtUjog9uB50Ho1S4JwNmM/bAf3obGdJqqc90CDoxB7RIu8H y15S9sj4xi8I0tSE1lyolmXAvhkvKEMDsR7EtTGCYX/BgfA/07SZW6QjEkeTu+ftB5c0G5 KQbpYpdHoPt2mikmjIiBfrLSmniaNyJiQZEqCJ0xBQq1gU8HmFuSsELCkqP14wyXBPao2f wbIecOJL3CY7tQ/VVoa7erJgXByGGdhr0c/sloMpdKOIE6s22acKOGZmG9Hf2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790909650; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KGkM0mN4KGvaaLwU8YHwozNf+o7FNawg+0DcsX3sGb4=; b=scL6qYbCt74hpWaaLtJDdwl1qn7aySTs8o1XRQ9QFqa6YLicCdlYlB3MRByLrpqmRtHbPl MQz3NmCIJNLF3ELJqw3L1HZV0Lj2r781CS3Z6nIgdPbAuTNxipKisVzDpD0YfpaexRxm3q i1nNS0suxChF8k+QJPEU0zM9OGFWFS4JGiFLQpOxS+LbL6hUxALch6LP7Uvg3WQf2SHP6g /D6RZIGEztHpzYUlM0i/a9OAUev/sBvtmzHAYk7jCQqiXYFrNreoz3bk1DeG6sNcCpNj8o 9ytYUDo2PaZiOApGowg9Xk9PCQLGLBQvDNEywRFOS6sJ6BySRuzTZCqXONnzJQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hwtfB3FT8z10qK for ; Fri, 02 Oct 2026 02:54:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 372ac by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 02 Oct 2026 02:54:10 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 6948f4d5e2b2 - main - sendfile: keep the lowat hack more conservative List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6948f4d5e2b29100b986a96175ef9efb1ab91616 Auto-Submitted: auto-generated Date: Fri, 02 Oct 2026 02:54:10 +0000 Message-Id: <6abf1cd2.372ac.62ed0269@gitrepo.freebsd.org> The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=6948f4d5e2b29100b986a96175ef9efb1ab91616 commit 6948f4d5e2b29100b986a96175ef9efb1ab91616 Author: Gleb Smirnoff AuthorDate: 2026-10-02 02:53:40 +0000 Commit: Gleb Smirnoff CommitDate: 2026-10-02 02:53:40 +0000 sendfile: keep the lowat hack more conservative First, record the original lowat value and later in the wait/EAGAIN loop look at the original value, rather than on the value that we just faked. This eliminates some blank syscalls, where socket was reported as writable and immediate write instantly fails. In my testing the ratio of such syscalls was really small, under 2%, however in a different scenario this negative effect can be more profound. Second, cap the lowat growth to 1/2 of original socket buffer size, rather than to current size. The problem was there before, but it became more profound after 587c6c121504. Note: we are considering to evaluate if the lowat hack is needed at all. Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D60106 --- sys/kern/kern_sendfile.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c index b4ad28b27b36..a14b88b2169e 100644 --- a/sys/kern/kern_sendfile.c +++ b/sys/kern/kern_sendfile.c @@ -637,6 +637,7 @@ sendfile_getsock(struct thread *td, int s, struct file **sock_fp, int sendfile_wait_generic(struct socket *so, off_t need, int *space) { + u_int lowat, newlowat; int error; MPASS(need > 0); @@ -657,9 +658,11 @@ sendfile_wait_generic(struct socket *so, off_t need, int *space) */ error = 0; SOCK_SENDBUF_LOCK(so); + lowat = so->so_snd.sb_lowat; if (so->so_snd.sb_flags & SB_AUTOLOWAT) { - if (so->so_snd.sb_lowat < so->so_snd.sb_hiwat / 2) - so->so_snd.sb_lowat = so->so_snd.sb_hiwat / 2; + newlowat = min(V_tcp_sendspace, so->so_snd.sb_hiwat) / 2; + if (so->so_snd.sb_lowat < newlowat) + so->so_snd.sb_lowat = newlowat; if (so->so_snd.sb_lowat < PAGE_SIZE && so->so_snd.sb_hiwat >= PAGE_SIZE) so->so_snd.sb_lowat = PAGE_SIZE; @@ -679,7 +682,7 @@ retry_space: } *space = sbspace(&so->so_snd); - if (*space < need && (*space <= 0 || *space < so->so_snd.sb_lowat)) { + if (*space < need && (*space <= 0 || *space < lowat)) { if (so->so_state & SS_NBIO) { error = EAGAIN; goto done;