zoukankan      html  css  js  c++  java
  • 匿名内存 | shm

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

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

    今天和公司的内存管理的专家求教,原来系统的swapback包括shm,包括匿名页等等;而shm并不属于匿名页,匿名页刚分配出来就被设置上swapbacked啦。

    shm内存增加内存的统计量是:

     580         __mod_node_page_state(page_pgdat(page), NR_FILE_PAGES, nr);
     581         __mod_node_page_state(page_pgdat(page), NR_SHMEM, nr);
     

    /**
     * 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刚被申请出来的时候,仅仅是放在了

  • 相关阅读:
    [bzoj1468]Tree(点分治)
    [bzoj1087]: [SCOI2005]互不侵犯King(状压dp)
    [hdu5628]Clarke and math(dirichlet卷积)
    [bzoj1036]:[ZJOI2008]树的统计Count(树链剖分)
    [bzoj1026][SCOI2009]windy数(前缀和+数位dp)
    洛谷 P1714 切蛋糕(dp+RMQ)
    [hdu3507] Print Article
    [bzoj1597]: [Usaco2008 Mar]土地购买
    php基础二
    php基础
  • 原文地址:https://www.cnblogs.com/honpey/p/8926175.html
Copyright © 2011-2022 走看看