Repository navigation
fix(libkernel): retire an EV_ONESHOT note through its delete callback and follow Windows $Deleted paths - #7049
Conversation
|
Review of b64fd73: the EV_ONESHOT detach is correct (it matches FreeBSD
Minor:
When this lands, #6510 should be closed as superseded, since this carries its parts. |
|
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.
|
b64fd73 to
b3e3e81
Compare
|
Addressed the review in |
|
Re-anchored onto current |
b3e3e81 to
53b717d
Compare
jotitadev
left a comment
There was a problem hiding this comment.
Static review plus a small arm64 repro on macOS (Apple M2 Max, macOS 27.2, Apple clang 21), head 53b717de6. Two problems in the new tests in core/libs/tests/GuestKqueue.cpp.
1. RecycleBinDeleteWatchedFile never runs on any platform. In main() its call is nested inside the non-Windows block:
#ifndef _WIN32 // line 963
RenameAndDeleteWatchedFile();
VnodeOneshotWatchStops();
PeriodicTimerFiresTwice();
#ifdef _WIN32 // line 967: always false here
RecycleBinDeleteWatchedFile();
#endif
#endifThe function itself is defined only under #ifdef _WIN32 (line 760), so the \$Extend\$Deleted\ change in FileEvent.cpp (IsDeleted/SnapshotHints) has no test that actually runs, even though the PR body lists it under Tested. Moving the #ifdef _WIN32 ... #endif block after the closing #endif fixes it.
2. The leak check in VnodeOneshotWatchStops passes vacuously on macOS. InotifyWatchCount (lines 705-716) iterates /proc/self/fd under #ifndef _WIN32. macOS has no /proc, so directory_iterator sets the error code and the count is always 0. That makes Require(InotifyWatchCount() == watchesBefore) (line 743) true regardless of the fix. The macOS host watch is a ::kqueue() per note (FileEvent.cpp:446), closed when StopVnode stops the watch thread, so the same leak is possible there.
Repro: the PR's InotifyWatchCount copied as is, plus 3 deliberately leaked kqueue() descriptors:
InotifyWatchCount before=0 after=0 (err: No such file or directory) -> check passes: yes (vacuous)
kqueue fds via proc_pidinfo before=0 after=3 -> leak detected: yes
Suggestion: gate the current helper on __linux__. On __APPLE__, count PROX_FDTYPE_KQUEUE entries from proc_pidinfo(getpid(), PROC_PIDLISTFDS, ...) (<libproc.h>), which detected the leaked descriptors above. Alternatively, skip the leak assertion where the count is not meaningful, so the test does not claim coverage it does not have.
(The branch also currently conflicts with main.)
AI-assisted: yes (Claude Code)
adriadam10
left a comment
There was a problem hiding this comment.
The production change looks right: the deleteEventFunc call mirrors the existing one in CollectOncePerWait, and the exact \$Extend\$Deleted\ match addresses the earlier review. The branch needs the following before it can merge (it also conflicts with main in core/libs/tests/GuestKqueue.cpp and docs/dev/debt/libkernel.md):
core/libs/tests/GuestKqueue.cpp(main(), ~line 967):RecycleBinDeleteWatchedFile()is called inside#ifndef _WIN32, so its#ifdef _WIN32is never true and the$Deletedchange has no test that runs. Move the#ifdef _WIN32block after the closing#endif(as reported by @jotitadev).InotifyWatchCount(~line 706) reads/proc/self/fd; on macOS that directory does not exist, the count is always 0 and the leak assertion passes without checking anything. Gate it on__linux__and skip the assertion elsewhere (or count kqueue descriptors viaproc_pidinfo).- The diff also adds
DisableAndEnable,Dispatch,ForceOneshotandStressTest(~165 lines) that the description does not mention and that belong to the superseded #6510 feature already covered byDisableAndDispatchonmain. Drop them, or move them to their own PR with their own justification.StressTestdepends on 4 threads and 1–2 ms sleeps and asserts strict arrival order, which is a flake risk on the CI runners. - Cosmetics: the over-indented
DisableAndEnable();call and the double blank line beforeStressTest.
Please rebase on current main (keep main's LowWaterMarks()/DisableAndDispatch() calls) and re-run guest_kqueue. Happy to re-review once these are addressed.
53b717d to
895ca7c
Compare
|
Rebased onto current
Tested: Linux (CachyOS, kernel 7.2.10, GCC 16.2.1, Ninja, Release, |
895ca7c to
072d780
Compare
072d780 to
3ecd18f
Compare
|
@adriadam10 — re-requesting your review, as you offered: Addressed per your review; head is now
|
|
@adriadam10 — one more commit ( The disable/enable cycle works on this head. The next-wait abort from the earlier round no longer reproduces: it was observed on the pre-rebase head, before
One guard change came out of writing it: a timer modify that sets |
de497d3 to
faece77
Compare
|
@adriadam10 — head Fresh
|
… and follow Windows $Deleted paths Carries the additive pieces of boykopovar#6510 onto main after its feature was superseded by boykopovar#5847: the deleteEventFunc invocation when an EV_ONESHOT note retires in CollectTriggered, the Windows $Deleted path detection in FileEvent (IsDeleted transitions), the relaxed timer-modify and SetVnodeNotes guards, and the compatible kevent tests.
…perseded kevent tests - RecycleBinDeleteWatchedFile now runs on Windows: its call moves out of the #ifndef _WIN32 block so the $Extend$Deleted$ path is exercised - InotifyWatchCount and the two leak assertions gate on __linux__ (macOS has no /proc; the count was always 0 and the assertion vacuous) - DisableAndEnable, Dispatch, ForceOneshot and StressTest drop with their main() calls: they belong to the superseded boykopovar#6510 feature, and StressTest asserts strict arrival order across 4 threads with 1-2 ms sleeps (CI flake risk)
…d timer's enable re-arm - a timer change with EV_ADD unset and data 0 keeps the period; one that set fflags was silently ignored, where FreeBSD 11's kqueue_register copies it onto the note: it now throws with the other re-adds, waiting for the measured rules - EV_ENABLE on a disabled timer reports the expiries missed while disabled in one step and keeps the note's phase, as FreeBSD 11's filt_timerexpire counts a disabled note and keeps its p_nexttime; TimerDisableEnableRearm pins it (5 serial runs and 3 rounds of 8 parallel copies pass) - the next-wait abort from the review round was observed before main's 5cbc460 wait refactor and does not reproduce
…he timer debt line off the section end Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
843f9fc to
387f069
Compare
|
@adriadam10 — everything on our side is done: your approval is anchored to the current head |
|
Windows run of Build: head
So on Windows the new test passes, and fails without the One thing I noticed:
So the three tests run on Windows as they are, if you want them to. |
|
Checked the |
Culprit #7049; failing run 40193493248 (linux guest_kqueue aborted after 6 s inside VnodeOneshotWatchStops). Watch threads of the previous test close their inotify fds after Stop(), so the baseline count could drop below the final one and the exact equality never held. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
What
Carries the additive pieces of #6510 (as offered there after its feature was superseded by #5847), revised per the review of
b64fd7377:deleteEventFuncinvocation when anEV_ONESHOTnote retires inCollectTriggered\$Extend$Deleted`exactly instead of any path containing$Deleted`kqueue_registersetskn_sfflagsunconditionally for filters withoutf_touch, matchingmain's unconditionalSetVnodeNotesdocs/dev/debt/libkernel.mdTested
Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV): full suite passes except the knownmainregression (agc_driver_tessellationsegfault, #4727); conventions pass. New tests:VnodeOneshotWatchStops: a vnodeEV_ONESHOTfires once, the note is gone, and on Linux the retired watch's inotify descriptor count returns to its pre-watch level (with a bounded wait for the watch thread to exit) — the leak the review describedPeriodicTimerFiresTwice: a plain periodic timer fires twice (uncovered onmainbefore)TimerDisableEnableRearm: a disabled periodic timer'sEV_ENABLEreports the expiries missed while disabled in one step and keeps the note's phase, and anEV_ADD | EV_ENABLEre-add still throwsRecycleBinDeleteWatchedFile(Windows-gated): a watched file renamed under\$Extend$Deleted`reportsNOTE_DELETE`The requested timer test is in the branch now (
TimerDisableEnableRearm):EV_DISABLEfollowed byEV_ENABLEwithdata == 0on a periodic timer reports the expiries missed while disabled in one step and keeps the note's phase, as FreeBSD 11'sfilt_timerexpirecounts a disabled note and keeps itsp_nexttime. The next-wait abort described in the earlier round no longer reproduces: it was observed on the pre-rebase head, beforemain's equeue wait refactor (5cbc46029b). One guard change came out of writing it: a timer modify that setsfflagswas silently ignored, wherekqueue_registercopies it onto the note — it now refuses with the other re-adds, waiting for the measured rules.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)main)