Fix the LIMIT_AVAILABLE_MEMORY debug option.
When limiting the available memory by reducing the page count it may not be enough to just limit sNumPages. Depending on the physical memory map non existing pages between ranges (sNonExistingPages) would still be added up and later subtracted from the sNumPages, resulting in a wrong max page count. Also due to the fixed removal of non existing page ranges the actually available memory would usually not be the amount set via LIMIT_AVAILABLE_MEMORY. Instead we now calculate the available memory when going through the physical memory ranges and limit/exit as soon as we've reached the desired amount of available memory (also ignoring further non-existing pages).
This commit is contained in:
parent
57093ab5ed
commit
3dbd9c1148
@ -3236,17 +3236,22 @@ vm_page_init_num_pages(kernel_args *args)
|
||||
sNonExistingPages += start - physicalPagesEnd;
|
||||
physicalPagesEnd = start
|
||||
+ args->physical_memory_range[i].size / B_PAGE_SIZE;
|
||||
|
||||
#ifdef LIMIT_AVAILABLE_MEMORY
|
||||
page_num_t available
|
||||
= physicalPagesEnd - sPhysicalPageOffset - sNonExistingPages;
|
||||
if (available > LIMIT_AVAILABLE_MEMORY * (1024 * 1024 / B_PAGE_SIZE)) {
|
||||
physicalPagesEnd = sPhysicalPageOffset + sNonExistingPages
|
||||
+ LIMIT_AVAILABLE_MEMORY * (1024 * 1024 / B_PAGE_SIZE);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TRACE(("first phys page = %#" B_PRIxPHYSADDR ", end %#" B_PRIxPHYSADDR "\n",
|
||||
sPhysicalPageOffset, physicalPagesEnd));
|
||||
|
||||
sNumPages = physicalPagesEnd - sPhysicalPageOffset;
|
||||
|
||||
#ifdef LIMIT_AVAILABLE_MEMORY
|
||||
if (sNumPages > LIMIT_AVAILABLE_MEMORY * (1024 * 1024 / B_PAGE_SIZE))
|
||||
sNumPages = LIMIT_AVAILABLE_MEMORY * (1024 * 1024 / B_PAGE_SIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user