If only 2 page frames are queued and code executing in one frame is
making an access to memory in the second frame then the access will trap
and k_mem_paging_eviction_accessed() will be called to move that frame
to the end of the queue ... marking the new head frame unaccessible.
But that newly unaccessible frame contains the code that has yet to be
resumed to perform its memory access. Since it is now unaccessible, a
trap is triggered, the frame is moved to the end of the queue and the
new head frame (the one we trapped for initially) is marked unaccessible.
Execution is resumed with the memory access which is unaccessible again
and the cycle repeats infinitely.
Fix this by not marking the new head unaccessible if there is only one
queued frame left in the queue.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The first page frame index was reserved for head and tail ^pointers.
However there are cases where the first frame is actually made
evictable and would trigger the assertion guarding against that.
Fix this by applying an offset to actual frame indexes.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This is a O(1) LRU eviction algorithm. A bit more complex but way more
scalable than the NRU algorithm.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>