referenced = page_referenced(page, 1);
/* In active use or really unfreeable? Activate it. */
if (sc->order <= PAGE_ALLOC_COSTLY_ORDER &&
referenced && page_mapping_inuse(page))
goto activate_locked;
/* Called without lock on whether page is mapped, so answer is unstable */
static inline int page_mapping_inuse(struct page *page)
{
struct address_space *mapping;
/* Page is in somebody's page tables. */
if (page_mapped(page))
return 1;
/* Be more reluctant to reclaim swapcache than pagecache */
if (PageSwapCache(page))
return 1;
mapping = page_mapping(page);
if (!mapping)
return 0;
/* File is mmap'd by somebody? */
return mapping_mapped(mapping);
}
更重要的一个问题:
if (page_test_and_clear_young(page_to_pfn(page)))
referenced++;
这个page_test_and_clear_young方法我查了下只有s390上才有定义的。其他架构上都是noop。英文我不太看的懂,你可以看下,貌似说s390的pte跟一般的不一样什么的。还请看了之后,指教指教我啊。
更重要的一个问题:
if (page_test_and_clear_young(page_to_pfn(page)))
referenced++;
这个page_test_and_clear_young方法我查了下只有s390上才有定义的。其他架构上都是noop。英文我不太看的懂,你可以看下,貌似说s390的pte跟一般的不一样什么的。还请看了之后,指教指教我啊。
-------------------------------------------------------------------------------------------------
int page_referenced(struct page *page,
int is_locked,
struct mem_cgroup *mem_cont,
unsigned long *vm_flags)
{
int referenced = 0;
int we_locked = 0;
*vm_flags = 0;
if (page_mapped(page) && page_rmapping(page)) { //下面都没用了。对于read系统调用产生的cache.buffer
if (!is_locked && (!PageAnon(page) || PageKsm(page))) {
we_locked = trylock_page(page);
if (!we_locked) {
referenced++;
goto out;
}
}
if (unlikely(PageKsm(page)))
referenced += page_referenced_ksm(page, mem_cont,
vm_flags);
else if (PageAnon(page))
referenced += page_referenced_anon(page, mem_cont,
vm_flags);
else if (page->mapping) //我说的read系统调用出来的buffer/cache, page_mapped(page)都没有成立,肯定不会走了。
referenced += page_referenced_file(page, mem_cont,
vm_flags);
if (we_locked)
unlock_page(page);
}
out:
if (page_test_and_clear_young(page))
referenced++;
anon page直接就在 active list中,一般系统比较少才能调用到shrink_active_list,更突出了它的重要性。
你的帖子ubuntu为什么free内存这么少,其实就是buffer/cache很多,加进来的释放的主要都是cache,shrink_active_list调用比较少。
anon page直接就在 active list中,一般系统比较少才能调用到shrink_active_list,更突出了它的重要性。
你的帖子ubuntu为什么free内存这么少,其实就是buffer/cache很多,加进来的释放的主要都是cache,shrink_active_list调用比较少。