Expand description
Tracing data structures
This module defines the object and data structures for tracing kernel, thread, etc. events. Tracing is done via the sys_ktrace system call, which takes an object and a trace spec. This object is the “prime” trace object for a sequence of trace objects. The kernel fills these objects with a stream of trace events until they fill up (reach a maximum size defined by the kernel). Once a trace object fills up, the kernel generates a new trace object with the same CreateSpec as the prime object, and starts filling that object with data. It then appends a ‘next-object’ entry to the object that just filled up, so readers know which object to continue reading from.
A single prime tracing object can be associated with multiple TraceSpec structures, enabling that object (or its subsequent objects) to collect a wide variety of data with fine-grained control over which events are collected.
Streamed data is tracked via the TraceBase structure, located at the base address of any trace object. The end field defines the current end-point of data within the object. This atomic field is updated by the kernel when trace data is written, and any threads sleeping on this value will wake up.
Note that not all trace events are generated synchronously. Asynchronous events are generated by the kernel when in critical states. These events are not guaranteed to be reported in a timely manner, and may be dropped if the system is under heavy load.
Structs§
- Context
Fault Event - Event data for memory faults.
- Context
MapEvent - Event data for memory mapping operations.
- Fault
Flags - Flags describing memory fault characteristics.
- Pager
Command Responded - Event data for pager command responses.
- Pager
Command Sent - Event data for pager commands sent to kernel.
- Pager
Request Completed - Event data for completed pager requests.
- Pager
Request Recv - Event data for pager requests received.
- Syscall
Entry Event - Event data for system call entry.
- Thread
CtxSwitch - Event data for thread context switches.
- Thread
Event - Event data for thread operations.
- Thread
Migrate - Event data for thread migration between CPUs.
- Thread
Sampling Event - Event data for thread sampling operations.
- Trace
Base - The base structure for a trace object.
- Trace
Data - Header for additional data.
- Trace
Entry Flags - Trace entry flags.
- Trace
Entry Head - Header for a trace entry. This is always present, and may be optionally followed by additional
data, if the
flags
field contains theHAS_DATA
flag. - Trace
Flags
Enums§
- Trace
Kind - Kinds of tracing events.
Constants§
- CONTEXT_
FAULT - Memory fault occurred.
- CONTEXT_
INVALIDATION - Memory invalidation occurred.
- CONTEXT_
MAP - Memory mapping operation occurred.
- CONTEXT_
SHOOTDOWN - TLB shootdown occurred.
- CONTEXT_
UNMAP - Memory unmapping operation occurred.
- KERNEL_
ALLOC - Kernel memory allocation occurred.
- OBJECT_
CREATE - Object was created.
- OBJECT_
CTRL - Object control operation occurred.
- PAGER_
COMMAND_ RESPONDED - Pager command was responded to.
- PAGER_
COMMAND_ SEND - Pager command was sent.
- PAGER_
REQUEST_ COMPLETED - Pager request was completed.
- PAGER_
REQUEST_ RECV - Pager request was received.
- SECURITY_
CTX_ ENTRY - Entered a security context.
- SECURITY_
CTX_ EXIT - Exited a security context.
- SECURITY_
VIOLATION - Security violation occurred.
- THREAD_
BLOCK - Thread was blocked.
- THREAD_
CONTEXT_ SWITCH - Thread context switch occurred.
- THREAD_
EXIT - Thread has exited.
- THREAD_
MIGRATE - Thread migrated to a different CPU.
- THREAD_
RESUME - Thread was resumed from blocked state.
- THREAD_
SAMPLE - Thread sampling event occurred.
- THREAD_
SYSCALL_ ENTRY - Thread made a system call.
Traits§
- Trace
Data Cast - Trait for types that can be cast from trace data based on event types.