diff options
-rw-r--r-- | src/kernel/arch/amd64/interrupts/isr.c | 2 | ||||
-rw-r--r-- | src/kernel/mem/alloc.c | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/kernel/arch/amd64/interrupts/isr.c b/src/kernel/arch/amd64/interrupts/isr.c index 17dce6e..519d783 100644 --- a/src/kernel/arch/amd64/interrupts/isr.c +++ b/src/kernel/arch/amd64/interrupts/isr.c @@ -6,6 +6,7 @@ #include <kernel/arch/amd64/port_io.h> #include <kernel/arch/amd64/time.h> #include <kernel/arch/generic.h> +#include <kernel/mem/alloc.h> #include <kernel/panic.h> #include <kernel/proc.h> #include <stdbool.h> @@ -53,6 +54,7 @@ void isr_stage3(int interrupt, uint64_t *stackframe) { default: if ((stackframe[1] & 0x3) == 0) { + mem_debugprint(); log_interrupt(interrupt, stackframe); cpu_halt(); } else { diff --git a/src/kernel/mem/alloc.c b/src/kernel/mem/alloc.c index 3ed49d6..a8e5aed 100644 --- a/src/kernel/mem/alloc.c +++ b/src/kernel/mem/alloc.c @@ -20,6 +20,7 @@ struct malloc_hdr *malloc_last = NULL; extern uint8_t pbitmap[], pbitmap_start[]; /* linker.ld */ static size_t pbitmap_len; static size_t pbitmap_searchstart = 0; +static size_t pbitmap_taken = 0; static bool bitmap_get(size_t i) { @@ -32,6 +33,11 @@ static void bitmap_set(size_t i, bool v) { size_t b = i / 8; uint8_t m = 1 << (i&7); assert(b < pbitmap_len); + if ((pbitmap[b] & m) ^ v) { + /* value changes */ + if (v) pbitmap_taken++; + else pbitmap_taken--; + } if (v) pbitmap[b] |= m; else pbitmap[b] &= ~m; } @@ -72,6 +78,7 @@ void mem_debugprint(void) { total++; } kprintf(" total 0x%x\n", total); + kprintf("pbitmap usage %u/%u\n", pbitmap_taken, pbitmap_len * 8); } void *page_alloc(size_t pages) { |