page replacement policy in the latest Linux kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I'm trying to understand the page replacement policy in the latest Linux kernel and reimplement a similar one in the user space.
As far as I can understand from ULK and the code, there are two lists: active list and inactive list.
Here I only consider the case of the *page cache*:
When a page is added to the page cache (by add_to_page_cache_lru), it is also added to the inactive list and its reference bit is set (by mark_page_accessed).
When a page is accessed again, it is added to the active list and the reference bit is cleared (by mark_page_accessed).
When a page is accessed and it's in the active list, the reference bit is set if it's not set (by mark_page_accessed).

When the system is out of free pages, it starts to shrink the cache.
When a page is in the active list, if the page hasn't been referenced for a period of time (page_referenced() returns 0, and for the pages in the page cache, it's always 0), it will be moved to the inactive list (in shrink_active_list);
When a page is in the inactive list, if the page hasn't been referenced (it's always true for pages in the page cache), reclaim the page (in shrink_inactive_list);
When the system is out of free pages, it always starts to reclaim pages in the inactive list first, unless the number of pages in the active list is larger than that in the inactive list.

Please correct me if any part is wrong for the page cache.

Thanks,
Da
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux