Repository navigation
Conversation
EVFILT_READ and EVFILT_WRITE on a regular file threw. They now follow FreeBSD 11's vfs_kqfilter, filt_vfsread and filt_vfswrite: a read event reports the file size minus the descriptor's offset and fires when that is not zero or NOTE_FILE_POLL is set; a write event always fires with data 0. A waiting kevent is woken by the host watch EVFILT_VNODE uses, and the equeue wait no longer polls descriptors that are neither sockets nor pipes, which the host reports ready at once.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Rebase handoff — rebased onto current
Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, To pick it up: Head is |
|
The new |
What
keventthrew forEVFILT_READandEVFILT_WRITEon a regular file:Both now follow FreeBSD 11's
vfs_kqfilter,filt_vfsreadandfilt_vfswrite, from the same commit the kqueue debt entry already links. A read event reports the file size minus the descriptor's offset (negative past the end) and fires when that is not zero, or always withNOTE_FILE_POLL.NOTE_LOWATanddataare ignored, and adding the event again replaces itsfflags, askqueue_registerdoes for a filter withoutf_touch. A write event always fires withdata0. Size and offset come fromsceKernelFstatandsceKernelLseek, so files served fromapp0.zarwork as well.A waiting
keventis woken by the host watchEVFILT_VNODEalready uses, so a write from another descriptor or process wakes it. Files fromapp0.zarnever change and get no watch.GuestSockets::WaitAnyalso needed a change. It passed every interest that is not a socket toppoll, and the host reports a regular file (and the null device behind an archived file) ready at once, so akeventwaiting on a file at its end spun on the CPU. It now passes only pipes to the host, and on Windows the 1 ms pipe slicing is only turned on when a pipe is actually in the set.EV_CLEARon a regular file still throws, as it does on sockets and pipes, and so do directories (theirva_sizeis not modelled) and the other descriptor types. The debt entry also notes the one difference I know of: the event is re-evaluated at every scan, so after reading to the end a seek back is reported straight away, where FreeBSD waits for the next write, truncation or attribute change.Overlap: #7075 changes the same line of
WaitAny. I used itsinterest.write ? WriteMask : ReadMaskthere, so whichever lands second only rebases that line. #7049 changes the lines next to mine inModifyKnote; the two don't interact. #7092 (NOTE_LOWATon sockets) conflicts inModifyKnoteand in the kqueue debt sentence (git merge-treeof the two heads). They don't clash in behaviour: itsDescriptorLowWateronly applies to sockets, and a regular file ignores the mark asfilt_vfsreaddoes, so the resolution is to keep itsDescriptorLowWatercall in place of my!fileguard, and to keep both edits to the debt sentence. #6343 (descriptor 0) touches the same branch ofAddDescriptorKnote; with this PR a stdin redirected from a regular file takes the new path, which is what FreeBSD does too.Tested
Ubuntu 24.04, GCC 13.3.0, Release, on
mainca82d7d88.RegularFilecase inguest_kqueue:datain the middle and at the end of the file, negativedatapast the end,NOTE_FILE_POLLturned on and off by adding the event again,NOTE_LOWATignored, a blockingkeventwoken by a write through a second descriptor 50 ms later, a truncation,EV_CLEARthrowing, the write event, and the events going away on close. It aborts onmainwith the error above and passes with this change.WaitAnychange the test still passes, but takes about 80 ms of CPU instead of 10 ms (/usr/bin/time, 3 runs each) because the 50 ms wait spins.guest_equeue_events,guest_kqueue,guest_poll,guest_select,guest_select_wait, theguest_socket_*tests,guest_tcp,guest_udp,guest_sce_net, theguest_rudp_*tests andguest_net_ctl: 22/22 pass.python3 tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)