1# Copyright (c) 2020 Intel Corporation
2# SPDX-License-Identifier: Apache-2.0
3#
4# Demand paging sample eviction algorithms
5
6choice EVICTION_CHOICE
7	prompt "Page frame eviction algorithms"
8	default EVICTION_LRU if ARM64
9	default EVICTION_NRU
10	depends on DEMAND_PAGING
11
12config EVICTION_CUSTOM
13	bool "Custom eviction algorithm"
14	imply EVICTION_TRACKING
15	help
16	  This option is chosen when the eviction algorithm will be implemented
17	  by the application, instead of using one included in Zephyr.
18
19config EVICTION_NRU
20	bool "Not Recently Used (NRU) page eviction algorithm"
21	help
22	  This implements a Not Recently Used page eviction algorithm.
23	  A periodic timer will clear the accessed state of all virtual pages.
24	  When a page frame needs to be evicted, the algorithm will prefer to
25	  evict page frames using an ascending order of priority:
26
27	   - recently accessed, dirty
28	   - recently accessed, clean
29	   - not recently accessed, dirty
30	   - not recently accessed, clean
31
32config EVICTION_LRU
33	bool "Least Recently Used (LRU) page eviction algorithm"
34	select EVICTION_TRACKING
35	help
36	  This implements a Least Recently Used page eviction algorithm.
37	  Usage is tracked based on MMU protection making pages unaccessible
38	  and causing a fault when actually used, using such event to reorder
39	  the page eviction queue. This is more efficient than the NRU
40	  algorithm: all operations are O(1), the accessed flag is cleared on
41	  one page at a time and only when there is a page eviction request.
42
43endchoice
44
45if EVICTION_NRU
46config EVICTION_NRU_PERIOD
47	int "Recently accessed period, in milliseconds"
48	default 100
49	help
50	  A periodic timer will fire that clears the accessed state of all virtual
51	  pages that are capable of being paged out. At eviction time, if a page
52	  still has the accessed property, it will be considered as recently used.
53endif # EVICTION_NRU
54
55config EVICTION_TRACKING
56	bool
57	depends on ARCH_SUPPORTS_EVICTION_TRACKING
58	help
59	  Selected by eviction algorithms which needs page tracking and need to
60	  implement the following functions: k_mem_paging_eviction_add(),
61	  k_mem_paging_eviction_remove() and k_mem_paging_eviction_accessed().
62