libkernel: kqueue, kevent and the file-event calls are absent (Cloudberry Kingdom, Palworld); implementation ready #3461

Closed
opened 2026-10-11 10:59:19 +00:00 by screamm · 4 comments
screamm commented 2026-10-11 10:59:19 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T10:59:19Z.


libkernel does not export kqueue, kevent, sceKernelAddFileEvent (cG3t15OK4Ow) or sceKernelDeleteFileEvent (UmXngHKB6is). Cloudberry Kingdom (PPSA23827, #3177) calls kevent right after start-up with an EVFILT_VNODE registration, and Palworld's Discord module imports kevent and the two file-event calls (#2648).

Fix branch ready: screamm:feat/libkernel-kqueue (two commits on main 6cee0bb0: cd21c720 feat(libkernel): implement kqueue and kevent over the event queue, a289fb40 feat(libkernel): implement file events). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commits as they are. The Linux inotify path has only been compiled against stub headers on Windows, so a Linux build and run is the first thing it needs.

  • Commit 1: kqueue() reserves a number in the file descriptor space (the same null-device trick the Windows directory descriptors use) backed by an equeue; close/_close/sceKernelClose/dup2 onto it close the queue and drop its events from every queue; kevent() follows FreeBSD 11.0.1 kern_event.c for the change list, EV_ERROR/EV_RECEIPT, errno codes and timeout rules, with read/write on guest sockets, timers and user events; a kqueue reports each ready event once per call. Unmodelled filters, EV_DISABLE/EV_DISPATCH/EV_FORCEONESHOT, NOTE_LOWAT, EV_CLEAR on a socket, read/write on non-sockets, changes to an existing timer (11.0 vs 11.4 differ) and fractional nanosecond periods above one second throw; the deviations (read/write/fstat on a kqueue, the global timer limit, close waking a waiter) are in TechnicalDebt. The equeue's two event-collection loops are merged into one (will conflict with a fix for #3115).
  • Commit 2: EVFILT_VNODE watches the host file or directory and maps changes to NOTE_WRITE/EXTEND/ATTRIB/LINK/DELETE/RENAME (Windows: FindFirstChangeNotification plus a 50 ms poll of size, times and link count, because the directory notification does not fire for a write through an open handle until flush or close; Linux: inotify); sceKernelAddFileEvent(eq, fd, watch, udata)/DeleteFileEvent use the OpenOrbis and SharpProspero signatures with EV_CLEAR and watch as fflags (a guess, recorded). NOTE_REVOKE/OPEN/CLOSE/CLOSE_WRITE/READ, unknown bits and NOTE_EXTEND on a Windows directory throw; sockets, pipes and kqueues return EINVAL.
  • New guest_kqueue: create/close, timers, a user event from another thread, read/write on a socket pair, EV_ERROR, timeout and errors, a vnode watch seeing a write with Cloudberry's exact flags, the sce pair, a directory watch.

Tested on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, full build including libs: guest_kqueue, guest_equeue_events, guest_socket_events, guest_dup, guest_ppsa01530_exports 3/3 (and guest_kqueue 15 runs, 4 at a time); ctest -j8 -E "^agc_driver_|^video_out_flip" 528/529, the one failure being windows_exceptions (#3411); tools/check_conventions.py --base main and git diff --check pass. Not run on Linux; no title run (if Cloudberry's descriptor is a directory, the Windows NOTE_EXTEND throw still stops it).

Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5800434223 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3461). Originally posted by [screamm](https://github.com/screamm) on 2026-10-11T10:59:19Z. --- libkernel does not export `kqueue`, `kevent`, `sceKernelAddFileEvent` (`cG3t15OK4Ow`) or `sceKernelDeleteFileEvent` (`UmXngHKB6is`). Cloudberry Kingdom (PPSA23827, #3177) calls `kevent` right after start-up with an `EVFILT_VNODE` registration, and Palworld's Discord module imports `kevent` and the two file-event calls (#2648). **Fix branch ready:** [`screamm:feat/libkernel-kqueue`](https://github.com/screamm/AnyPS5/tree/feat/libkernel-kqueue) (two commits on `main` `6cee0bb0`: `cd21c720` `feat(libkernel): implement kqueue and kevent over the event queue`, `a289fb40` `feat(libkernel): implement file events`). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commits as they are. The Linux inotify path has only been compiled against stub headers on Windows, so a Linux build and run is the first thing it needs. - Commit 1: `kqueue()` reserves a number in the file descriptor space (the same null-device trick the Windows directory descriptors use) backed by an equeue; `close`/`_close`/`sceKernelClose`/`dup2` onto it close the queue and drop its events from every queue; `kevent()` follows FreeBSD 11.0.1 `kern_event.c` for the change list, `EV_ERROR`/`EV_RECEIPT`, errno codes and timeout rules, with read/write on guest sockets, timers and user events; a kqueue reports each ready event once per call. Unmodelled filters, `EV_DISABLE`/`EV_DISPATCH`/`EV_FORCEONESHOT`, `NOTE_LOWAT`, `EV_CLEAR` on a socket, read/write on non-sockets, changes to an existing timer (11.0 vs 11.4 differ) and fractional nanosecond periods above one second throw; the deviations (read/write/fstat on a kqueue, the global timer limit, close waking a waiter) are in TechnicalDebt. The equeue's two event-collection loops are merged into one (will conflict with a fix for #3115). - Commit 2: `EVFILT_VNODE` watches the host file or directory and maps changes to `NOTE_WRITE`/`EXTEND`/`ATTRIB`/`LINK`/`DELETE`/`RENAME` (Windows: `FindFirstChangeNotification` plus a 50 ms poll of size, times and link count, because the directory notification does not fire for a write through an open handle until flush or close; Linux: inotify); `sceKernelAddFileEvent(eq, fd, watch, udata)`/`DeleteFileEvent` use the OpenOrbis and SharpProspero signatures with `EV_CLEAR` and `watch` as `fflags` (a guess, recorded). `NOTE_REVOKE`/`OPEN`/`CLOSE`/`CLOSE_WRITE`/`READ`, unknown bits and `NOTE_EXTEND` on a Windows directory throw; sockets, pipes and kqueues return `EINVAL`. - New `guest_kqueue`: create/close, timers, a user event from another thread, read/write on a socket pair, `EV_ERROR`, timeout and errors, a vnode watch seeing a write with Cloudberry's exact flags, the sce pair, a directory watch. **Tested** on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, `BUILD_TESTING=ON`, full build including `libs`: `guest_kqueue`, `guest_equeue_events`, `guest_socket_events`, `guest_dup`, `guest_ppsa01530_exports` 3/3 (and `guest_kqueue` 15 runs, 4 at a time); `ctest -j8 -E "^agc_driver_|^video_out_flip"` 528/529, the one failure being `windows_exceptions` (#3411); `tools/check_conventions.py --base main` and `git diff --check` pass. Not run on Linux; no title run (if Cloudberry's descriptor is a directory, the Windows `NOTE_EXTEND` throw still stops it). Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).
blawesom commented 2026-10-11 13:08:49 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T13:08:49Z.


Independent verification on Linux: CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • Rebased a289fb403 onto current main: one conflict in Equeue.cpp (main and the branch place GetTriggeredEvents on opposite sides of CollectTriggered; both versions identical, the branch's order kept), plus a duplicated CollectTriggered declaration the replay left in Equeue.hpp (removed).
  • tools/check_conventions.py --base origin/main and git diff --check pass.
  • guest_kqueue passes, along with the full suite: 833/833 (AMD RX 9070 XT / RADV).

The rebased branch is available at blawesom:verify/3461 for anyone carrying — the commit is otherwise unchanged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109355761 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3461#issuecomment-6109355761). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-11T13:08:49Z. --- Independent verification on **Linux**: CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`. - Rebased `a289fb403` onto current `main`: one conflict in `Equeue.cpp` (main and the branch place `GetTriggeredEvents` on opposite sides of `CollectTriggered`; both versions identical, the branch's order kept), plus a duplicated `CollectTriggered` declaration the replay left in `Equeue.hpp` (removed). - `tools/check_conventions.py --base origin/main` and `git diff --check` pass. - `guest_kqueue` passes, along with the full suite: **833/833** (AMD RX 9070 XT / RADV). The rebased branch is available at [`blawesom:verify/3461`](https://github.com/blawesom/AnyPS5/tree/verify/3461) for anyone carrying — the commit is otherwise unchanged.
queeeef commented 2026-10-11 17:21:53 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by queeeef on 2026-10-11T17:21:53Z.


Tested on Windows with Palworld (PPSA23126, 01.102.999), whose libdiscord_partner_sdk.prx imports kevent, sceKernelAddFileEvent and sceKernelDeleteFileEvent (#2648).

blawesom:verify/3461 (35b3628e) cherry-picks cleanly onto main a11c8f7f7. Without it the title stops at unresolved ELF import cG3t15OK4Ow from libkernel.prx; with it every import binds and the title runs to character creation (other fixes listed in #2648). I did not check whether the title calls kevent or the file-event functions in that time, and I did not run the tests.

Windows 11 Pro 26300, MinGW-w64 GCC 15.2.0 (WinLibs r7), RelWithDebInfo. AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111648140 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3461#issuecomment-6111648140). Originally posted by [queeeef](https://github.com/queeeef) on 2026-10-11T17:21:53Z. --- Tested on Windows with Palworld (PPSA23126, 01.102.999), whose `libdiscord_partner_sdk.prx` imports `kevent`, `sceKernelAddFileEvent` and `sceKernelDeleteFileEvent` (#2648). `blawesom:verify/3461` (`35b3628e`) cherry-picks cleanly onto `main` `a11c8f7f7`. Without it the title stops at `unresolved ELF import cG3t15OK4Ow from libkernel.prx`; with it every import binds and the title runs to character creation (other fixes listed in #2648). I did not check whether the title calls `kevent` or the file-event functions in that time, and I did not run the tests. Windows 11 Pro 26300, MinGW-w64 GCC 15.2.0 (WinLibs r7), RelWithDebInfo. AI-assisted (Claude Code).
xXPBSXx commented 2026-10-11 20:59:03 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-11T20:59:03Z.


Cloudberry Kingdom (PPSA23827) on main (0a8b1d32b, plain main), 120 s run: terminate called after throwing an instance of 'std::runtime_error' what(): kqueue_nid_postfix not implemented, after the title looks for configs in savedata. So kqueue is still the first stop on main; #3764 implements kqueue, kevent and the file events. I have not run the title with #3764 applied.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6113686578 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3461#issuecomment-6113686578). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-11T20:59:03Z. --- Cloudberry Kingdom (PPSA23827) on `main` (`0a8b1d32b`, plain main), 120 s run: `terminate called after throwing an instance of 'std::runtime_error' what(): kqueue_nid_postfix not implemented`, after the title looks for `configs` in savedata. So `kqueue` is still the first stop on main; #3764 implements `kqueue`, `kevent` and the file events. I have not run the title with #3764 applied. AI-assisted (Claude Code).
xXPBSXx commented 2026-10-12 02:10:29 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T02:10:29Z.


Test with #3764 (kqueue) on main, Windows 10, GCC, 150 s limit: the kqueue/file-event imports bind and the title now stops at what(): EVFILT_VNODE: NOTE_EXTEND on a directory not implemented (SIGABRT), the throw in FileEvent.cpp OpenHostWatch of #3764: the title registers a vnode event with NOTE_EXTEND on a directory. Details in https://github.com/boykopovar/AnyPS5/pull/3764 (comment).

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6116506392 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3461#issuecomment-6116506392). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-12T02:10:29Z. --- Test with #3764 (kqueue) on main, Windows 10, GCC, 150 s limit: the kqueue/file-event imports bind and the title now stops at `what(): EVFILT_VNODE: NOTE_EXTEND on a directory not implemented` (SIGABRT), the throw in `FileEvent.cpp` `OpenHostWatch` of #3764: the title registers a vnode event with `NOTE_EXTEND` on a directory. Details in https://github.com/boykopovar/AnyPS5/pull/3764 (comment). AI-assisted (Claude Code).
Sign in to join this conversation.
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#3461
No description provided.