feat(libkernel): support kevent timer reconfiguration #5361
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5361"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by AaravMehta-07 on 2026-10-13T17:58:06Z.
What
Implement reconfiguration of an existing
EVFILT_TIMERthroughkevent. Main currently throwskevent: changing an existing EVFILT_TIMER not implemented, including anEV_ADDthat changes an existing timer's period.This uses FreeBSD 11.4's
filt_timertouchandkqueue_registerbehavior as the reference. AnEV_ADDdiscards old undelivered expiry state and restarts with the new period/precision; changes withoutEV_ADDupdate onlyudata. Existing persistent flags are retained. Invalid replacement parameters disarm the timer and produce anEV_ERROR/EINVALevent rather than a registration error.Lookup, insert, update and delete selection are one queue-mutex transaction. This matters when a concurrent wait consumes a one-shot registration: separating
HasEventfromEditEventcan otherwise returnENOENTfor a valid re-add. The inline template avoids adding an out-of-line helper to the library's auto-exported symbols.The reference choice is explicit: FreeBSD 11.0 retained the old armed expiry, whereas 11.4 restarts it. This is a public-source contract implementation, not console-measured PS5 behavior. The debt entry records that distinction and retains the other unsupported cases. No ABI signature, export name or NID was changed, and no proprietary firmware was used. No title was tested or claimed unblocked.
The unchanged progress scanner reports 3214/3646 (88.15%) before and after:
keventremains partial because other cases still throw. No coverage-counter claim is made.Tested
Windows, supported WinLibs MinGW-w64 GCC 15.2.0 r7, Release with
BUILD_TESTING=ONand recursively initialized submodules:The eight Windows skips were
agc_driver_stencil_ref_export, the fivevideo_out_flip_{lifetime,reopen,controls,overlay,unopened}tests,guest_video_out_wqhd_detection_no_vulkan, andlong_paths. They are not counted as passes. Wider GPU tests ran withANYPS5_GPU=4060on NVIDIA RTX 4060 Laptop, driver 610.88. No test timeout was increased.Linux/WSL Ubuntu, GCC 15.2.0: the bundled-dependency full configuration succeeded; built the affected
guest_kqueue_teststarget and kernel/libc dependencies. Focusedguest_kqueuepassed 3/3 (2.28-2.29 s each). The full Linux build and full Linux suite were not run.The guest-export regression covers discarded materialized expiry/count state, changed deadline/precision and
udata, preserved periodic/one-shot flags, no-EV_ADDtouches, a waiting thread, invalid-update error delivery and recovery, fresh registration after one-shot deletion, and 2000 concurrent re-add/delivery iterations. Compile-time checks pin the existing x64 event/timespec layouts.The updated regression was compiled against the saved original unpatched runtime from
0214069and failed with the original timer-change exception (exit-1073740791).Kqueue.cppis unchanged between that upstream revision and the PR base. Five isolated Linux mutants compiled and failed the regression: stale trigger, stale count, replacement flags, missing waiter notification, and non-atomic lookup/update. Mutation copies and logs were kept outside the repository. This is not a sanitizer run; waiter scheduling is exercised with a start flag/delay, not a formal blocked-state proof.All PE export names, including 620 guest-style names, matched the original runtime. No new timer helper was exported. Research, implementation, tests and critical review were AI-assisted; the independent reviewer was an AI agent, not a human reviewer.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); remaining gaps are recorded in library technical debt.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T01:16:42Z.
Review: COMMENTED
Making the lookup, insert, update and delete one transaction under the queue mutex is a good catch. A separate
HasEvent/EditEventcheck really can race with a consumed one-shot timer.On the semantics: the description says FreeBSD 11.0 keeps the armed expiry on a re-
EV_ADDwhile 11.4 restarts it, and the PR picks 11.4. Which FreeBSD release the console kernel tracks isn't settled, and this is exactly the case where the two disagree. Under the repository's exact-or-throw rule, the disputed case (anEV_ADDthat changes the period of a timer that is still armed) would keep throwing until it's measured. The unambiguous cases, audata-only change and a re-add of a timer that has already fired or been disarmed, behave the same in both versions and can go in now.Measuring it is practical: #5230 measured scheduling behaviour from a homebrew payload on a PS5 (firmware 13.60). The same kind of payload could arm a 1 s timer, re-add it with 3 s after 0.5 s, and record when it first fires: 3.5 s from the start means 11.4 behaviour, and 1 s or 3 s means otherwise. That would settle it for this PR and for the debt entry.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:28:12Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed