babatengwo 发表于 2014-11-11 10:04

NR_FILE_PAGES统计哪些内存

各位大侠,问一下zone_stat_item中,NR_FILE_PAGES是对哪些内存的统计?

enum zone_stat_item {
        /* First 128 byte cacheline (assuming 64 bit words) */
        NR_FREE_PAGES,
        NR_LRU_BASE,
        NR_INACTIVE_ANON = NR_LRU_BASE, /* must match order of LRU_ACTIVE */
        NR_ACTIVE_ANON,                /*"   "   "   "       "         */
        NR_INACTIVE_FILE,        /*"   "   "   "       "         */
        NR_ACTIVE_FILE,                /*"   "   "   "       "         */
        NR_UNEVICTABLE,                /*"   "   "   "       "         */
        NR_MLOCK,                /* mlock()ed pages found and moved off LRU */
        NR_ANON_PAGES,        /* Mapped anonymous pages */
        NR_FILE_MAPPED,        /* pagecache pages mapped into pagetables.
                           only modified from process context */
        NR_FILE_PAGES,
        NR_FILE_DIRTY,
        NR_WRITEBACK,
        NR_SLAB_RECLAIMABLE,
      ......
}

Tinnal 发表于 2014-11-11 21:45

回复 1# babatengwo

文件使用的page cache的数量。/**
* add_to_page_cache - add newly allocated pagecache pages
* @page:        page to add
* @mapping:        the page's address_space
* @offset:        page index
* @gfp_mask:        page allocation mode
*
* This function is used to add newly allocated pagecache pages;
* the page is new, so we can just run SetPageLocked() against it.
* The other page state flags were set by rmqueue().
*
* This function does not add the page to the LRU.The caller must do that.
*/
int add_to_page_cache(struct page *page, struct address_space *mapping,
                pgoff_t offset, gfp_t gfp_mask)
{
        int error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM);

        if (error == 0) {
                write_lock_irq(&mapping->tree_lock);
                error = radix_tree_insert(&mapping->page_tree, offset, page);
                if (!error) {
                        page_cache_get(page);
                        SetPageLocked(page);
                        page->mapping = mapping;
                        page->index = offset;
                        mapping->nrpages++;
                        __inc_zone_page_state(page, NR_FILE_PAGES);
                }
                write_unlock_irq(&mapping->tree_lock);
                radix_tree_preload_end();
        }
        return error;
}
页: [1]
查看完整版本: NR_FILE_PAGES统计哪些内存