mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-29 21:58:20 +00:00
mm: added page fault range caching for each mm_space_t
mm: added last_pagefault handling when mm_space_t is unmapped mm: fixed styling inconsistencies, fixed last pagefault range removal mm: fix unitialized last_pagefault member in slab data
This commit is contained in:
+15
-2
@@ -273,7 +273,13 @@ bool mm_handle_page_fault(void *addr, bool user, int actions) {
|
||||
}
|
||||
|
||||
MUTEX_ACQUIRE(&space->lock);
|
||||
mm_range_t *range = mm_get_range(space, addr);
|
||||
|
||||
// we look at the last page fault range and check if the address is in this range
|
||||
// this might avoid a more expensive tree lookup
|
||||
mm_range_t *range = space->last_pagefault;
|
||||
if (range == NULL || range->start > addr || addr >= range->start + range->size) {
|
||||
range = mm_get_range(space, addr);
|
||||
}
|
||||
|
||||
bool status = false;
|
||||
|
||||
@@ -282,6 +288,8 @@ bool mm_handle_page_fault(void *addr, bool user, int actions) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
space->last_pagefault = range;
|
||||
|
||||
// check if valid
|
||||
|
||||
int invalid_actions = 0;
|
||||
@@ -486,8 +494,12 @@ void *mm_map(void *addr, volatile size_t size, int flags, mmuflags_t mmuflags, v
|
||||
|
||||
mm_insert_range(space, range);
|
||||
cleanup:
|
||||
if (ret_addr == NULL && range)
|
||||
if (ret_addr == NULL && range) {
|
||||
if (space->last_pagefault == range)
|
||||
space->last_pagefault = NULL;
|
||||
|
||||
mm_free_range(range);
|
||||
}
|
||||
|
||||
MUTEX_RELEASE(&space->lock);
|
||||
return ret_addr;
|
||||
@@ -547,6 +559,7 @@ mm_context_t *mm_create_context() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx->space.last_pagefault = NULL;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user