内存回收
void mark_page_accessed(struct page *page)
{
page = compound_head(page);
if (!PageActive(page) && !PageUnevictable(page) &&
PageReferenced(page)) {
/*
* If the page is on the LRU, queue it for activation via
* activate_page_pvecs. Otherwise, assume the page is on a
* pagevec, mark it active and it'll be moved to the active
* LRU on the next drain.
*/
if (PageLRU(page))
activate_page(page);
else
__lru_cache_activate_page(page);
ClearPageReferenced(page);
workingset_activation(page);
} else if (!PageReferenced(page)) {
SetPageReferenced(page);
}
if (page_is_idle(page))
clear_page_idle(page);
}
页面加入lru时调用的是 lru_cache_add
,per cpu保存了lruvec作为缓存,以减少访问全局lru产生的竞争,当page加入per cpu的lruvec时,是不立即设置LRU标志位的,所以要判断PageLRU以决定直接移动page到active lru还是标记一下active,推迟到下次批量处理lruvec时再移动。