diff options
Diffstat (limited to 'src/kernel/mem/alloc.c')
-rw-r--r-- | src/kernel/mem/alloc.c | 7 |
1 files changed, 7 insertions, 0 deletions
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) { |