kernel: Add assertions to ensure vm_page_reservation is destroyed with a count of 0.

Inspired by some of jpelczar's changes.
This commit is contained in:
Augustin Cavalier
2024-09-10 12:13:38 -04:00
parent 5f8fe75449
commit b4798ac6a7
2 changed files with 11 additions and 1 deletions
+8
View File
@@ -20,6 +20,14 @@ extern int32 gMappedPagesCount;
struct vm_page_reservation { struct vm_page_reservation {
uint32 count; uint32 count;
#if KDEBUG && defined(__cplusplus)
vm_page_reservation() : count(0) {}
~vm_page_reservation()
{
ASSERT(count == 0);
}
#endif
}; };
+3 -1
View File
@@ -3990,8 +3990,10 @@ vm_page_allocate_page_run(uint32 flags, page_num_t length,
if (foundRun) { if (foundRun) {
i = allocate_page_run(start, length, flags, freeClearQueueLocker); i = allocate_page_run(start, length, flags, freeClearQueueLocker);
if (i == length) if (i == length) {
reservation.count = 0;
return &sPages[start]; return &sPages[start];
}
// apparently a cached page couldn't be allocated -- skip it and // apparently a cached page couldn't be allocated -- skip it and
// continue // continue