kernel/vm: Check page->accessed as well as page->usage_count in pre_map.

usage_count is set by the page_daemon, and as such isn't often
updated. In order to check whether new or "hot" pages are in-use,
we need to check their "accessed" flag directly.

This is a significant speed improvement, especially in heavily-contended
mapped files (e.g. shared libraries in a compile job.)

Same benchmark (compile the mime_db and relink HaikuDepot):
before (same as previous commit's "after"):
real    0m18.789s
user    0m14.880s
sys     0m8.779s

after:
real    0m16.615s
user    0m13.919s
sys     0m5.972s
This commit is contained in:
Augustin Cavalier
2024-07-24 00:34:07 -04:00
parent fb594524ff
commit acc926946c
+1 -1
View File
@@ -2123,7 +2123,7 @@ pre_map_area_pages(VMArea* area, VMCache* cache,
break;
// skip busy and inactive pages
if (page->busy || page->usage_count == 0)
if (page->busy || (page->usage_count == 0 && !page->accessed))
continue;
DEBUG_PAGE_ACCESS_START(page);