Bug 287348 - [exp-run] retiring sendfile(2) SF_SYNC flag
Summary: [exp-run] retiring sendfile(2) SF_SYNC flag
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Gleb Smirnoff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-06-06 21:52 UTC by Gleb Smirnoff
Modified: 2025-12-04 16:52 UTC (History)
1 user (show)

See Also:
glebius: exp-run?


Attachments
SF_SYNC removal patch (4.57 KB, patch)
2025-06-06 21:52 UTC, Gleb Smirnoff
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gleb Smirnoff freebsd_committer freebsd_triage 2025-06-06 21:52:41 UTC
Created attachment 261048 [details]
SF_SYNC removal patch

I'd like to see if there is any software in ports that uses this flag.  Should be sufficient to just delete SF_SYNC from socket.h.  However, a full patch removing the feature is attached.
Comment 2 Gleb Smirnoff freebsd_committer freebsd_triage 2025-06-17 17:15:46 UTC
Thanks, Antoine!

The packetdrill is expected, it is our tool that test all things possible.

A note on sysutils/rocr. The port was added by jmd@ with a note in commit log "Hence, in the current absence of a working amdkfd on FreeBSD, these ports do not function yet".  The port was never improved after.  The Github repo the port fetches from is an outdated jmd@'s fork of ROCm/ROCR-Runtime. The SF_SYNC flag was added when jmd@ ported the code from Linux:

5c092e87 (J M Dieterich 2017-02-14 10:49:25 -0500  228) #ifdef __FreeBSD__
5c092e87 (J M Dieterich 2017-02-14 10:49:25 -0500  229)         int err = sendfile(in, d, size, 0, NULL, &written, SF_SYNC);
5c092e87 (J M Dieterich 2017-02-14 10:49:25 -0500  230) #else
^e9aac90 (James Edwards 2016-01-26 19:43:17 -0600  231)         written = sendfile(d, in, NULL, size);
5c092e87 (J M Dieterich 2017-02-14 10:49:25 -0500  232) #endif

This doesn't make any sense. There is no analog of SF_SYNC in Linux and never was. My guess flag was added without understanding its meaning.

Verdict: SF_SYNC has no use, as expected.
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-06-24 22:26:02 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d17cbe46983c08ba0567b0ffd71434abd35aa205

commit d17cbe46983c08ba0567b0ffd71434abd35aa205
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-06-24 21:26:10 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-06-24 22:24:04 +0000

    sendfile: retire SF_SYNC

    The flag was added in b75a1171d8ba4 for the sake of Varnish.  However, that
    idea didn't work.  Quoting email from Poul-Henning:

    "We had to give up sendfile(), the overhead of keeping track of everything
    between the network stack and VM system made ate any gain we saw. ... I
    dont think we ever shipped a version where sendfile was enabled by
    default."

    PR:     287348

 lib/libsys/sendfile.2    | 8 +-------
 sys/kern/kern_sendfile.c | 6 +++++-
 2 files changed, 6 insertions(+), 8 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2025-12-04 16:45:45 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=575efcfff22f5d75fc3ac6201f11e5eae46ec9ce

commit 575efcfff22f5d75fc3ac6201f11e5eae46ec9ce
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-12-04 16:37:10 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-12-04 16:44:21 +0000

    sendfile: remove SF_SYNC in FreeBSD 16.0

    See d17cbe46983c for details.

    PR:     287348

 sys/kern/kern_sendfile.c | 88 ------------------------------------------------
 sys/sys/socket.h         |  2 +-
 2 files changed, 1 insertion(+), 89 deletions(-)