kernel: profiling infrastructure

This commit is contained in:
Matheus
2025-12-05 18:19:42 -03:00
parent d10295dcdf
commit 40bbf217ee
19 changed files with 595 additions and 3 deletions
+1
View File
@@ -20,6 +20,7 @@
#define DEV_MAJOR_MOUSE 11
#define DEV_MAJOR_PTY 12
#define DEV_MAJOR_ACPI 13
#define DEV_MAJOR_PROF 14
typedef struct {
int (*open)(int minor, vnode_t **vnode, int flags);
+6
View File
@@ -0,0 +1,6 @@
#ifndef _PROF_H
#define _PROF_H
void profiling_insert(uint8_t size, void *data);
#endif
+1
View File
@@ -7,6 +7,7 @@ void arch_apic_timerinit();
void arch_apic_init();
void arch_apic_initap();
void arch_apic_eoi();
void arch_apic_init_perf(void);
void arch_ioapic_setirq(uint8_t gsi, uint8_t vector, uint8_t proc, bool masked);
void arch_apic_sendipi(uint8_t cpu, uint8_t vec, uint8_t dest, uint8_t mode, uint8_t level);
+5
View File
@@ -13,6 +13,7 @@
#include <kernel/dpc.h>
#include <arch/apic.h>
#include <kernel/timekeeper.h>
#include <ringbuffer.h>
#define ARCH_EOI arch_apic_eoi
@@ -68,6 +69,10 @@ typedef struct cpu_t {
spinlock_t shootdown_lock;
int *shootdown_done;
#ifdef ENABLE_PROFILING
ringbuffer_t *prof_ringbuffer;
#endif
// architecture specific, does not need to be exposed
uint64_t gdt[7];
+5
View File
@@ -4,6 +4,11 @@
#include <stdint.h>
#define MSR_IA32APICBASE 0x1B
#define MSR_PERF_FIXED_CTR2 0x30b
#define MSR_PERF_FIXED_CTR_CTRL 0x38d
#define MSR_PERF_GLOBAL_STATUS 0x38e
#define MSR_PERF_GLOBAL_CTRL 0x38f
#define MSR_PERF_GLOBAL_OVF_CTRL 0x390
#define MSR_EFER 0xC0000080
#define MSR_STAR 0xC0000081
#define MSR_LSTAR 0xC0000082
+9
View File
@@ -0,0 +1,9 @@
#ifndef ARCH_PROF_H
#define ARCH_PROF_H
#include <arch/context.h>
#include <stdbool.h>
bool arch_profiling_irq(context_t *ctx);
#endif