demand_paging: LRU eviction: add missing documentation
Document missing eviction algorithm interface functions, and mention LRU. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
parent
7f1c3d1841
commit
57b2eaa09b
1 changed files with 24 additions and 6 deletions
|
@ -118,12 +118,19 @@ Eviction Algorithm
|
||||||
|
|
||||||
The eviction algorithm is used to determine which data page and its
|
The eviction algorithm is used to determine which data page and its
|
||||||
corresponding page frame can be paged out to free up a page frame
|
corresponding page frame can be paged out to free up a page frame
|
||||||
for the next page in operation. There are two functions which are
|
for the next page in operation. There are four functions which are
|
||||||
called from the kernel paging code:
|
called from the kernel paging code:
|
||||||
|
|
||||||
* :c:func:`k_mem_paging_eviction_init()` is called to initialize
|
* :c:func:`k_mem_paging_eviction_init()` is called to initialize
|
||||||
the eviction algorithm. This is called at ``POST_KERNEL``.
|
the eviction algorithm. This is called at ``POST_KERNEL``.
|
||||||
|
|
||||||
|
* :c:func:`k_mem_paging_eviction_add()` is called each time a data page becomes
|
||||||
|
eligible for future eviction.
|
||||||
|
|
||||||
|
* :c:func:`k_mem_paging_eviction_remove()` is called when a data page is no
|
||||||
|
longer eligible for eviction. This may happen if the given data page becomes
|
||||||
|
pinned, gets unmapped or is about to be evicted.
|
||||||
|
|
||||||
* :c:func:`k_mem_paging_eviction_select()` is called to select
|
* :c:func:`k_mem_paging_eviction_select()` is called to select
|
||||||
a data page to evict. A function argument ``dirty`` is written to
|
a data page to evict. A function argument ``dirty`` is written to
|
||||||
signal the caller whether the selected data page has been modified
|
signal the caller whether the selected data page has been modified
|
||||||
|
@ -133,12 +140,23 @@ called from the kernel paging code:
|
||||||
The function returns a pointer to the page frame corresponding to
|
The function returns a pointer to the page frame corresponding to
|
||||||
the selected data page.
|
the selected data page.
|
||||||
|
|
||||||
Currently, a NRU (Not-Recently-Used) eviction algorithm has been
|
There is one additional function which is called by the architecture's memory
|
||||||
implemented as a sample. This is a very simple algorithm which
|
management code to flag data pages when they trigger an access fault:
|
||||||
ranks each data page on whether they have been accessed and modified.
|
:c:func:`k_mem_paging_eviction_accessed()`. This is used by the LRU algorithm
|
||||||
The selection is based on this ranking.
|
to requeue "used" pages.
|
||||||
|
|
||||||
To implement a new eviction algorithm, the two functions mentioned
|
Two eviction algorithms are currently available:
|
||||||
|
|
||||||
|
* An NRU (Not-Recently-Used) eviction algorithm has been implemented as a
|
||||||
|
sample. This is a very simple algorithm which ranks data pages on whether
|
||||||
|
they have been accessed and modified. The selection is based on this ranking.
|
||||||
|
|
||||||
|
* An LRU (Least-Recently-Used) eviction algorithm is also available. It is
|
||||||
|
based on a sorted queue of data pages. The LRU code is more complex compared
|
||||||
|
to the NRU code but also considerably more efficient. This is recommended for
|
||||||
|
production use.
|
||||||
|
|
||||||
|
To implement a new eviction algorithm, the five functions mentioned
|
||||||
above must be implemented.
|
above must be implemented.
|
||||||
|
|
||||||
Backing Store
|
Backing Store
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue