码迷,mamicode.com
首页 > 其他好文 > 详细

匿名内存

时间:2018-04-24 11:05:15      阅读:415      评论:0      收藏:0      [点我收藏+]

标签:state   命名   with   out   apc   static   col   like   delete   

page_is_file_cache是和swapbacked互斥的,所以说对于匿名页来说,分配的时候就就会把PageSwapBacked给设置上,page->mapping_address = 0x1

swap_backed和page->mapping_address貌似是重复的呢?感觉swapbacked是page->mapping_adddress的超集。

/**
 * page_is_file_cache - should the page be on a file LRU or anon LRU?
 * @page: the page to test
 *
 * Returns 1 if @page is page cache page backed by a regular filesystem,
 * or 0 if @page is anonymous, tmpfs or otherwise ram or swap backed.
 * Used by functions that manipulate the LRU lists, to sort a page
 * onto the right LRU list.
 *
 * We would like to get this info without a page flag, but the state
 * needs to survive until the page is last deleted from the LRU, which
 * could be as far down as __page_cache_release.
 */
static inline int page_is_file_cache(struct page *page)
{
    return !PageSwapBacked(page);
}

 

是所有的匿名的内存,

普通的文件在普通的address_space,swap 的命名空间中保存着要被swap出去的页,还有将要被读出来的页。普通情况下匿名页是没有东西的在里面的。

swapbacked什么时候设置:在读之前设置,[只对shmem有用]

swapcache什么时候设置

backed还有swapcache的都是用来判断的:

 

share memory什么情况下都不会回收么?看函数:shmem_writepage

正常情况下:

add_to_swap --> add_to_swap_cache

什么时候清呢?

目前看只有一个地方是是shrink_page_list ---> add_to_swap

        if (PageAnon(page) && !PageSwapCache(page)) {
            if (!(sc->gfp_mask & __GFP_IO))
                goto keep_locked;
            if (!add_to_swap(page, page_list))
                goto activate_locked;
            lazyfree = true;
            may_enter_fs = 1;

            /* Adding to swap updated mapping */
            mapping = page_mapping(page);
        } else if (unlikely(PageTransHuge(page))) {
            /* Split file THP */
           if (split_huge_page_to_list(page, page_list))
                goto keep_locked;
        }
设置swapCache的地方是:SetPageSwapCache:
1):  __add_to_swap_cache

2):  shmem_replace_page

3): 

// 所以知道了,一个page刚被申请出来的时候,仅仅是放在了

匿名内存

标签:state   命名   with   out   apc   static   col   like   delete   

原文地址:https://www.cnblogs.com/honpey/p/8926175.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!