Skip to content

Commit 8cabd9a

Browse files
committed
x86: mmu/demand_paging: supports LRU eviction algorithm
The LRU (Least Recently Used) requires additional accounting. So add the code for that. Fixes #75132 Signed-off-by: Daniel Leung <[email protected]>
1 parent e21f073 commit 8cabd9a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

arch/x86/core/fatal.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#include <mmu.h>
1414
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
1515

16+
#ifdef CONFIG_DEMAND_PAGING
17+
#include <zephyr/kernel/mm/demand_paging.h>
18+
#endif
19+
1620
#if defined(CONFIG_BOARD_QEMU_X86) || defined(CONFIG_BOARD_QEMU_X86_64)
1721
FUNC_NORETURN void arch_system_halt(unsigned int reason)
1822
{
@@ -476,6 +480,20 @@ void z_x86_page_fault_handler(struct arch_esf *esf)
476480
#endif /* CONFIG_X86_KPTI */
477481
if (was_valid_access) {
478482
/* Page fault handled, re-try */
483+
484+
#ifdef CONFIG_EVICTION_LRU
485+
/* Currently only LRU eviction algorithm needs to be marked.
486+
* So for now, skip it for others to avoid unnecessary
487+
* processing.
488+
*/
489+
uintptr_t phys, ret;
490+
491+
ret = arch_page_info_get(virt, &phys, false);
492+
if ((ret & ARCH_DATA_PAGE_NOT_MAPPED) != ARCH_DATA_PAGE_NOT_MAPPED) {
493+
k_mem_paging_eviction_accessed(phys);
494+
}
495+
#endif
496+
479497
return;
480498
}
481499
}

0 commit comments

Comments
 (0)