PatchworkOS
Loading...
Searching...
No Matches
Statistics

Performance Statistics driver. More...

Data Structures

struct  statistics_cpu_ctx_t
 Per-CPU statistics context. More...
 

Functions

void statistics_cpu_ctx_init (statistics_cpu_ctx_t *ctx)
 Initializes a per-CPU statistics context.
 
void statistics_init (void)
 Initializes the statistics driver.
 
void statistics_interrupt_begin (interrupt_frame_t *frame, cpu_t *self)
 Called at the beginning of an interrupt.
 
void statistics_interrupt_end (interrupt_frame_t *frame, cpu_t *self)
 Called at the end of an interrupt.
 

Detailed Description

Performance Statistics driver.

The Performance Statistics driver is exposed in the /dev/stat directory. Below is an overview of the files in this directory.

Cpu Statistics

The /dev/stat/cpu file contains per-CPU statistics in the following format:

cpu idle_clocks active_clocks interrupt_clocks
cpu0 123456 789012 345678
cpu1 234567 890123 456789
...
cpuN 345678 901234 567890

Memory Statistics

The /dev/stat/mem file contains memory statistics in the following format:

value kib
total 1048576
free 524288
reserved 131072
_PUBLIC void free(void *ptr)
Definition free.c:11

Function Documentation

◆ statistics_cpu_ctx_init()

void statistics_cpu_ctx_init ( statistics_cpu_ctx_t ctx)

Initializes a per-CPU statistics context.

Parameters
ctxThe context to initialize.

Definition at line 24 of file statistics.c.

References statistics_cpu_ctx_t::activeClocks, statistics_cpu_ctx_t::idleClocks, statistics_cpu_ctx_t::interruptBegin, statistics_cpu_ctx_t::interruptClocks, statistics_cpu_ctx_t::interruptEnd, statistics_cpu_ctx_t::lock, and lock_init().

Referenced by cpu_init().

◆ statistics_init()

void statistics_init ( void  )

Initializes the statistics driver.

Definition at line 100 of file statistics.c.

References cpuFile, cpuOps, memFile, memOps, NULL, panic(), statDir, sysfs_dir_new(), and sysfs_file_new().

Referenced by init_finalize().

◆ statistics_interrupt_begin()

void statistics_interrupt_begin ( interrupt_frame_t frame,
cpu_t self 
)

Called at the beginning of an interrupt.

Will measure the time spent in interrupts and time spent idle/active.

Parameters
frameThe interrupt frame.
selfThe current CPU.

Definition at line 120 of file statistics.c.

References LOCK_SCOPE, sched_is_idle(), cpu_t::stat, stat(), and timer_uptime().

Referenced by interrupt_handler().

◆ statistics_interrupt_end()

void statistics_interrupt_end ( interrupt_frame_t frame,
cpu_t self 
)

Called at the end of an interrupt.

Parameters
frameThe interrupt frame.
selfThe current CPU.

Definition at line 140 of file statistics.c.

References LOCK_SCOPE, cpu_t::stat, stat(), and timer_uptime().

Referenced by interrupt_handler().