Should khu work with dumbvm? In other words, if I run ASST2 code and the number reported by khu grows significantly between calls to ASST2 functions, is our code leaking memory? Or is it because dumbvm doesn’t reclaim pages?
khu works with dumbvm, and yes, that indicates your code is leaking memory .
khu reports its total, it essentially needs to deal with two values: the number of bytes used by the VM/coremap (dumbvm for ASST2), and the number of bytes used by the subpage allocator (
kmalloc). There’s a slight caveat here - it’s not quite the sum of the two; we need to subtract off the number of pages owned the subpage allocator, since there is overlap. Anyways,
coremap_used_bytes() is the function that returns the number of bytes the VM has allocated, and dumbvm always returns 0. So, even though it is leaking pages, it isn’t reporting it. And yes, we did this intentionally so we could detect leaks in ASST2 .
You can find this in the code if you follow the call chain for
khu from the menu.