Skip to content
This repository has been archived by the owner on Mar 2, 2022. It is now read-only.

Running other page eviction policies #24

Open
Boon-Jun opened this issue Mar 18, 2021 · 2 comments
Open

Running other page eviction policies #24

Boon-Jun opened this issue Mar 18, 2021 · 2 comments

Comments

@Boon-Jun
Copy link

Hi @lastweek . Thank you so much for your help last time.

After reading the paper on LegoOS and learning about the different page eviction policies available, I wanted to try them out too, but I'm unable to find their implementation in the source code of this repository.

May I ask whether if the implementation exists for us to play with?

@lastweek
Copy link
Contributor

Hi,

You can look up https://github.com/WukLab/LegoOS/blob/master/managers/processor/pcache/evict_lru.c#L293.
This kernel thread will walk through pcache set, within each set, it looks at reference bit and adjust the list (LRU).

if you want to change policies, i suggest you start from modifying sweep_pset(). Watch out for those flags.. this code is very very racy (there might be concurrent pgfaults, mmap, munmap etc).

@Boon-Jun
Copy link
Author

Boon-Jun commented Mar 31, 2021

Hi @lastweek.
Thank you for the reply last time. So I did a simple manual tracing of the code related to lru allocation & eviction, and this is how I currently understand it at a high level.

  1. The allocation of a cache line is recorded within the cache set by adding it to the head of its lru list.
  2. Accessing an existing cache line does not modify the lru list, and the order within the lru list stays the same.
  3. Background thread sweeps through all cache sets and their respective lru lists in fixed time intervals, and if any cache line in the lru list has not been accessed for a while, move it to the back of the lru list.
  4. When an eviction is required, start iterating from the back of the lru list to find a cache line that can be evicted.

May I know whether if my interpretation of the allocation & eviction is right? And if so, does disabling the background thread means the OS no longer moves the least recently accessed cache line to the back of the lru list and what we have is something similar to a FIFO page eviction?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants