- 论坛徽章:
- 0
|
linux pte 的L_PTE_YOUNG作用
看了下代码,发现只有在确页异常anon ,file map, 分配page的时候才会至位。
然后,在pfra中,page _check_reference回收anon page,file page的时候会看page相应的young pte数目。并且清除相应的pte的young标志。
假设没有swap的话,那么只要page没有young的pte,而不管page的PAGE_REFERENCED标志,page就肯定会被释放(或者active 到 inactive lru)
那么,young标志是否是一次性标志呢?真没有其他地方设置了?
假设 young标志不会再设置了。对于anon,filemap的page,如果在用户态多次访问,kernel如何知道他是被多次访问的,而不应该释放掉?
static enum page_references page_check_references(struct page *page,
struct scan_control *sc)
{
int referenced_ptes, referenced_page;
unsigned long vm_flags;
referenced_ptes = page_referenced(page, 1, sc->mem_cgroup, &vm_flags);
referenced_page = TestClearPageReferenced(page);
/* Lumpy reclaim - ignore references */
if (sc->reclaim_mode & RECLAIM_MODE_LUMPYRECLAIM)
return PAGEREF_RECLAIM;
/*
* Mlock lost the isolation race with us. Let try_to_unmap()
* move the page to the unevictable list.
*/
if (vm_flags & VM_LOCKED)
return PAGEREF_RECLAIM;
if (referenced_ptes) {
if (PageAnon(page))
return PAGEREF_ACTIVATE;
/*
* All mapped pages start out with page table
* references from the instantiating fault, so we need
* to look twice if a mapped file page is used more
* than once.
*
* Mark it and spare it for another trip around the
* inactive list. Another page table reference will
* lead to its activation.
*
* Note: the mark is set for activated pages as well
* so that recently deactivated but used pages are
* quickly recovered.
*/
SetPageReferenced(page);
if (referenced_page)
return PAGEREF_ACTIVATE;
return PAGEREF_KEEP;
}
/* Reclaim if clean, defer dirty pages to writeback */
if (referenced_page && !PageSwapBacked(page))
return PAGEREF_RECLAIM_CLEAN;
return PAGEREF_RECLAIM;
}
|
|