mm: move most file-based accounting to the node
Subsystems (19)
[email protected]
maintainerPATCH 36/101 mm: move most file-based accounting to the node
From: Mel Gorman <[email protected]>
Subject: mm: move most file-based accounting to the node
There are now a number of accounting oddities such as mapped file pages being accounted for on the node while the total number of file pages are accounted on the zone. This can be coped with to some extent but it's confusing so this patch moves the relevant file-based accounted. Due to throttling logic in the page allocator for reliable OOM detection, it is still necessary to track dirty and writeback pages on a per-zone basis.
[[email protected]: fix NR_ZONE_WRITE_PENDING accounting]
Signed-off-by Mel Gorman <[email protected]>
Acked-by Vlastimil Babka <[email protected]>
Acked-by Michal Hocko <[email protected]>
Cc Hillf Danton <[email protected]>
Acked-by Johannes Weiner <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Rik van Riel <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
arch/s390/appldata/appldata_mem.c | 2 arch/tile/mm/pgtable.c | 8 - drivers/base/node.c | 16 +-- drivers/staging/android/lowmemorykiller.c | 4 drivers/staging/lustre/lustre/osc/osc_cache.c | 6 - fs/fs-writeback.c | 4 fs/fuse/file.c | 8 - fs/nfs/internal.h | 2 fs/nfs/write.c | 2 fs/proc/meminfo.c | 16 +-- include/linux/mmzone.h | 19 ++-- include/trace/events/writeback.h | 6 - mm/filemap.c | 12 +- mm/huge_memory.c | 4 mm/khugepaged.c | 6 - mm/migrate.c | 14 +-- mm/page-writeback.c | 47 ++++------ mm/page_alloc.c | 74 ++++++---------- mm/rmap.c | 10 +- mm/shmem.c | 14 +-- mm/swap_state.c | 4 mm/util.c | 4 mm/vmscan.c | 16 +-- mm/vmstat.c | 19 ++-- 24 files changed, 155 insertions(+), 162 deletions(-)
arch/s390/appldata/appldata_mem.c renamed from arch/s390/appldata/appldata_mem.c~mm-move-most-file-based-accounting-to-the-node +1 -1
@@ -102,7 +102,7 @@ static void appldata_get_mem_data(void * mem_data->totalhigh =P2K (val.totalhigh); mem_data->freehigh =P2K (val.freehigh); mem_data->bufferram =P2K (val.bufferram); - mem_data->cached =P2K (global_page_state (NR_FILE_PAGES ) + mem_data->cached =P2K (global_node_page_state (NR_FILE_PAGES ) - val.bufferram);si_swapinfo (&val);
arch/tile/mm/pgtable.c renamed from arch/tile/mm/pgtable.c~mm-move-most-file-based-accounting-to-the-node +4 -4
@@ -49,16 +49,16 @@ void show_mem(unsigned int filter) global_node_page_state(NR_ACTIVE_FILE)), (global_node_page_state (NR_INACTIVE_ANON ) +global_node_page_state (NR_INACTIVE_FILE )), -global_page_state (NR_FILE_DIRTY ), -global_page_state (NR_WRITEBACK ), -global_page_state (NR_UNSTABLE_NFS ), +global_node_page_state (NR_FILE_DIRTY ), +global_node_page_state (NR_WRITEBACK ), +global_node_page_state (NR_UNSTABLE_NFS ),global_page_state (NR_FREE_PAGES ), (global_page_state (NR_SLAB_RECLAIMABLE ) +global_page_state (NR_SLAB_UNRECLAIMABLE )),global_node_page_state (NR_FILE_MAPPED ),global_page_state (NR_PAGETABLE ),global_page_state (NR_BOUNCE ), -global_page_state (NR_FILE_PAGES ), +global_node_page_state (NR_FILE_PAGES ), get_nr_swap_pages());for_each_zone (zone) {
drivers/base/node.c renamed from drivers/base/node.c~mm-move-most-file-based-accounting-to-the-node +8 -8
@@ -118,28 +118,28 @@ static ssize_t node_read_meminfo(struct"Node %d ShmemPmdMapped: %8lu kB\n" #endif , - nid,K (sum_zone_node_page_state (nid,NR_FILE_DIRTY )), - nid,K (sum_zone_node_page_state (nid,NR_WRITEBACK )), - nid,K (sum_zone_node_page_state (nid,NR_FILE_PAGES )), + nid,K (node_page_state (pgdat,NR_FILE_DIRTY )), + nid,K (node_page_state (pgdat,NR_WRITEBACK )), + nid,K (node_page_state (pgdat,NR_FILE_PAGES )), nid,K (node_page_state (pgdat,NR_FILE_MAPPED )), nid,K (node_page_state (pgdat,NR_ANON_MAPPED )), nid,K (i.sharedram), nid,sum_zone_node_page_state (nid,NR_KERNEL_STACK ) *THREAD_SIZE /1024 , nid,K (sum_zone_node_page_state (nid,NR_PAGETABLE )), - nid,K (sum_zone_node_page_state (nid,NR_UNSTABLE_NFS )), + nid,K (node_page_state (pgdat,NR_UNSTABLE_NFS )), nid,K (sum_zone_node_page_state (nid,NR_BOUNCE )), - nid,K (sum_zone_node_page_state (nid,NR_WRITEBACK_TEMP )), + nid,K (node_page_state (pgdat,NR_WRITEBACK_TEMP )), nid,K (sum_zone_node_page_state (nid,NR_SLAB_RECLAIMABLE ) +sum_zone_node_page_state (nid,NR_SLAB_UNRECLAIMABLE )), nid,K (sum_zone_node_page_state (nid,NR_SLAB_RECLAIMABLE )), #ifdef CONFIG_TRANSPARENT_HUGEPAGE nid,K (sum_zone_node_page_state (nid,NR_SLAB_UNRECLAIMABLE )), - nid,K (sum_zone_node_page_state (nid,NR_ANON_THPS ) * + nid,K (node_page_state (pgdat,NR_ANON_THPS ) *HPAGE_PMD_NR ), - nid,K (sum_zone_node_page_state (nid,NR_SHMEM_THPS ) * + nid,K (node_page_state (pgdat,NR_SHMEM_THPS ) *HPAGE_PMD_NR ), - nid,K (sum_zone_node_page_state (nid,NR_SHMEM_PMDMAPPED ) * + nid,K (node_page_state (pgdat,NR_SHMEM_PMDMAPPED ) * HPAGE_PMD_NR));#else nid, K(sum_zone_node_page_state(nid, NR_SLAB_UNRECLAIMABLE)));
drivers/staging/android/lowmemorykiller.c renamed from drivers/staging/android/lowmemorykiller.c~mm-move-most-file-based-accounting-to-the-node +2 -2
@@ -91,8 +91,8 @@ static unsigned long lowmem_scan(structshort selected_oom_score_adj;int array_size =ARRAY_SIZE (lowmem_adj);int other_free =global_page_state (NR_FREE_PAGES ) - totalreserve_pages; -int other_file =global_page_state (NR_FILE_PAGES ) - -global_page_state (NR_SHMEM ) - +int other_file =global_node_page_state (NR_FILE_PAGES ) - +global_node_page_state (NR_SHMEM ) -total_swapcache_pages ();if (lowmem_adj_size < array_size)
drivers/staging/lustre/lustre/osc/osc_cache.c renamed from drivers/staging/lustre/lustre/osc/osc_cache.c~mm-move-most-file-based-accounting-to-the-node +4 -2
@@ -1864,7 +1864,8 @@ void osc_dec_unstable_pages(struct ptlrpLASSERT (page_count >=0 );for (i =0 ; i < page_count; i++) -dec_zone_page_state (desc->bd_iov[i].kiov_page,NR_UNSTABLE_NFS ); +dec_node_page_state (desc->bd_iov[i].kiov_page, +NR_UNSTABLE_NFS );atomic_sub (page_count, &cli->cl_cache->ccc_unstable_nr);LASSERT (atomic_read (&cli->cl_cache->ccc_unstable_nr) >=0 );
@@ -1898,7 +1899,8 @@ void osc_inc_unstable_pages(struct ptlrpLASSERT (page_count >=0 );for (i =0 ; i < page_count; i++) -inc_zone_page_state (desc->bd_iov[i].kiov_page,NR_UNSTABLE_NFS ); +inc_node_page_state (desc->bd_iov[i].kiov_page, +NR_UNSTABLE_NFS );LASSERT (atomic_read (&cli->cl_cache->ccc_unstable_nr) >=0 );atomic_add (page_count, &cli->cl_cache->ccc_unstable_nr);
fs/fs-writeback.c renamed from fs/fs-writeback.c~mm-move-most-file-based-accounting-to-the-node +2 -2
@@ -1807,8 +1807,8 @@ static struct wb_writeback_work *get_nex*/ static unsigned long get_nr_dirty_pages (void ) { -return global_page_state (NR_FILE_DIRTY ) + -global_page_state (NR_UNSTABLE_NFS ) + +return global_node_page_state (NR_FILE_DIRTY ) + +global_node_page_state (NR_UNSTABLE_NFS ) +get_nr_dirty_inodes (); }
fs/fuse/file.c renamed from fs/fuse/file.c~mm-move-most-file-based-accounting-to-the-node +4 -4
@@ -1452,7 +1452,7 @@ static void fuse_writepage_finish(structlist_del (&req->writepages_entry);for (i =0 ; i < req->num_pages; i++) {dec_wb_stat (&bdi->wb,WB_WRITEBACK ); -dec_zone_page_state (req->pages[i],NR_WRITEBACK_TEMP ); +dec_node_page_state (req->pages[i],NR_WRITEBACK_TEMP );wb_writeout_inc (&bdi->wb); }wake_up (&fi->page_waitq);
@@ -1642,7 +1642,7 @@ static int fuse_writepage_locked(struct req->inode = inode;inc_wb_stat (&inode_to_bdi (inode)->wb,WB_WRITEBACK ); -inc_zone_page_state (tmp_page,NR_WRITEBACK_TEMP ); +inc_node_page_state (tmp_page,NR_WRITEBACK_TEMP );spin_lock (&fc->lock);list_add (&req->writepages_entry, &fi->writepages);
@@ -1756,7 +1756,7 @@ static bool fuse_writepage_in_flight(strspin_unlock (&fc->lock);dec_wb_stat (&bdi->wb,WB_WRITEBACK ); -dec_zone_page_state (page,NR_WRITEBACK_TEMP ); +dec_node_page_state (page,NR_WRITEBACK_TEMP );wb_writeout_inc (&bdi->wb);fuse_writepage_free (fc, new_req);fuse_request_free (new_req);
@@ -1855,7 +1855,7 @@ static int fuse_writepages_fill(struct p req->page_descs[req->num_pages].length =PAGE_SIZE ;inc_wb_stat (&inode_to_bdi (inode)->wb,WB_WRITEBACK ); -inc_zone_page_state (tmp_page,NR_WRITEBACK_TEMP ); +inc_node_page_state (tmp_page,NR_WRITEBACK_TEMP ); err =0 ;if (is_writeback &&fuse_writepage_in_flight (req, page)) {
fs/nfs/internal.h renamed from fs/nfs/internal.h~mm-move-most-file-based-accounting-to-the-node +1 -1
@@ -623,7 +623,7 @@ void nfs_mark_page_unstable(struct pageif (!cinfo->dreq) {struct inode *inode =page_file_mapping (page)->host; -inc_zone_page_state (page,NR_UNSTABLE_NFS ); +inc_node_page_state (page,NR_UNSTABLE_NFS );inc_wb_stat (&inode_to_bdi (inode)->wb,WB_RECLAIMABLE );__mark_inode_dirty (inode,I_DIRTY_DATASYNC ); }
fs/nfs/write.c renamed from fs/nfs/write.c~mm-move-most-file-based-accounting-to-the-node +1 -1
@@ -898,7 +898,7 @@ nfs_mark_request_commit(struct nfs_pagestatic void nfs_clear_page_commit (struct page *page) { -dec_zone_page_state (page,NR_UNSTABLE_NFS ); +dec_node_page_state (page,NR_UNSTABLE_NFS );dec_wb_stat (&inode_to_bdi (page_file_mapping (page)->host)->wb,WB_RECLAIMABLE ); }
fs/proc/meminfo.c renamed from fs/proc/meminfo.c~mm-move-most-file-based-accounting-to-the-node +8 -8
@@ -40,7 +40,7 @@ static int meminfo_proc_show(struct seq_si_swapinfo (&i); committed =percpu_counter_read_positive (&vm_committed_as); - cached =global_page_state (NR_FILE_PAGES ) - + cached =global_node_page_state (NR_FILE_PAGES ) -total_swapcache_pages () - i.bufferram;if (cached <0 ) cached =0 ;
@@ -138,8 +138,8 @@ static int meminfo_proc_show(struct seq_#endif K (i.totalswap),K (i.freeswap), -K (global_page_state (NR_FILE_DIRTY )), -K (global_page_state (NR_WRITEBACK )), +K (global_node_page_state (NR_FILE_DIRTY )), +K (global_node_page_state (NR_WRITEBACK )),K (global_node_page_state (NR_ANON_MAPPED )),K (global_node_page_state (NR_FILE_MAPPED )), K(i.sharedram),
@@ -152,9 +152,9 @@ static int meminfo_proc_show(struct seq_#ifdef CONFIG_QUICKLIST K (quicklist_total_size ()), #endif -K (global_page_state (NR_UNSTABLE_NFS )), +K (global_node_page_state (NR_UNSTABLE_NFS )),K (global_page_state (NR_BOUNCE )), -K (global_page_state (NR_WRITEBACK_TEMP )), +K (global_node_page_state (NR_WRITEBACK_TEMP )),K (vm_commit_limit ()),K (committed), (unsigned long)VMALLOC_TOTAL >> 10,
@@ -164,9 +164,9 @@ static int meminfo_proc_show(struct seq_ , atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)#endif #ifdef CONFIG_TRANSPARENT_HUGEPAGE - , K(global_page_state(NR_ANON_THPS) * HPAGE_PMD_NR) - , K(global_page_state(NR_SHMEM_THPS) * HPAGE_PMD_NR) - , K(global_page_state(NR_SHMEM_PMDMAPPED) * HPAGE_PMD_NR) + , K(global_node_page_state(NR_ANON_THPS) * HPAGE_PMD_NR) + , K(global_node_page_state(NR_SHMEM_THPS) * HPAGE_PMD_NR) + , K(global_node_page_state(NR_SHMEM_PMDMAPPED) * HPAGE_PMD_NR)#endif #ifdef CONFIG_CMA , K(totalcma_pages)
include/linux/mmzone.h renamed from include/linux/mmzone.h~mm-move-most-file-based-accounting-to-the-node +10 -9
@@ -114,21 +114,16 @@ enum zone_stat_item {NR_ZONE_LRU_BASE ,/* Used only for compaction and reclaim retry */ NR_ZONE_LRU_ANON =NR_ZONE_LRU_BASE ,NR_ZONE_LRU_FILE , +NR_ZONE_WRITE_PENDING ,/* Count of dirty, writeback and unstable pages */ NR_MLOCK ,/* mlock()ed pages found and moved off LRU */ -NR_FILE_PAGES , -NR_FILE_DIRTY , -NR_WRITEBACK ,NR_SLAB_RECLAIMABLE ,NR_SLAB_UNRECLAIMABLE ,NR_PAGETABLE ,/* used for pagetables */ NR_KERNEL_STACK ,/* Second 128 byte cacheline */ -NR_UNSTABLE_NFS ,/* NFS unstable pages */ NR_BOUNCE ,NR_VMSCAN_WRITE ,NR_VMSCAN_IMMEDIATE ,/* Prioritise for reclaim when writeback ends */ -NR_WRITEBACK_TEMP ,/* Writeback using temporary buffers */ -NR_SHMEM ,/* shmem pages (included tmpfs/GEM pages) */ NR_DIRTIED ,/* page dirtyings since bootup */ NR_WRITTEN ,/* page writings since bootup */ #if IS_ENABLED(CONFIG_ZSMALLOC)
@@ -142,9 +137,6 @@ enum zone_stat_item {NUMA_LOCAL ,/* allocation from local node */ NUMA_OTHER ,/* allocation from other node */ #endif -NR_ANON_THPS , -NR_SHMEM_THPS , -NR_SHMEM_PMDMAPPED ,NR_FREE_CMA_PAGES , NR_VM_ZONE_STAT_ITEMS };
@@ -164,6 +156,15 @@ enum node_stat_item {NR_ANON_MAPPED ,/* 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_WRITEBACK_TEMP ,/* Writeback using temporary buffers */ +NR_SHMEM ,/* shmem pages (included tmpfs/GEM pages) */ +NR_SHMEM_THPS , +NR_SHMEM_PMDMAPPED , +NR_ANON_THPS , +NR_UNSTABLE_NFS ,/* NFS unstable pages */ NR_VM_NODE_STAT_ITEMS };
include/trace/events/writeback.h renamed from include/trace/events/writeback.h~mm-move-most-file-based-accounting-to-the-node +3 -3
@@ -412,9 +412,9 @@ TRACE_EVENT(global_dirty_state, ),TP_fast_assign ( - __entry->nr_dirty = global_page_state(NR_FILE_DIRTY); - __entry->nr_writeback =global_page_state (NR_WRITEBACK ); - __entry->nr_unstable =global_page_state (NR_UNSTABLE_NFS ); + __entry->nr_dirty = global_node_page_state(NR_FILE_DIRTY); + __entry->nr_writeback =global_node_page_state (NR_WRITEBACK ); + __entry->nr_unstable =global_node_page_state (NR_UNSTABLE_NFS ); __entry->nr_dirtied =global_page_state (NR_DIRTIED ); __entry->nr_written =global_page_state (NR_WRITTEN ); __entry->background_thresh = background_thresh;
mm/filemap.c renamed from mm/filemap.c~mm-move-most-file-based-accounting-to-the-node +6 -6
@@ -218,11 +218,11 @@ void __delete_from_page_cache(struct pag/* hugetlb pages do not participate in page cache accounting. */ if (!PageHuge (page)) -__mod_zone_page_state (page_zone (page),NR_FILE_PAGES , -nr); +__mod_node_page_state (page_pgdat (page),NR_FILE_PAGES , -nr);if (PageSwapBacked (page)) { -__mod_zone_page_state (page_zone (page),NR_SHMEM , -nr); +__mod_node_page_state (page_pgdat (page),NR_SHMEM , -nr);if (PageTransHuge (page)) -__dec_zone_page_state (page,NR_SHMEM_THPS ); +__dec_node_page_state (page,NR_SHMEM_THPS ); }else {VM_BUG_ON_PAGE (PageTransHuge (page) && !PageHuge (page), page); }
@@ -568,9 +568,9 @@ int replace_page_cache_page(struct page* hugetlb pages do not participate in page cache accounting. */ if (!PageHuge (new)) -__inc_zone_page_state (new,NR_FILE_PAGES ); +__inc_node_page_state (new,NR_FILE_PAGES );if (PageSwapBacked (new)) -__inc_zone_page_state (new,NR_SHMEM ); +__inc_node_page_state (new,NR_SHMEM );spin_unlock_irqrestore (&mapping->tree_lock, flags);mem_cgroup_migrate (old, new);radix_tree_preload_end ();
@@ -677,7 +677,7 @@ static int __add_to_page_cache_locked(st/* hugetlb pages do not participate in page cache accounting. */ if (!huge) -__inc_zone_page_state (page,NR_FILE_PAGES ); +__inc_node_page_state (page,NR_FILE_PAGES );spin_unlock_irq (&mapping->tree_lock);if (!huge)mem_cgroup_commit_charge (page, memcg, false, false);
mm/huge_memory.c renamed from mm/huge_memory.c~mm-move-most-file-based-accounting-to-the-node +2 -2
@@ -1586,7 +1586,7 @@ static void __split_huge_pmd_locked(struif (atomic_add_negative (-1 ,compound_mapcount_ptr (page))) {/* Last compound_mapcount is gone. */ -__dec_zone_page_state (page,NR_ANON_THPS ); +__dec_node_page_state (page,NR_ANON_THPS );if (TestClearPageDoubleMap (page)) {/* No need in mapcount reference anymore */ for (i =0 ; i <HPAGE_PMD_NR ; i++)
@@ -2061,7 +2061,7 @@ int split_huge_page_to_list(struct pagelist_del (page_deferred_list (head)); }if (mapping) -__dec_zone_page_state (page,NR_SHMEM_THPS ); +__dec_node_page_state (page,NR_SHMEM_THPS );spin_unlock (&pgdata->split_queue_lock);__split_huge_page (page, list, flags); ret =0 ;
mm/khugepaged.c renamed from mm/khugepaged.c~mm-move-most-file-based-accounting-to-the-node +3 -3
@@ -1483,10 +1483,10 @@ tree_unlocked: }local_irq_save (flags); -__inc_zone_page_state (new_page,NR_SHMEM_THPS ); +__inc_node_page_state (new_page,NR_SHMEM_THPS );if (nr_none) { -__mod_zone_page_state (zone,NR_FILE_PAGES , nr_none); -__mod_zone_page_state (zone,NR_SHMEM , nr_none); +__mod_node_page_state (zone->zone_pgdat,NR_FILE_PAGES , nr_none); +__mod_node_page_state (zone->zone_pgdat,NR_SHMEM , nr_none); }local_irq_restore (flags);
mm/migrate.c renamed from mm/migrate.c~mm-move-most-file-based-accounting-to-the-node +8 -6
@@ -505,15 +505,17 @@ int migrate_page_move_mapping(struct add* are mapped to swap space. */ if (newzone != oldzone) { -__dec_zone_state (oldzone,NR_FILE_PAGES ); -__inc_zone_state (newzone,NR_FILE_PAGES ); +__dec_node_state (oldzone->zone_pgdat,NR_FILE_PAGES ); +__inc_node_state (newzone->zone_pgdat,NR_FILE_PAGES );if (PageSwapBacked (page) && !PageSwapCache (page)) { -__dec_zone_state (oldzone,NR_SHMEM ); -__inc_zone_state (newzone,NR_SHMEM ); +__dec_node_state (oldzone->zone_pgdat,NR_SHMEM ); +__inc_node_state (newzone->zone_pgdat,NR_SHMEM ); }if (dirty &&mapping_cap_account_dirty (mapping)) { -__dec_zone_state (oldzone,NR_FILE_DIRTY ); -__inc_zone_state (newzone,NR_FILE_DIRTY ); +__dec_node_state (oldzone->zone_pgdat,NR_FILE_DIRTY ); +__dec_zone_state (oldzone,NR_ZONE_WRITE_PENDING ); +__inc_node_state (newzone->zone_pgdat,NR_FILE_DIRTY ); +__inc_zone_state (newzone,NR_ZONE_WRITE_PENDING ); } }local_irq_enable ();
mm/page-writeback.c renamed from mm/page-writeback.c~mm-move-most-file-based-accounting-to-the-node +22 -25
111 lines not on this page · raw message
mm/page_alloc.c renamed from mm/page_alloc.c~mm-move-most-file-based-accounting-to-the-node +32 -42
158 lines not on this page · raw message
mm/rmap.c renamed from mm/rmap.c~mm-move-most-file-based-accounting-to-the-node +5 -5
@@ -1213,7 +1213,7 @@ void do_page_add_anon_rmap(struct page ** disabled. */ if (compound) -__inc_zone_page_state (page,NR_ANON_THPS ); +__inc_node_page_state (page,NR_ANON_THPS );__mod_node_page_state (page_pgdat (page),NR_ANON_MAPPED , nr); }if (unlikely (PageKsm (page)))
@@ -1251,7 +1251,7 @@ void page_add_new_anon_rmap(struct pageVM_BUG_ON_PAGE (!PageTransHuge (page), page);/* increment count (starts at -1) */ atomic_set (compound_mapcount_ptr (page),0 ); -__inc_zone_page_state (page,NR_ANON_THPS ); +__inc_node_page_state (page,NR_ANON_THPS ); }else {/* Anon THP always mapped first with PMD */ VM_BUG_ON_PAGE (PageTransCompound (page), page);
@@ -1282,7 +1282,7 @@ void page_add_file_rmap(struct page *pagif (!atomic_inc_and_test (compound_mapcount_ptr (page))) goto out;VM_BUG_ON_PAGE (!PageSwapBacked (page), page); -__inc_zone_page_state (page,NR_SHMEM_PMDMAPPED ); +__inc_node_page_state (page,NR_SHMEM_PMDMAPPED ); }else {if (PageTransCompound (page)) {VM_BUG_ON_PAGE (!PageLocked (page), page);
@@ -1322,7 +1322,7 @@ static void page_remove_file_rmap(structif (!atomic_add_negative (-1 ,compound_mapcount_ptr (page))) goto out;VM_BUG_ON_PAGE (!PageSwapBacked (page), page); -__dec_zone_page_state (page,NR_SHMEM_PMDMAPPED ); +__dec_node_page_state (page,NR_SHMEM_PMDMAPPED ); }else {if (!atomic_add_negative (-1 , &page->_mapcount)) goto out;
@@ -1356,7 +1356,7 @@ static void page_remove_anon_compound_rmif (!IS_ENABLED (CONFIG_TRANSPARENT_HUGEPAGE ))return ; -__dec_zone_page_state (page,NR_ANON_THPS ); +__dec_node_page_state (page,NR_ANON_THPS );if (TestClearPageDoubleMap (page)) {/*
mm/shmem.c renamed from mm/shmem.c~mm-move-most-file-based-accounting-to-the-node +7 -7
@@ -575,9 +575,9 @@ static int shmem_add_to_page_cache(strucif (!error) { mapping->nrpages += nr;if (PageTransHuge (page)) -__inc_zone_page_state (page,NR_SHMEM_THPS ); -__mod_zone_page_state (page_zone (page),NR_FILE_PAGES , nr); -__mod_zone_page_state (page_zone (page),NR_SHMEM , nr); +__inc_node_page_state (page,NR_SHMEM_THPS ); +__mod_node_page_state (page_pgdat (page),NR_FILE_PAGES , nr); +__mod_node_page_state (page_pgdat (page),NR_SHMEM , nr);spin_unlock_irq (&mapping->tree_lock); }else { page->mapping =NULL ;
@@ -601,8 +601,8 @@ static void shmem_delete_from_page_cache error =shmem_radix_tree_replace (mapping, page->index, page, radswap); page->mapping =NULL ; mapping->nrpages--; -__dec_zone_page_state (page,NR_FILE_PAGES ); -__dec_zone_page_state (page,NR_SHMEM ); +__dec_node_page_state (page,NR_FILE_PAGES ); +__dec_node_page_state (page,NR_SHMEM );spin_unlock_irq (&mapping->tree_lock);put_page (page);BUG_ON (error);
@@ -1493,8 +1493,8 @@ static int shmem_replace_page(struct pag error =shmem_radix_tree_replace (swap_mapping, swap_index, oldpage, newpage);if (!error) { -__inc_zone_page_state (newpage,NR_FILE_PAGES ); -__dec_zone_page_state (oldpage,NR_FILE_PAGES ); +__inc_node_page_state (newpage,NR_FILE_PAGES ); +__dec_node_page_state (oldpage,NR_FILE_PAGES ); }spin_unlock_irq (&swap_mapping->tree_lock);
mm/swap_state.c renamed from mm/swap_state.c~mm-move-most-file-based-accounting-to-the-node +2 -2
@@ -95,7 +95,7 @@ int __add_to_swap_cache(struct page *pag entry.val, page);if (likely (!error)) { address_space->nrpages++; -__inc_zone_page_state (page,NR_FILE_PAGES ); +__inc_node_page_state (page,NR_FILE_PAGES );INC_CACHE_INFO (add_total); }spin_unlock_irq (&address_space->tree_lock);
@@ -147,7 +147,7 @@ void __delete_from_swap_cache(struct pagset_page_private (page,0 );ClearPageSwapCache (page); address_space->nrpages--; -__dec_zone_page_state (page,NR_FILE_PAGES ); +__dec_node_page_state (page,NR_FILE_PAGES );INC_CACHE_INFO (del_total); }
mm/util.c renamed from mm/util.c~mm-move-most-file-based-accounting-to-the-node +2 -2
@@ -528,7 +528,7 @@ int __vm_enough_memory(struct mm_structif (sysctl_overcommit_memory ==OVERCOMMIT_GUESS ) { free =global_page_state (NR_FREE_PAGES ); - free +=global_page_state (NR_FILE_PAGES ); + free +=global_node_page_state (NR_FILE_PAGES );/* * shmem pages shouldn't be counted as free in this
@@ -536,7 +536,7 @@ int __vm_enough_memory(struct mm_struct* that won't affect the overall amount of available * memory in the system. */ - free -=global_page_state (NR_SHMEM ); + free -=global_node_page_state (NR_SHMEM ); free +=get_nr_swap_pages ();
mm/vmscan.c renamed from mm/vmscan.c~mm-move-most-file-based-accounting-to-the-node +8 -8
@@ -3587,11 +3587,11 @@ int sysctl_min_unmapped_ratio = 1;*/ int sysctl_min_slab_ratio =5 ; -static inline unsigned long zone_unmapped_file_pages (struct zone *zone) +static inline unsigned long node_unmapped_file_pages (struct pglist_data *pgdat) { -unsigned long file_mapped =node_page_state (zone->zone_pgdat,NR_FILE_MAPPED ); -unsigned long file_lru =node_page_state (zone->zone_pgdat,NR_INACTIVE_FILE ) + -node_page_state (zone->zone_pgdat,NR_ACTIVE_FILE ); +unsigned long file_mapped =node_page_state (pgdat,NR_FILE_MAPPED ); +unsigned long file_lru =node_page_state (pgdat,NR_INACTIVE_FILE ) + +node_page_state (pgdat,NR_ACTIVE_FILE );/* * It's possible for there to be more file mapped pages than
@@ -3610,17 +3610,17 @@ static unsigned long zone_pagecache_recl/* * If RECLAIM_UNMAP is set, then all file pages are considered * potentially reclaimable. Otherwise, we have to worry about -* pages like swapcache and zone_unmapped_file_pages() provides +* pages like swapcache and node_unmapped_file_pages() provides * a better estimate */ if (zone_reclaim_mode &RECLAIM_UNMAP ) - nr_pagecache_reclaimable =zone_page_state (zone,NR_FILE_PAGES ); + nr_pagecache_reclaimable =node_page_state (zone->zone_pgdat,NR_FILE_PAGES );else - nr_pagecache_reclaimable =zone_unmapped_file_pages (zone); + nr_pagecache_reclaimable =node_unmapped_file_pages (zone->zone_pgdat);/* If we can't clean pages, remove dirty pages from consideration */ if (!(zone_reclaim_mode &RECLAIM_WRITE )) - delta +=zone_page_state (zone,NR_FILE_DIRTY ); + delta +=node_page_state (zone->zone_pgdat,NR_FILE_DIRTY );/* Watch for any possible underflows due to delta */ if (unlikely (delta > nr_pagecache_reclaimable))
mm/vmstat.c renamed from mm/vmstat.c~mm-move-most-file-based-accounting-to-the-node +10 -9
@@ -924,20 +924,15 @@ const char * const vmstat_text[] = {"nr_alloc_batch" ,"nr_zone_anon_lru" ,"nr_zone_file_lru" , +"nr_zone_write_pending" ,"nr_mlock" , -"nr_file_pages" , -"nr_dirty" , -"nr_writeback" ,"nr_slab_reclaimable" ,"nr_slab_unreclaimable" ,"nr_page_table_pages" ,"nr_kernel_stack" , -"nr_unstable" ,"nr_bounce" ,"nr_vmscan_write" ,"nr_vmscan_immediate_reclaim" , -"nr_writeback_temp" , -"nr_shmem" ,"nr_dirtied" ,"nr_written" , #if IS_ENABLED(CONFIG_ZSMALLOC)
@@ -951,9 +946,6 @@ const char * const vmstat_text[] = {"numa_local" ,"numa_other" , #endif -"nr_anon_transparent_hugepages" , -"nr_shmem_hugepages" , -"nr_shmem_pmdmapped" , "nr_free_cma",/* Node-based counters */
@@ -970,6 +962,15 @@ const char * const vmstat_text[] = {"workingset_nodereclaim" ,"nr_anon_pages" ,"nr_mapped" , +"nr_file_pages" , +"nr_dirty" , +"nr_writeback" , +"nr_writeback_temp" , +"nr_shmem" , +"nr_shmem_hugepages" , +"nr_shmem_pmdmapped" , +"nr_anon_transparent_hugepages" , +"nr_unstable" ,/* enum writeback_stat_item counters */ "nr_dirty_threshold",
_