Skip to content

feat(ktrace): added trace sessions and .ktrace extraction through /dev/ktrace - #347

Merged
FlareCoding merged 14 commits into
masterfrom
pr/ktrace-foundation
Oct 7, 2026
Merged

FlareCoding merged 14 commits into
masterfrom
pr/ktrace-foundation

Conversation

@FlareCoding

@FlareCoding FlareCoding commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Note

Medium Risk
New SMP-aware ring buffer and session state machine in the kernel plus devfs/syscall error plumbing; failures are mostly isolated but bugs could affect tracing correctness or concurrent open/start/stop behavior.

Overview
Adds kernel trace sessions with start() / stop() that clear per-CPU rings on start, drop events outside recording, stamp records with clock::now_ns(), and on stop close rings until reserved slots commit. Stopped sessions can be read as a versioned .ktrace blob (header, CPU table, oldest-first records, including wrapped rings) via /dev/ktrace/trace, with /dev/ktrace/control (start/stop writes) and /dev/ktrace/status (text snapshot). Boot registers these nodes through ktrace::register_devfs_nodes() after ktrace::init().

Introduces shared devfs::text_snapshot_node and append_str / append_u64 helpers (grow-on-read instead of fixed caps); sysstat drops its local snapshot node and uses this type for /dev/sysinfo/*. Plumbs fs::ERR_NODATA and EBUSY through resource providers and syscalls as ENODATA / EBUSY. Adds a userland ktrace app (start, stop, status, dump -o FILE) plus kernel tests for devfs snapshots and ktrace session/control/trace behavior.

Reviewed by Cursor Bugbot for commit d5b874a. Bugbot is set up for automated code reviews on this repo. Configure here.

cursor[bot]

This comment was marked as resolved.

@FlareCoding
FlareCoding merged commit f4e3cd3 into master Oct 7, 2026
10 checks passed
@FlareCoding
FlareCoding deleted the pr/ktrace-foundation branch October 7, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant