kernel: mmu: move when page fault is counted
The beginning of code in do_page_fault() is to pin the page in memory if it is already present in physical memory. It is there so that if a page is not present, it can proceed to perform page-in and then pin it. So the counting of page faults needs to be moved after the pinning code so it actually counts page faults, and not counting pinning operations when the page is already present. Also clarify the comment on the goto statement as it is not correct. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
ebbfde9742
commit
7771d27525
11
kernel/mmu.c
11
kernel/mmu.c
|
@ -1239,8 +1239,6 @@ static bool do_page_fault(void *addr, bool pin)
|
|||
}
|
||||
result = true;
|
||||
|
||||
paging_stats_faults_inc(faulting_thread, key);
|
||||
|
||||
if (status == ARCH_PAGE_LOCATION_PAGED_IN) {
|
||||
if (pin) {
|
||||
/* It's a physical memory address */
|
||||
|
@ -1249,12 +1247,19 @@ static bool do_page_fault(void *addr, bool pin)
|
|||
pf = z_phys_to_page_frame(phys);
|
||||
pf->flags |= Z_PAGE_FRAME_PINNED;
|
||||
}
|
||||
/* We raced before locking IRQs, re-try */
|
||||
|
||||
/* This if-block is to pin the page if it is
|
||||
* already present in physical memory. There is
|
||||
* no need to go through the following code to
|
||||
* pull in the data pages. So skip to the end.
|
||||
*/
|
||||
goto out;
|
||||
}
|
||||
__ASSERT(status == ARCH_PAGE_LOCATION_PAGED_OUT,
|
||||
"unexpected status value %d", status);
|
||||
|
||||
paging_stats_faults_inc(faulting_thread, key);
|
||||
|
||||
pf = free_page_frame_list_get();
|
||||
if (pf == NULL) {
|
||||
/* Need to evict a page frame */
|
||||
|
|
Loading…
Reference in a new issue