|
PatchworkOS
28a9544
A non-POSIX operating system.
|
Performance driver. More...
Data Structures | |
| struct | perf_cpu_ctx_t |
| Per-CPU performance context. More... | |
| struct | perf_process_ctx_t |
| struct | perf_thread_ctx_t |
| Per-Thread performance context. More... | |
| struct | stat_process_ctx_t |
| Per-Process performance context. More... | |
Functions | |
| void | perf_cpu_ctx_init (perf_cpu_ctx_t *ctx) |
| Initializes a per-CPU performance context, must be called on the CPU that owns the context. | |
| void | perf_process_ctx_init (perf_process_ctx_t *ctx) |
| Initializes a per-process performance context. | |
| void | perf_thread_ctx_init (perf_thread_ctx_t *ctx) |
| Initializes a per-thread performance context. | |
| void | perf_init (void) |
| Initializes the performance driver. | |
| void | perf_interrupt_begin (cpu_t *self) |
| Called at the beginning of an interrupt to update cpu performance data. | |
| void | perf_interrupt_end (cpu_t *self) |
| Called at the end of an interrupt to update cpu performance data. | |
| void | perf_syscall_begin (void) |
| Called at the beginning of a syscall to update process performance data. | |
| void | perf_syscall_end (void) |
| Called at the end of a syscall to update process performance data. | |
Performance driver.
The Performance driver is exposed in the /dev/perf directory. Below is an overview of the files in this directory.
The /dev/perf/cpu file contains per-CPU performance data in the following format:
The /dev/perf/mem file contains memory performance data in the following format:
| void perf_cpu_ctx_init | ( | perf_cpu_ctx_t * | ctx | ) |
Initializes a per-CPU performance context, must be called on the CPU that owns the context.
| ctx | The context to initialize. |
Definition at line 108 of file perf.c.
References perf_cpu_ctx_t::activeClocks, perf_cpu_ctx_t::idleClocks, perf_cpu_ctx_t::interruptBegin, perf_cpu_ctx_t::interruptClocks, perf_cpu_ctx_t::interruptEnd, perf_cpu_ctx_t::lock, and lock_init().
Referenced by cpu_init().
| void perf_init | ( | void | ) |
Initializes the performance driver.
Definition at line 131 of file perf.c.
References cpuFile, cpuOps, memFile, memOps, NULL, panic(), perfDir, sysfs_dir_new(), and sysfs_file_new().
Referenced by init_finalize().
| void perf_interrupt_begin | ( | cpu_t * | self | ) |
Called at the beginning of an interrupt to update cpu performance data.
Must be called with interrupts disabled.
| self | The current CPU. |
Definition at line 151 of file perf.c.
References perf_cpu_ctx_t::activeClocks, atomic_fetch_add, perf_cpu_ctx_t::idleClocks, perf_cpu_ctx_t::interruptBegin, perf_cpu_ctx_t::interruptEnd, perf_cpu_ctx_t::lock, LOCK_SCOPE, NULL, panic(), cpu_t::perf, process_t::perf, thread_t::perf, thread_t::process, sched_is_idle(), sched_thread_unsafe(), sys_time_uptime(), perf_thread_ctx_t::syscallBegin, and perf_thread_ctx_t::syscallEnd.
Referenced by interrupt_handler().
| void perf_interrupt_end | ( | cpu_t * | self | ) |
Called at the end of an interrupt to update cpu performance data.
Must be called with interrupts disabled.
| self | The current CPU. |
Definition at line 187 of file perf.c.
References perf_cpu_ctx_t::interruptBegin, perf_cpu_ctx_t::interruptClocks, perf_cpu_ctx_t::interruptEnd, perf_cpu_ctx_t::lock, LOCK_SCOPE, cpu_t::perf, thread_t::perf, sched_thread_unsafe(), sys_time_uptime(), perf_thread_ctx_t::syscallBegin, and perf_thread_ctx_t::syscallEnd.
Referenced by interrupt_handler().
| void perf_process_ctx_init | ( | perf_process_ctx_t * | ctx | ) |
Initializes a per-process performance context.
| ctx | The context to initialize. |
Definition at line 118 of file perf.c.
References atomic_init, perf_process_ctx_t::startTime, and sys_time_uptime().
Referenced by process_init().
| void perf_syscall_begin | ( | void | ) |
Called at the beginning of a syscall to update process performance data.
Must be called with interrupts disabled.
Definition at line 205 of file perf.c.
References atomic_fetch_add, NULL, panic(), process_t::perf, thread_t::perf, thread_t::process, sched_thread_unsafe(), sys_time_uptime(), perf_thread_ctx_t::syscallBegin, perf_thread_ctx_t::syscallEnd, and uptime().
Referenced by syscall_handler().
| void perf_syscall_end | ( | void | ) |
Called at the end of a syscall to update process performance data.
Must be called with interrupts disabled.
Definition at line 225 of file perf.c.
References atomic_fetch_add, process_t::perf, thread_t::perf, thread_t::process, sched_thread_unsafe(), sys_time_uptime(), perf_thread_ctx_t::syscallBegin, and perf_thread_ctx_t::syscallEnd.
Referenced by syscall_handler().
| void perf_thread_ctx_init | ( | perf_thread_ctx_t * | ctx | ) |
Initializes a per-thread performance context.
| ctx | The context to initialize. |
Definition at line 125 of file perf.c.
References perf_thread_ctx_t::syscallBegin, and perf_thread_ctx_t::syscallEnd.
Referenced by thread_init().