This adds a new kconfig for eviction algorithm which needs page tracking. When enabled, k_mem_paging_eviction_add()/_remove() and k_mem_paging_eviction_accessed() must be implemented. If an algorithm does not do page tracking, there is no need to implement these functions, and no need for the kernel MMU code to call into empty functions. This should save a few function calls and some CPU cycles. Note that arm64 unconditionally calls those functions so forces CONFIG_EVICTION_TRACKING to be enabled there. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
62 lines
2.1 KiB
Plaintext
62 lines
2.1 KiB
Plaintext
# Copyright (c) 2020 Intel Corporation
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# Demand paging sample eviction algorithms
|
|
|
|
choice EVICTION_CHOICE
|
|
prompt "Page frame eviction algorithms"
|
|
default EVICTION_LRU if ARM64
|
|
default EVICTION_NRU
|
|
depends on DEMAND_PAGING
|
|
|
|
config EVICTION_CUSTOM
|
|
bool "Custom eviction algorithm"
|
|
imply EVICTION_TRACKING
|
|
help
|
|
This option is chosen when the eviction algorithm will be implemented
|
|
by the application, instead of using one included in Zephyr.
|
|
|
|
config EVICTION_NRU
|
|
bool "Not Recently Used (NRU) page eviction algorithm"
|
|
help
|
|
This implements a Not Recently Used page eviction algorithm.
|
|
A periodic timer will clear the accessed state of all virtual pages.
|
|
When a page frame needs to be evicted, the algorithm will prefer to
|
|
evict page frames using an ascending order of priority:
|
|
|
|
- recently accessed, dirty
|
|
- recently accessed, clean
|
|
- not recently accessed, dirty
|
|
- not recently accessed, clean
|
|
|
|
config EVICTION_LRU
|
|
bool "Least Recently Used (LRU) page eviction algorithm"
|
|
select EVICTION_TRACKING
|
|
help
|
|
This implements a Least Recently Used page eviction algorithm.
|
|
Usage is tracked based on MMU protection making pages unaccessible
|
|
and causing a fault when actually used, using such event to reorder
|
|
the page eviction queue. This is more efficient than the NRU
|
|
algorithm: all operations are O(1), the accessed flag is cleared on
|
|
one page at a time and only when there is a page eviction request.
|
|
|
|
endchoice
|
|
|
|
if EVICTION_NRU
|
|
config EVICTION_NRU_PERIOD
|
|
int "Recently accessed period, in milliseconds"
|
|
default 100
|
|
help
|
|
A periodic timer will fire that clears the accessed state of all virtual
|
|
pages that are capable of being paged out. At eviction time, if a page
|
|
still has the accessed property, it will be considered as recently used.
|
|
endif # EVICTION_NRU
|
|
|
|
config EVICTION_TRACKING
|
|
bool
|
|
depends on ARCH_SUPPORTS_EVICTION_TRACKING
|
|
help
|
|
Selected by eviction algorithms which needs page tracking and need to
|
|
implement the following functions: k_mem_paging_eviction_add(),
|
|
k_mem_paging_eviction_remove() and k_mem_paging_eviction_accessed().
|