feat(libkernel): implement EV_DISABLE, EV_DISPATCH and EV_FORCEONESHOT in kevent #6510

Closed
Nawasfadili wants to merge 1 commit from upstream-pr/6510 into main
Nawasfadili commented 2026-10-15 18:07:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Nawasfadili on 2026-10-15T18:07:53Z.


What

Implement EV_DISABLE, EV_DISPATCH, and EV_FORCEONESHOT flags in kevent for libkernel.

  • Support EV_DISABLE and EV_ENABLE to temporarily disable knotes without unregistering them.
  • Support EV_DISPATCH to automatically disable knote upon delivery.
  • Support EV_FORCEONESHOT to delete knote immediately after delivery, including zero-interval timers.
  • Handle Windows $Deleted path in FileEvent.cpp.
  • Update technical debt list in docs/dev/debt/libkernel.md.

Tested

Windows 11 x64, guest_kqueue tests (passed 5/5 repeats with 0 errors). Multi-threaded worker stress test for EV_DISPATCH.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4877755538 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6510). Originally posted by [Nawasfadili](https://github.com/Nawasfadili) on 2026-10-15T18:07:53Z. --- ### What Implement EV_DISABLE, EV_DISPATCH, and EV_FORCEONESHOT flags in kevent for libkernel. - Support EV_DISABLE and EV_ENABLE to temporarily disable knotes without unregistering them. - Support EV_DISPATCH to automatically disable knote upon delivery. - Support EV_FORCEONESHOT to delete knote immediately after delivery, including zero-interval timers. - Handle Windows $Deleted path in FileEvent.cpp. - Update technical debt list in docs/dev/debt/libkernel.md. ### Tested Windows 11 x64, guest_kqueue tests (passed 5/5 repeats with 0 errors). Multi-threaded worker stress test for EV_DISPATCH. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-15 18:27:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T18:27:16Z.


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.

Pull request Shared files not compared
PR 4630 docs/dev/debt/libkernel.md
PR 5021 core/libs/prx/libkernel/Equeue/src/FileEvent.cpp
docs/dev/debt/libkernel.md
PR 6044 core/libs/tests/GuestKqueue.cpp
PR 6149 docs/dev/debt/libkernel.md
PR 6446 docs/dev/debt/libkernel.md
PR 6469 docs/dev/debt/libkernel.md
PR 6519 docs/dev/debt/libkernel.md
PR 6534 docs/dev/debt/libkernel.md
PR 6542 docs/dev/debt/libkernel.md
PR 6586 docs/dev/debt/libkernel.md
PR 6658 docs/dev/debt/libkernel.md
PR 6663 docs/dev/debt/libkernel.md
PR 6825 docs/dev/debt/libkernel.md
PR 6826 docs/dev/debt/libkernel.md
PR 6830 docs/dev/debt/libkernel.md
PR 6833 docs/dev/debt/libkernel.md
PR 6836 docs/dev/debt/libkernel.md
PR 6879 core/libs/prx/libkernel/Equeue/src/FileEvent.cpp
PR 6893 docs/dev/debt/libkernel.md
PR 6908 docs/dev/debt/libkernel.md
PR 6915 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 6977 docs/dev/debt/libkernel.md
PR 7039 docs/dev/debt/libkernel.md
PR 7049 core/libs/prx/libkernel/Equeue/Equeue.cpp
core/libs/prx/libkernel/Equeue/src/FileEvent.cpp
core/libs/prx/libkernel/Equeue/src/Kqueue.cpp
core/libs/tests/GuestKqueue.cpp
docs/dev/debt/libkernel.md
PR 7070 docs/dev/debt/libkernel.md
PR 7075 core/libs/prx/libkernel/Equeue/src/Kqueue.cpp
core/libs/tests/GuestKqueue.cpp
docs/dev/debt/libkernel.md
PR 7088 core/libs/prx/libkernel/Equeue/Equeue.hpp
core/libs/prx/libkernel/Equeue/src/FileEvent.cpp
core/libs/prx/libkernel/Equeue/src/Kqueue.cpp
core/libs/tests/GuestKqueue.cpp
docs/dev/debt/libkernel.md
PR 7090 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 core/libs/prx/libkernel/Equeue/Equeue.hpp
core/libs/prx/libkernel/Equeue/src/FileEvent.cpp
core/libs/prx/libkernel/Equeue/src/Kqueue.cpp
core/libs/tests/GuestKqueue.cpp
docs/dev/debt/libkernel.md
PR 7129 core/libs/prx/libkernel/Equeue/Equeue.cpp
core/libs/prx/libkernel/Equeue/Equeue.hpp
core/libs/prx/libkernel/Equeue/src/Kqueue.cpp
core/libs/tests/GuestKqueue.cpp
docs/dev/debt/libkernel.md
PR 7135 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7192 docs/dev/debt/libkernel.md
PR 7299 docs/dev/debt/libkernel.md
PR 7332 docs/dev/debt/libkernel.md
PR 7403 docs/dev/debt/libkernel.md
PR 7437 docs/dev/debt/libkernel.md
PR 7447 docs/dev/debt/libkernel.md
PR 7464 docs/dev/debt/libkernel.md
PR 7492 core/libs/prx/libkernel/Equeue/Equeue.cpp
core/libs/tests/GuestKqueue.cpp
PR 7509 core/libs/prx/libkernel/Equeue/Equeue.cpp
core/libs/prx/libkernel/Equeue/Equeue.hpp
docs/dev/debt/libkernel.md
PR 7511 docs/dev/debt/libkernel.md
PR 7530 docs/dev/debt/libkernel.md
PR 7532 docs/dev/debt/libkernel.md
PR 7539 docs/dev/debt/libkernel.md
PR 7541 docs/dev/debt/libkernel.md
PR 7542 docs/dev/debt/libkernel.md
PR 7543 docs/dev/debt/libkernel.md
PR 7551 docs/dev/debt/libkernel.md
PR 7554 docs/dev/debt/libkernel.md
PR 7556 docs/dev/debt/libkernel.md
PR 7565 docs/dev/debt/libkernel.md
PR 7605 docs/dev/debt/libkernel.md
PR 7611 docs/dev/debt/libkernel.md
PR 7622 core/libs/prx/libkernel/Equeue/src/FileEvent.cpp
PR 7653 core/libs/prx/libkernel/Equeue/Equeue.cpp
core/libs/prx/libkernel/Equeue/src/Kqueue.cpp
core/libs/tests/GuestKqueue.cpp
docs/dev/debt/libkernel.md
PR 7654 docs/dev/debt/libkernel.md
PR 7670 core/libs/tests/GuestKqueue.cpp
PR 7675 docs/dev/debt/libkernel.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6199323870 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6510#issuecomment-6199323870). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T18:27:16Z. --- <!-- pr-overlap --> 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. | Pull request | Shared files not compared | |---|---| | [PR 4630](https://www.github.com/boykopovar/AnyPS5/pull/4630) | `docs/dev/debt/libkernel.md` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/Equeue/src/FileEvent.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestKqueue.cpp` | | [PR 6149](https://www.github.com/boykopovar/AnyPS5/pull/6149) | `docs/dev/debt/libkernel.md` | | [PR 6446](https://www.github.com/boykopovar/AnyPS5/pull/6446) | `docs/dev/debt/libkernel.md` | | [PR 6469](https://www.github.com/boykopovar/AnyPS5/pull/6469) | `docs/dev/debt/libkernel.md` | | [PR 6519](https://www.github.com/boykopovar/AnyPS5/pull/6519) | `docs/dev/debt/libkernel.md` | | [PR 6534](https://www.github.com/boykopovar/AnyPS5/pull/6534) | `docs/dev/debt/libkernel.md` | | [PR 6542](https://www.github.com/boykopovar/AnyPS5/pull/6542) | `docs/dev/debt/libkernel.md` | | [PR 6586](https://www.github.com/boykopovar/AnyPS5/pull/6586) | `docs/dev/debt/libkernel.md` | | [PR 6658](https://www.github.com/boykopovar/AnyPS5/pull/6658) | `docs/dev/debt/libkernel.md` | | [PR 6663](https://www.github.com/boykopovar/AnyPS5/pull/6663) | `docs/dev/debt/libkernel.md` | | [PR 6825](https://www.github.com/boykopovar/AnyPS5/pull/6825) | `docs/dev/debt/libkernel.md` | | [PR 6826](https://www.github.com/boykopovar/AnyPS5/pull/6826) | `docs/dev/debt/libkernel.md` | | [PR 6830](https://www.github.com/boykopovar/AnyPS5/pull/6830) | `docs/dev/debt/libkernel.md` | | [PR 6833](https://www.github.com/boykopovar/AnyPS5/pull/6833) | `docs/dev/debt/libkernel.md` | | [PR 6836](https://www.github.com/boykopovar/AnyPS5/pull/6836) | `docs/dev/debt/libkernel.md` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/libs/prx/libkernel/Equeue/src/FileEvent.cpp` | | [PR 6893](https://www.github.com/boykopovar/AnyPS5/pull/6893) | `docs/dev/debt/libkernel.md` | | [PR 6908](https://www.github.com/boykopovar/AnyPS5/pull/6908) | `docs/dev/debt/libkernel.md` | | [PR 6915](https://www.github.com/boykopovar/AnyPS5/pull/6915) | `docs/dev/debt/libkernel.md` | | [PR 6936](https://www.github.com/boykopovar/AnyPS5/pull/6936) | `docs/dev/debt/libkernel.md` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `docs/dev/debt/libkernel.md` | | [PR 7039](https://www.github.com/boykopovar/AnyPS5/pull/7039) | `docs/dev/debt/libkernel.md` | | [PR 7049](https://www.github.com/boykopovar/AnyPS5/pull/7049) | `core/libs/prx/libkernel/Equeue/Equeue.cpp`<br>`core/libs/prx/libkernel/Equeue/src/FileEvent.cpp`<br>`core/libs/prx/libkernel/Equeue/src/Kqueue.cpp`<br>`core/libs/tests/GuestKqueue.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7070](https://www.github.com/boykopovar/AnyPS5/pull/7070) | `docs/dev/debt/libkernel.md` | | [PR 7075](https://www.github.com/boykopovar/AnyPS5/pull/7075) | `core/libs/prx/libkernel/Equeue/src/Kqueue.cpp`<br>`core/libs/tests/GuestKqueue.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7088](https://www.github.com/boykopovar/AnyPS5/pull/7088) | `core/libs/prx/libkernel/Equeue/Equeue.hpp`<br>`core/libs/prx/libkernel/Equeue/src/FileEvent.cpp`<br>`core/libs/prx/libkernel/Equeue/src/Kqueue.cpp`<br>`core/libs/tests/GuestKqueue.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7090](https://www.github.com/boykopovar/AnyPS5/pull/7090) | `docs/dev/debt/libkernel.md` | | [PR 7105](https://www.github.com/boykopovar/AnyPS5/pull/7105) | `docs/dev/debt/libkernel.md` | | [PR 7121](https://www.github.com/boykopovar/AnyPS5/pull/7121) | `core/libs/prx/libkernel/Equeue/Equeue.hpp`<br>`core/libs/prx/libkernel/Equeue/src/FileEvent.cpp`<br>`core/libs/prx/libkernel/Equeue/src/Kqueue.cpp`<br>`core/libs/tests/GuestKqueue.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7129](https://www.github.com/boykopovar/AnyPS5/pull/7129) | `core/libs/prx/libkernel/Equeue/Equeue.cpp`<br>`core/libs/prx/libkernel/Equeue/Equeue.hpp`<br>`core/libs/prx/libkernel/Equeue/src/Kqueue.cpp`<br>`core/libs/tests/GuestKqueue.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7135](https://www.github.com/boykopovar/AnyPS5/pull/7135) | `docs/dev/debt/libkernel.md` | | [PR 7149](https://www.github.com/boykopovar/AnyPS5/pull/7149) | `docs/dev/debt/libkernel.md` | | [PR 7192](https://www.github.com/boykopovar/AnyPS5/pull/7192) | `docs/dev/debt/libkernel.md` | | [PR 7299](https://www.github.com/boykopovar/AnyPS5/pull/7299) | `docs/dev/debt/libkernel.md` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `docs/dev/debt/libkernel.md` | | [PR 7403](https://www.github.com/boykopovar/AnyPS5/pull/7403) | `docs/dev/debt/libkernel.md` | | [PR 7437](https://www.github.com/boykopovar/AnyPS5/pull/7437) | `docs/dev/debt/libkernel.md` | | [PR 7447](https://www.github.com/boykopovar/AnyPS5/pull/7447) | `docs/dev/debt/libkernel.md` | | [PR 7464](https://www.github.com/boykopovar/AnyPS5/pull/7464) | `docs/dev/debt/libkernel.md` | | [PR 7492](https://www.github.com/boykopovar/AnyPS5/pull/7492) | `core/libs/prx/libkernel/Equeue/Equeue.cpp`<br>`core/libs/tests/GuestKqueue.cpp` | | [PR 7509](https://www.github.com/boykopovar/AnyPS5/pull/7509) | `core/libs/prx/libkernel/Equeue/Equeue.cpp`<br>`core/libs/prx/libkernel/Equeue/Equeue.hpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7511](https://www.github.com/boykopovar/AnyPS5/pull/7511) | `docs/dev/debt/libkernel.md` | | [PR 7530](https://www.github.com/boykopovar/AnyPS5/pull/7530) | `docs/dev/debt/libkernel.md` | | [PR 7532](https://www.github.com/boykopovar/AnyPS5/pull/7532) | `docs/dev/debt/libkernel.md` | | [PR 7539](https://www.github.com/boykopovar/AnyPS5/pull/7539) | `docs/dev/debt/libkernel.md` | | [PR 7541](https://www.github.com/boykopovar/AnyPS5/pull/7541) | `docs/dev/debt/libkernel.md` | | [PR 7542](https://www.github.com/boykopovar/AnyPS5/pull/7542) | `docs/dev/debt/libkernel.md` | | [PR 7543](https://www.github.com/boykopovar/AnyPS5/pull/7543) | `docs/dev/debt/libkernel.md` | | [PR 7551](https://www.github.com/boykopovar/AnyPS5/pull/7551) | `docs/dev/debt/libkernel.md` | | [PR 7554](https://www.github.com/boykopovar/AnyPS5/pull/7554) | `docs/dev/debt/libkernel.md` | | [PR 7556](https://www.github.com/boykopovar/AnyPS5/pull/7556) | `docs/dev/debt/libkernel.md` | | [PR 7565](https://www.github.com/boykopovar/AnyPS5/pull/7565) | `docs/dev/debt/libkernel.md` | | [PR 7605](https://www.github.com/boykopovar/AnyPS5/pull/7605) | `docs/dev/debt/libkernel.md` | | [PR 7611](https://www.github.com/boykopovar/AnyPS5/pull/7611) | `docs/dev/debt/libkernel.md` | | [PR 7622](https://www.github.com/boykopovar/AnyPS5/pull/7622) | `core/libs/prx/libkernel/Equeue/src/FileEvent.cpp` | | [PR 7653](https://www.github.com/boykopovar/AnyPS5/pull/7653) | `core/libs/prx/libkernel/Equeue/Equeue.cpp`<br>`core/libs/prx/libkernel/Equeue/src/Kqueue.cpp`<br>`core/libs/tests/GuestKqueue.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7654](https://www.github.com/boykopovar/AnyPS5/pull/7654) | `docs/dev/debt/libkernel.md` | | [PR 7670](https://www.github.com/boykopovar/AnyPS5/pull/7670) | `core/libs/tests/GuestKqueue.cpp` | | [PR 7675](https://www.github.com/boykopovar/AnyPS5/pull/7675) | `docs/dev/debt/libkernel.md` |
jotitadev commented 2026-10-15 19:04:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T19:04:53Z.

Review: COMMENTED


Linux run, plus three places where the new flags diverge from the FreeBSD 11 kern_event.c that the debt entry cites.

Setup: Ubuntu 26.04, i7-8700, GCC 15.2, Release, full build with BUILD_TESTING=ON. Head 709c63698 merged onto main 44df21632.

Results

  • guest_kqueue passes, and passes 5/5 with --repeat until-fail:5, StressTest included.
  • Non-GPU suite (ctest -E "^agc"): 668/670, the same as plain main. The two failures are file_writer_binary and file_writer_text, which also fail on main on this host.
  • Test only, without the three Equeue source files: aborts with kevent: EV_DISABLE not implemented. So the test does cover the new paths.

Divergences from FreeBSD 11 (commit 34bd347, the one the debt entry links)

  1. EV_FORCEONESHOT together with EV_ADD. kqueue_register drops the flag when it creates the knote (kn_kevent.flags &= ~(EV_ADD | EV_DELETE | EV_ENABLE | EV_DISABLE | EV_FORCEONESHOT)) and jumps to done_ev_add, so the new knote is not one-shot. On FreeBSD the event keeps firing and a later EV_DELETE returns 0. With this PR the knote is deleted after the first delivery, the returned flags is 0x100, and EV_DELETE gets ENOENT. ForceOneshot and EdgeCaseFlags assert the PR's version. Removing EV_DISABLE | EV_FORCEONESHOT from KNOTE_CLEARED_FLAGS is what lets 0x100 reach the caller; main matched FreeBSD there.
  2. EV_FORCEONESHOT on an existing knote. FreeBSD runs kn->kn_flags |= EV_ONESHOT; KNOTE_ACTIVATE(kn, 1);. The event is delivered on the next scan even if its condition never triggered, comes back with EV_ONESHOT, and the knote is then dropped. With this PR nothing is delivered until a trigger arrives.
  3. EVFILT_USER data. filt_usertouch(EVENT_REGISTER) sets kn_sdata = kev->data on every touch, not only with NOTE_TRIGGER. Main follows that; this PR moves the assignment inside the NOTE_TRIGGER branch. The fourth step of EdgeCaseFlags depends on the PR's behaviour.

Smaller differences:

  • A zero-period timer with EV_ADD | EV_FORCEONESHOT becomes one-shot here. On FreeBSD, filt_timerattach only sees EV_ONESHOT, so the period becomes 1.
  • EV_ENABLE | EV_DISABLE in the same change returns EINVAL on FreeBSD (start of kqueue_register). Here the knote is disabled.

Probe on the same build. Each scenario was appended to GuestKqueue.cpp, using its own helpers:

Scenario main 44df21632 this PR FreeBSD 11 (from source)
user knote: EV_ADD, NOTE_TRIGGER data 100, then touch with data 7, poll data 7 data 100 data 7
EV_ADD | EV_FORCEONESHOT, trigger, poll, poll, EV_DELETE throws 1 event flags=0x100, then 0, delete ENOENT flag dropped; 1 event flags=0, then 1 again (EV_CLEAR is not set), delete 0
EV_ADD (no trigger), then EV_FORCEONESHOT, poll throws 0 events 1 event flags=EV_ONESHOT, knote dropped

The FreeBSD column comes from reading the source; I did not run FreeBSD. If the console is meant to follow FreeBSD here, the knote probably needs a separate disabled state and the flags masked as in kqueue_register. If not, it would help to record these differences in the debt entry: as written, it says kqueue_register is followed.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5538490976 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6510#pullrequestreview-5538490976). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T19:04:53Z. **Review:** COMMENTED --- Linux run, plus three places where the new flags diverge from the FreeBSD 11 `kern_event.c` that the debt entry cites. **Setup:** Ubuntu 26.04, i7-8700, GCC 15.2, Release, full build with `BUILD_TESTING=ON`. Head `709c63698` merged onto main `44df21632`. **Results** - `guest_kqueue` passes, and passes 5/5 with `--repeat until-fail:5`, StressTest included. - Non-GPU suite (`ctest -E "^agc"`): 668/670, the same as plain main. The two failures are `file_writer_binary` and `file_writer_text`, which also fail on main on this host. - Test only, without the three `Equeue` source files: aborts with `kevent: EV_DISABLE not implemented`. So the test does cover the new paths. **Divergences from FreeBSD 11** (commit `34bd347`, the one the debt entry links) 1. **`EV_FORCEONESHOT` together with `EV_ADD`.** `kqueue_register` drops the flag when it creates the knote (`kn_kevent.flags &= ~(EV_ADD | EV_DELETE | EV_ENABLE | EV_DISABLE | EV_FORCEONESHOT)`) and jumps to `done_ev_add`, so the new knote is not one-shot. On FreeBSD the event keeps firing and a later `EV_DELETE` returns 0. With this PR the knote is deleted after the first delivery, the returned `flags` is `0x100`, and `EV_DELETE` gets `ENOENT`. `ForceOneshot` and `EdgeCaseFlags` assert the PR's version. Removing `EV_DISABLE | EV_FORCEONESHOT` from `KNOTE_CLEARED_FLAGS` is what lets `0x100` reach the caller; main matched FreeBSD there. 2. **`EV_FORCEONESHOT` on an existing knote.** FreeBSD runs `kn->kn_flags |= EV_ONESHOT; KNOTE_ACTIVATE(kn, 1);`. The event is delivered on the next scan even if its condition never triggered, comes back with `EV_ONESHOT`, and the knote is then dropped. With this PR nothing is delivered until a trigger arrives. 3. **`EVFILT_USER` data.** `filt_usertouch(EVENT_REGISTER)` sets `kn_sdata = kev->data` on every touch, not only with `NOTE_TRIGGER`. Main follows that; this PR moves the assignment inside the `NOTE_TRIGGER` branch. The fourth step of `EdgeCaseFlags` depends on the PR's behaviour. Smaller differences: - A zero-period timer with `EV_ADD | EV_FORCEONESHOT` becomes one-shot here. On FreeBSD, `filt_timerattach` only sees `EV_ONESHOT`, so the period becomes 1. - `EV_ENABLE | EV_DISABLE` in the same change returns `EINVAL` on FreeBSD (start of `kqueue_register`). Here the knote is disabled. **Probe on the same build.** Each scenario was appended to `GuestKqueue.cpp`, using its own helpers: | Scenario | main `44df21632` | this PR | FreeBSD 11 (from source) | |---|---|---|---| | user knote: `EV_ADD`, `NOTE_TRIGGER` data 100, then touch with data 7, poll | data 7 | data 100 | data 7 | | `EV_ADD \| EV_FORCEONESHOT`, trigger, poll, poll, `EV_DELETE` | throws | 1 event `flags=0x100`, then 0, delete `ENOENT` | flag dropped; 1 event `flags=0`, then 1 again (`EV_CLEAR` is not set), delete 0 | | `EV_ADD` (no trigger), then `EV_FORCEONESHOT`, poll | throws | 0 events | 1 event `flags=EV_ONESHOT`, knote dropped | The FreeBSD column comes from reading the source; I did not run FreeBSD. If the console is meant to follow FreeBSD here, the knote probably needs a separate disabled state and the flags masked as in `kqueue_register`. If not, it would help to record these differences in the debt entry: as written, it says `kqueue_register` is followed. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Nawasfadili commented 2026-10-15 23:10:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Nawasfadili on 2026-10-15T23:10:19Z.


Thanks a lot for the thorough review and FreeBSD 11 analysis, @jotitadev!

I've updated the PR to strictly match FreeBSD 11 (kern_event.c):

  1. Separate disabled state: Added a dedicated bool disabled field to KernelEqueueEvent so event.flags is no longer mutated or polluted with EV_DISABLE upon EV_DISPATCH delivery, mirroring FreeBSD's separation of kn_status (KN_DISABLED) and kn_kevent.flags.
  2. EV_FORCEONESHOT semantics:
    • Stripped in KNOTE_CLEARED_FLAGS on EV_ADD so a newly added knote remains persistent.
    • On an existing knote, it now sets EV_ONESHOT and activates it immediately (triggered = true), matching kern_event.c:1340-1341 (kn->kn_flags |= EV_ONESHOT; KNOTE_ACTIVATE(kn, 1);), returning with EV_ONESHOT and auto-dropping.
  3. EVFILT_USER data touch: TouchUserKnote now updates event.event.data = change.data unconditionally on every register touch, exactly as filt_usertouch(EVENT_REGISTER) does.
  4. Unit tests: Updated GuestKqueue.cpp to verify all three probe scenarios from your table (guest_kqueue passes 5/5 repeats, and conventions check passes cleanly).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6204184307 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6510#issuecomment-6204184307). Originally posted by [Nawasfadili](https://github.com/Nawasfadili) on 2026-10-15T23:10:19Z. --- Thanks a lot for the thorough review and FreeBSD 11 analysis, @jotitadev! I've updated the PR to strictly match FreeBSD 11 (`kern_event.c`): 1. **Separate disabled state**: Added a dedicated `bool disabled` field to `KernelEqueueEvent` so `event.flags` is no longer mutated or polluted with `EV_DISABLE` upon `EV_DISPATCH` delivery, mirroring FreeBSD's separation of `kn_status` (`KN_DISABLED`) and `kn_kevent.flags`. 2. **`EV_FORCEONESHOT` semantics**: - Stripped in `KNOTE_CLEARED_FLAGS` on `EV_ADD` so a newly added knote remains persistent. - On an existing knote, it now sets `EV_ONESHOT` and activates it immediately (`triggered = true`), matching `kern_event.c:1340-1341` (`kn->kn_flags |= EV_ONESHOT; KNOTE_ACTIVATE(kn, 1);`), returning with `EV_ONESHOT` and auto-dropping. 3. **`EVFILT_USER` data touch**: `TouchUserKnote` now updates `event.event.data = change.data` unconditionally on every register touch, exactly as `filt_usertouch(EVENT_REGISTER)` does. 4. **Unit tests**: Updated `GuestKqueue.cpp` to verify all three probe scenarios from your table (`guest_kqueue` passes 5/5 repeats, and conventions check passes cleanly).
karimibrahim07 commented 2026-10-16 14:13:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by karimibrahim07 on 2026-10-16T14:13:55Z.

Review: COMMENTED


A heads-up on where this PR stands. #5847, which implements the same EV_DISABLE, EV_DISPATCH and EV_FORCEONESHOT handling in Kqueue.cpp and Equeue.cpp, was merged by adriadam10 on 2026-10-15 at 21:01 UTC, a few hours after this PR opened. Head 522969b0c now conflicts with main 5d9dcc42d in five files (Equeue.cpp, Equeue.hpp, Kqueue.cpp, GuestKqueue.cpp and the libkernel debt doc), all from that overlap. The merged version's debt entry already describes the three flags.

The one part that isn't on main is the FileEvent.cpp change: IsDeleted also treating a path under $Deleted as deleted, and NOTE_DELETE raised on that transition. That's a separate topic from the kevent flags. If it fixes a case main misses, for example a delete where neither deletePending nor the link count changes in the snapshot, it could stand on its own as a small PR with a test that shows the missed NOTE_DELETE. If any of jotitadev's FreeBSD 11 points (the separate disabled state and so on) still differ from what #5847 merged, those would fit a follow-up against main too.

AI-assisted: yes. I checked the merge with main and compared the diff with the merged #5847.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5548982225 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6510#pullrequestreview-5548982225). Originally posted by [karimibrahim07](https://github.com/karimibrahim07) on 2026-10-16T14:13:55Z. **Review:** COMMENTED --- A heads-up on where this PR stands. #5847, which implements the same `EV_DISABLE`, `EV_DISPATCH` and `EV_FORCEONESHOT` handling in `Kqueue.cpp` and `Equeue.cpp`, was merged by adriadam10 on 2026-10-15 at 21:01 UTC, a few hours after this PR opened. Head `522969b0c` now conflicts with `main` `5d9dcc42d` in five files (`Equeue.cpp`, `Equeue.hpp`, `Kqueue.cpp`, `GuestKqueue.cpp` and the libkernel debt doc), all from that overlap. The merged version's debt entry already describes the three flags. The one part that isn't on `main` is the `FileEvent.cpp` change: `IsDeleted` also treating a path under `$Deleted` as deleted, and `NOTE_DELETE` raised on that transition. That's a separate topic from the kevent flags. If it fixes a case `main` misses, for example a delete where neither `deletePending` nor the link count changes in the snapshot, it could stand on its own as a small PR with a test that shows the missed `NOTE_DELETE`. If any of jotitadev's FreeBSD 11 points (the separate `disabled` state and so on) still differ from what #5847 merged, those would fit a follow-up against `main` too. AI-assisted: yes. I checked the merge with `main` and compared the diff with the merged #5847.
blawesom commented 2026-10-16 17:13:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-16T17:13:31Z.


Heads-up before more rebase effort goes in: main already implements this feature. PR #5847 landed b32c5a50c ("feat(libkernel): implement kevent EV_DISABLE, EV_DISPATCH and EV_FORCEONESHOT", Oct 14) with follow-up a7da412a7 ("follow kqueue_register for EV_FORCEONESHOT and modify flags"), so this PR is now a parallel implementation of merged work. main also renamed the event field this PR uses (disabled → enabled, inverted default).

What I find genuinely additive here, on top of #5847:

  • deleteEventFunc invocation when an EV_ONESHOT note retires in CollectTriggered (Equeue.cpp) — mirrors the pattern main already uses in CollectOncePerWait
  • Windows $Deleted path detection in FileEvent.cpp (IsDeleted(before) != IsDeleted(after) transitions) — not covered by main's NOTE_DELETE reporting as far as I can tell
  • five new test functions in GuestKqueue.cpp — with one caveat: EdgeCaseFlags applies EV_DISPATCH on modify and asserts it lands in the knote flags, which a7da412a7 deliberately removed (it follows FreeBSD kqueue_register, which does not OR dispatch flags into a note on modify), so that test contradicts main's semantics as-is

So the practical options are reducing this PR to the additive deltas (the delete-once and $Deleted pieces plus the compatible tests), or closing it in favor of #5847 — that's a call for you and the maintainers. I can carry the reduction as a rebase handoff if that's the wanted direction; the semantics question (EV_DISPATCH reset behavior — this PR resets via resetFunc/EV_CLEAR conditionally, main clears unconditionally) may also be worth reconciling against FreeBSD in whichever piece survives.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6220782019 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6510#issuecomment-6220782019). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-16T17:13:31Z. --- **Heads-up before more rebase effort goes in: `main` already implements this feature.** PR #5847 landed `b32c5a50c` ("feat(libkernel): implement kevent EV_DISABLE, EV_DISPATCH and EV_FORCEONESHOT", Oct 14) with follow-up `a7da412a7` ("follow kqueue_register for EV_FORCEONESHOT and modify flags"), so this PR is now a parallel implementation of merged work. `main` also renamed the event field this PR uses (`disabled` → `enabled`, inverted default). What I find genuinely additive here, on top of #5847: - `deleteEventFunc` invocation when an `EV_ONESHOT` note retires in `CollectTriggered` (Equeue.cpp) — mirrors the pattern `main` already uses in `CollectOncePerWait` - Windows `$Deleted` path detection in `FileEvent.cpp` (`IsDeleted(before) != IsDeleted(after)` transitions) — not covered by `main`'s `NOTE_DELETE` reporting as far as I can tell - five new test functions in `GuestKqueue.cpp` — with one caveat: `EdgeCaseFlags` applies `EV_DISPATCH` on *modify* and asserts it lands in the knote flags, which `a7da412a7` deliberately removed (it follows FreeBSD `kqueue_register`, which does not OR dispatch flags into a note on modify), so that test contradicts `main`'s semantics as-is So the practical options are reducing this PR to the additive deltas (the delete-once and `$Deleted` pieces plus the compatible tests), or closing it in favor of #5847 — that's a call for you and the maintainers. I can carry the reduction as a rebase handoff if that's the wanted direction; the semantics question (EV_DISPATCH reset behavior — this PR resets via `resetFunc`/EV_CLEAR conditionally, `main` clears unconditionally) may also be worth reconciling against FreeBSD in whichever piece survives.
Nawasfadili commented 2026-10-16 20:13:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Nawasfadili on 2026-10-16T20:13:19Z.


Thanks @blawesom and @karimibrahim07 for the thorough review and heads-up!
Since the kevent flags were already merged via #5847, I'll close this PR.

@blawesom If you'd like to carry over the additive pieces (deleteEventFunc in CollectTriggered, the Windows $Deleted handling in FileEvent, and the extra tests) as a follow-up rebase handoff, please feel free to do so! Thanks again for your guidance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6223839183 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6510#issuecomment-6223839183). Originally posted by [Nawasfadili](https://github.com/Nawasfadili) on 2026-10-16T20:13:19Z. --- Thanks @blawesom and @karimibrahim07 for the thorough review and heads-up! Since the kevent flags were already merged via #5847, I'll close this PR. @blawesom If you'd like to carry over the additive pieces (`deleteEventFunc` in `CollectTriggered`, the Windows `$Deleted` handling in `FileEvent`, and the extra tests) as a follow-up rebase handoff, please feel free to do so! Thanks again for your guidance.
adriadam10 commented 2026-10-19 02:43:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T02:43:36Z.


Closing: main already implements this feature. #5847 (plus a7da412a7) landed EV_DISABLE, EV_DISPATCH and EV_FORCEONESHOT in Kqueue.cpp/Equeue.cpp, so this PR is a parallel implementation and conflicts with main in five files. You also said on 2026-10-16 that you would close it.

The pieces not on main (deleteEventFunc when an EV_ONESHOT knote retires in CollectTriggered, the Windows $Deleted handling in FileEvent.cpp, and the extra tests) are welcome as a small follow-up PR rebased on current main, one topic each.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6258525296 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6510#issuecomment-6258525296). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T02:43:36Z. --- Closing: `main` already implements this feature. #5847 (plus `a7da412a7`) landed `EV_DISABLE`, `EV_DISPATCH` and `EV_FORCEONESHOT` in `Kqueue.cpp`/`Equeue.cpp`, so this PR is a parallel implementation and conflicts with `main` in five files. You also said on 2026-10-16 that you would close it. The pieces not on `main` (`deleteEventFunc` when an `EV_ONESHOT` knote retires in `CollectTriggered`, the Windows `$Deleted` handling in `FileEvent.cpp`, and the extra tests) are welcome as a small follow-up PR rebased on current `main`, one topic each.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!6510
No description provided.