Move LRU page reclaim from zones to nodes
Subsystems (28)
cover Move LRU page reclaim from zones to nodes
This is an RFC series against 4.0 that moves LRUs from the zones to the node. In concept, this is straight forward but there are a lot of details so I'm posting it early to see what people think. The motivations are;
1. Currently, reclaim on node 0 behaves differently to node 1 with subtly different aging rules. Workloads may exhibit different behaviour depending on what node it was scheduled on as a result.
2. The residency of a page partially depends on what zone the page was allocated from. This is partially combatted by the fair zone allocation policy but that is a partial solution that introduces overhead in the page allocator paths.
3. kswapd and the page allocator play special games with the order they scan zones to avoid interfering with each other but it's unpredictable.
4. The different scan activity and ordering for zone reclaim is very difficult to predict.
5. slab shrinkers are node-based which makes relating page reclaim to slab reclaim harder than it should be.
The reason we have zone-based reclaim is that we used to have large highmem zones in common configurations and it was necessary to quickly find ZONE_NORMAL pages for reclaim. Today, this is much less of a concern as machines with lots of memory will (or should) use 64-bit kernels. Combinations of 32-bit hardware and 64-bit hardware are rare. Machines that do use highmem should have relatively low highmem:lowmem ratios than we worried about in the past.
Conceptually, moving to node LRUs should be easier to understand. The page allocator plays fewer tricks to game reclaim and reclaim behaves similarly on all nodes.
The series is very long and bisection will be hazardous due to being misleading as infrastructure is reshuffled. The rational bisection points are
[PATCH 01/25] mm, vmstat: Add infrastructure for per-node vmstats [PATCH 19/25] mm, vmscan: Account in vmstat for pages skipped during reclaim [PATCH 21/25] mm, page_alloc: Defer zlc_setup until it is known it is required [PATCH 23/25] mm, page_alloc: Delete the zonelist_cache
[PATCH 25/25] mm: page_alloc: Take fewer passes when allocating to the low watermark
It was tested on a UMA (8 cores single socket) and a NUMA machine (48 cores, 4 sockets). The page allocator tests showed marginal differences in aim9, page fault microbenchmark, page allocator micro-benchmark and ebizzy. This was expected as the affected paths are small in comparison to the overall workloads.
I also tested using fstest on zero-length files to stress slab reclaim. It showed no major differences in performance or stats.
A THP-based test case that stresses compaction was inconclusive. It showed differences in the THP allocation success rate and both gains and losses in the time it takes to allocate THP depending on the number of threads running.
Tests did show there were differences in the pages allocated from each zone. This is due to the fact the fair zone allocation policy is removed as with node-based LRU reclaim, it *should* not be necessary. It would be preferable if the original database workload that motivated the introduction of that policy was retested with this series though.
The raw figures as such are not that interesting -- things perform more or less the same which is what you'd hope.
arch/s390/appldata/appldata_mem.c | 2 +- arch/tile/mm/pgtable.c | 18 +- drivers/base/node.c | 73 +-- drivers/staging/android/lowmemorykiller.c | 12 +- fs/fs-writeback.c | 8 +- fs/fuse/file.c | 8 +- fs/nfs/internal.h | 2 +- fs/nfs/write.c | 2 +- fs/proc/meminfo.c | 14 +- include/linux/backing-dev.h | 2 +- include/linux/memcontrol.h | 15 +- include/linux/mm_inline.h | 4 +- include/linux/mmzone.h | 224 ++++------ include/linux/swap.h | 11 +- include/linux/topology.h | 2 +- include/linux/vm_event_item.h | 11 +- include/linux/vmstat.h | 94 +++- include/linux/writeback.h | 2 +- include/trace/events/vmscan.h | 10 +- include/trace/events/writeback.h | 6 +- kernel/power/snapshot.c | 10 +- kernel/sysctl.c | 4 +- mm/backing-dev.c | 14 +- mm/compaction.c | 25 +- mm/filemap.c | 16 +- mm/huge_memory.c | 14 +- mm/internal.h | 11 +- mm/memcontrol.c | 37 +- mm/memory-failure.c | 4 +- mm/memory_hotplug.c | 2 +- mm/mempolicy.c | 2 +- mm/migrate.c | 31 +- mm/mlock.c | 12 +- mm/mmap.c | 4 +- mm/nommu.c | 4 +- mm/page-writeback.c | 109 ++--- mm/page_alloc.c | 489 ++++++-------------- mm/rmap.c | 16 +- mm/shmem.c | 12 +- mm/swap.c | 66 +-- mm/swap_state.c | 4 +- mm/truncate.c | 2 +- mm/vmscan.c | 718 ++++++++++++++---------------- mm/vmstat.c | 308 ++++++++++--- mm/workingset.c | 49 +- 45 files changed, 1225 insertions(+), 1258 deletions(-)
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/25 mm, vmstat: Add infrastructure for per-node vmstats
VM statistic counters for reclaim decisions are zone-based. If the kernel is to reclaim on a per-node basis then we need to track per-node statistics but there is no infrastructure for that. This patch adds it in preparation but is currently unused.
--- drivers/base/node.c | 72 ++++++++------- include/linux/mmzone.h | 12 +++ include/linux/vmstat.h | 94 +++++++++++++++++-- mm/page_alloc.c | 9 +- mm/vmstat.c | 240 ++++++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 364 insertions(+), 63 deletions(-)
drivers/base/node.c +39 -33
@@ -74,16 +74,16 @@ static ssize_t node_read_meminfo(struct device *dev, nid,K (i.totalram), nid,K (i.freeram), nid,K (i.totalram - i.freeram), - nid,K (node_page_state (nid,NR_ACTIVE_ANON ) + -node_page_state (nid,NR_ACTIVE_FILE )), - nid,K (node_page_state (nid,NR_INACTIVE_ANON ) + -node_page_state (nid,NR_INACTIVE_FILE )), - nid,K (node_page_state (nid,NR_ACTIVE_ANON )), - nid,K (node_page_state (nid,NR_INACTIVE_ANON )), - nid,K (node_page_state (nid,NR_ACTIVE_FILE )), - nid,K (node_page_state (nid,NR_INACTIVE_FILE )), - nid,K (node_page_state (nid,NR_UNEVICTABLE )), - nid, K(node_page_state(nid, NR_MLOCK))); + nid,K (sum_zone_node_page_state (nid,NR_ACTIVE_ANON ) + +sum_zone_node_page_state (nid,NR_ACTIVE_FILE )), + nid,K (sum_zone_node_page_state (nid,NR_INACTIVE_ANON ) + +sum_zone_node_page_state (nid,NR_INACTIVE_FILE )), + nid,K (sum_zone_node_page_state (nid,NR_ACTIVE_ANON )), + nid,K (sum_zone_node_page_state (nid,NR_INACTIVE_ANON )), + nid,K (sum_zone_node_page_state (nid,NR_ACTIVE_FILE )), + nid,K (sum_zone_node_page_state (nid,NR_INACTIVE_FILE )), + nid,K (sum_zone_node_page_state (nid,NR_UNEVICTABLE )), + nid, K(sum_zone_node_page_state(nid, NR_MLOCK)));#ifdef CONFIG_HIGHMEM n += sprintf(buf + n,
@@ -115,28 +115,28 @@ static ssize_t node_read_meminfo(struct device *dev,"Node %d AnonHugePages: %8lu kB\n" #endif , - nid,K (node_page_state (nid,NR_FILE_DIRTY )), - nid,K (node_page_state (nid,NR_WRITEBACK )), - nid,K (node_page_state (nid,NR_FILE_PAGES )), - nid,K (node_page_state (nid,NR_FILE_MAPPED )), - nid,K (node_page_state (nid,NR_ANON_PAGES )), + 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 (sum_zone_node_page_state (nid,NR_FILE_MAPPED )), + nid,K (sum_zone_node_page_state (nid,NR_ANON_PAGES )), nid,K (i.sharedram), - nid,node_page_state (nid,NR_KERNEL_STACK ) * + nid,sum_zone_node_page_state (nid,NR_KERNEL_STACK ) *THREAD_SIZE /1024 , - nid,K (node_page_state (nid,NR_PAGETABLE )), - nid,K (node_page_state (nid,NR_UNSTABLE_NFS )), - nid,K (node_page_state (nid,NR_BOUNCE )), - nid,K (node_page_state (nid,NR_WRITEBACK_TEMP )), - nid,K (node_page_state (nid,NR_SLAB_RECLAIMABLE ) + -node_page_state (nid,NR_SLAB_UNRECLAIMABLE )), - nid,K (node_page_state (nid,NR_SLAB_RECLAIMABLE )), + nid,K (sum_zone_node_page_state (nid,NR_PAGETABLE )), + nid,K (sum_zone_node_page_state (nid,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 (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 (node_page_state (nid,NR_SLAB_UNRECLAIMABLE )) + nid,K (sum_zone_node_page_state (nid,NR_SLAB_UNRECLAIMABLE )) , nid, -K (node_page_state (nid,NR_ANON_TRANSPARENT_HUGEPAGES ) * +K (sum_zone_node_page_state (nid,NR_ANON_TRANSPARENT_HUGEPAGES ) * HPAGE_PMD_NR));#else - nid, K(node_page_state(nid, NR_SLAB_UNRECLAIMABLE))); + nid, K(sum_zone_node_page_state(nid, NR_SLAB_UNRECLAIMABLE)));#endif n +=hugetlb_report_node_meminfo (nid, buf + n);return n;
@@ -155,12 +155,12 @@ static ssize_t node_read_numastat(struct device *dev,"interleave_hit %lu\n" "local_node %lu\n" "other_node %lu\n" , -node_page_state (dev->id,NUMA_HIT ), -node_page_state (dev->id,NUMA_MISS ), -node_page_state (dev->id,NUMA_FOREIGN ), -node_page_state (dev->id,NUMA_INTERLEAVE_HIT ), -node_page_state (dev->id,NUMA_LOCAL ), - node_page_state(dev->id, NUMA_OTHER)); +sum_zone_node_page_state (dev->id,NUMA_HIT ), +sum_zone_node_page_state (dev->id,NUMA_MISS ), +sum_zone_node_page_state (dev->id,NUMA_FOREIGN ), +sum_zone_node_page_state (dev->id,NUMA_INTERLEAVE_HIT ), +sum_zone_node_page_state (dev->id,NUMA_LOCAL ), + sum_zone_node_page_state(dev->id, NUMA_OTHER)); } static DEVICE_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
@@ -168,12 +168,18 @@ static ssize_t node_read_vmstat(struct device *dev, struct device_attribute *attr, char *buf) { int nid = dev->id; +struct pglist_data *pgdat =NODE_DATA (nid);int i;int n =0 ;for (i =0 ; i <NR_VM_ZONE_STAT_ITEMS ; i++) n +=sprintf (buf+n,"%s %lu\n" , vmstat_text[i], -node_page_state (nid, i)); +sum_zone_node_page_state (nid, i)); + +for (i =0 ; i <NR_VM_NODE_STAT_ITEMS ; i++) + n +=sprintf (buf+n,"%s %lu\n" , + vmstat_text[i +NR_VM_ZONE_STAT_ITEMS ], +node_page_state (pgdat, i));return n; }
include/linux/mmzone.h +12 -0
@@ -159,6 +159,10 @@ enum zone_stat_item {NR_FREE_CMA_PAGES , NR_VM_ZONE_STAT_ITEMS }; +enum node_stat_item { +NR_VM_NODE_STAT_ITEMS +}; +/* * We do arithmetic on the LRU lists in various places in the code, * so it is important to keep the active lists LRU_ACTIVE higher in
@@ -269,6 +273,11 @@ struct per_cpu_pageset {#endif }; +struct per_cpu_nodestat { +s8 stat_threshold; +s8 vm_node_stat_diff[NR_VM_NODE_STAT_ITEMS ]; +}; +#endif /* !__GENERATING_BOUNDS.H */ enum zone_type {
@@ -762,6 +771,9 @@ typedef struct pglist_data {/* Number of pages migrated during the rate limiting time interval */ unsigned long numabalancing_migrate_nr_pages;#endif + +struct per_cpu_nodestat __percpu *per_cpu_nodestats; +atomic_long_t vm_stat[NR_VM_NODE_STAT_ITEMS ]; } pg_data_t;#define node_present_pages (nid) (NODE_DATA(nid)->node_present_pages)
include/linux/vmstat.h +86 -8
181 lines not on this page · raw message
mm/page_alloc.c +7 -2
@@ -3134,8 +3134,8 @@ void si_meminfo_node(struct sysinfo *val, int nid)for (zone_type =0 ; zone_type <MAX_NR_ZONES ; zone_type++) managed_pages += pgdat->node_zones[zone_type].managed_pages; val->totalram = managed_pages; - val->sharedram =node_page_state (nid,NR_SHMEM ); - val->freeram =node_page_state (nid,NR_FREE_PAGES ); + val->sharedram =sum_zone_node_page_state (nid,NR_SHMEM ); + val->freeram =sum_zone_node_page_state (nid,NR_FREE_PAGES );#ifdef CONFIG_HIGHMEM val->totalhigh = pgdat->node_zones[ZONE_HIGHMEM ].managed_pages; val->freehigh = zone_page_state(&pgdat->node_zones[ZONE_HIGHMEM],
@@ -4335,6 +4335,11 @@ static void __meminit setup_zone_pageset(struct zone *zone) zone->pageset = alloc_percpu(struct per_cpu_pageset);for_each_possible_cpu (cpu)zone_pageset_init (zone, cpu); + +if (!zone->zone_pgdat->per_cpu_nodestats) { + zone->zone_pgdat->per_cpu_nodestats = + alloc_percpu(struct per_cpu_nodestat); + } }/*
mm/vmstat.c +220 -20
373 lines not on this page · raw message
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/25 mm, vmscan: Move lru_lock to the node
In reply to Mel GormanNode-based reclaim means that the we need node-based LRUs and node-based locking. This is a preparation patch that just moves the lru_lock to the node as it makes later patches easier to review. It's a mechanical change but note this patch makes contention actively worse because now the LRU lock is hotter and direct reclaim and kswapd can contend on the same lock even when reclaiming from different zones.
--- include/linux/mmzone.h | 10 ++++++++-- mm/compaction.c | 6 +++--- mm/filemap.c | 4 ++-- mm/huge_memory.c | 4 ++-- mm/memcontrol.c | 4 ++-- mm/mlock.c | 10 +++++----- mm/page_alloc.c | 4 ++-- mm/rmap.c | 2 +- mm/swap.c | 30 +++++++++++++++--------------- mm/vmscan.c | 42 +++++++++++++++++++++--------------------- 10 files changed, 61 insertions(+), 55 deletions(-)
include/linux/mmzone.h +8 -2
@@ -97,7 +97,7 @@ struct free_area {struct pglist_data ;/* -* zone->lock and zone->lru_lock are two of the hottest locks in the kernel. +* zone->lock and the zone lru_lock are two of the hottest locks in the kernel. * So add a wild amount of padding here to ensure that they fall into separate * cachelines. There are very few zone structures in the machine, so space * consumption is not a concern here.
@@ -497,7 +497,6 @@ struct zone {/* Write-intensive fields used by page reclaim */ /* Fields commonly accessed by the page reclaim scanner */ -spinlock_t lru_lock;struct lruvec lruvec;/* Evictions & activations on the inactive file list */
@@ -771,6 +770,9 @@ typedef struct pglist_data {/* Number of pages migrated during the rate limiting time interval */ unsigned long numabalancing_migrate_nr_pages;#endif +/* Write-intensive fields used from the page allocator */ +ZONE_PADDING (_pad1_) + spinlock_t lru_lock;struct per_cpu_nodestat __percpu *per_cpu_nodestats;atomic_long_t vm_stat[NR_VM_NODE_STAT_ITEMS ];
@@ -787,6 +789,10 @@ typedef struct pglist_data {#define node_start_pfn (nid) (NODE_DATA(nid)->node_start_pfn)#define node_end_pfn (nid) pgdat_end_pfn(NODE_DATA(nid)) +static inline spinlock_t *zone_lru_lock (struct zone *zone) +{ +return &zone->zone_pgdat->lru_lock; +}static inline unsigned long pgdat_end_pfn (pg_data_t *pgdat) {
mm/compaction.c +3 -3
@@ -702,7 +702,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,* if contended. */ if (!(low_pfn %SWAP_CLUSTER_MAX ) - &&compact_unlock_should_abort (&zone->lru_lock, flags, + &&compact_unlock_should_abort (zone_lru_lock (zone), flags, &locked, cc))break ;
@@ -780,7 +780,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,/* If we already hold the lock, we can skip some rechecking */ if (!locked) { - locked =compact_trylock_irqsave (&zone->lru_lock, + locked =compact_trylock_irqsave (zone_lru_lock (zone), &flags, cc);if (!locked)break ;
@@ -825,7 +825,7 @@ isolate_success: low_pfn = end_pfn;if (locked) -spin_unlock_irqrestore (&zone->lru_lock, flags); +spin_unlock_irqrestore (zone_lru_lock (zone), flags);/* * Update the pageblock-skip information and cached scanner pfn,
mm/filemap.c +2 -2
@@ -95,8 +95,8 @@* ->swap_lock (try_to_unmap_one) * ->private_lock (try_to_unmap_one) * ->tree_lock (try_to_unmap_one) -* ->zone.lru_lock (follow_page->mark_page_accessed) -* ->zone.lru_lock (check_pte_range->isolate_lru_page) +* ->zone_lru_lock (follow_page->mark_page_accessed) +* ->zone_lru_lock (check_pte_range->isolate_lru_page) * ->private_lock (page_remove_rmap->set_page_dirty) * ->tree_lock (page_remove_rmap->set_page_dirty) * bdi.wb->list_lock (page_remove_rmap->set_page_dirty)
mm/huge_memory.c +2 -2
@@ -1634,7 +1634,7 @@ static void __split_huge_page_refcount(struct page *page,int tail_count =0 ;/* prevent PageLRU to go away from under us, and freeze lru stats */ -spin_lock_irq (&zone->lru_lock); +spin_lock_irq (zone_lru_lock (zone)); lruvec =mem_cgroup_page_lruvec (page, zone);compound_lock (page);
@@ -1723,7 +1723,7 @@ static void __split_huge_page_refcount(struct page *page,ClearPageCompound (page);compound_unlock (page); -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irq (zone_lru_lock (zone));for (i =1 ; i <HPAGE_PMD_NR ; i++) {struct page *page_tail = page + i;
mm/memcontrol.c +2 -2
@@ -2392,7 +2392,7 @@ static void lock_page_lru(struct page *page, int *isolated) {struct zone *zone =page_zone (page); -spin_lock_irq (&zone->lru_lock); +spin_lock_irq (zone_lru_lock (zone));if (PageLRU (page)) {struct lruvec *lruvec;
@@ -2416,7 +2416,7 @@ static void unlock_page_lru(struct page *page, int isolated)SetPageLRU (page);add_page_to_lru_list (page, lruvec,page_lru (page)); } -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irq (zone_lru_lock (zone)); } static void commit_charge(struct page *page, struct mem_cgroup *memcg,
mm/mlock.c +5 -5
@@ -183,7 +183,7 @@ unsigned int munlock_vma_page(struct page *page)* might otherwise copy PageMlocked to part of the tail pages before * we clear it in the head page. It also stabilizes hpage_nr_pages(). */ -spin_lock_irq (&zone->lru_lock); +spin_lock_irq (zone_lru_lock (zone)); nr_pages =hpage_nr_pages (page);if (!TestClearPageMlocked (page))
@@ -192,14 +192,14 @@ unsigned int munlock_vma_page(struct page *page)__mod_zone_page_state (zone,NR_MLOCK , -nr_pages);if (__munlock_isolate_lru_page (page, true)) { -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irq (zone_lru_lock (zone));__munlock_isolated_page (page); goto out; }__munlock_isolation_failed (page); unlock_out: -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irq (zone_lru_lock (zone)); out:return nr_pages -1 ;
@@ -340,7 +340,7 @@ static void __munlock_pagevec(struct pagevec *pvec, struct zone *zone)pagevec_init (&pvec_putback,0 );/* Phase 1: page isolation */ -spin_lock_irq (&zone->lru_lock); +spin_lock_irq (zone_lru_lock (zone));for (i =0 ; i < nr; i++) {struct page *page = pvec->pages[i];
@@ -366,7 +366,7 @@ static void __munlock_pagevec(struct pagevec *pvec, struct zone *zone) } delta_munlocked = -nr +pagevec_count (&pvec_putback);__mod_zone_page_state (zone,NR_MLOCK , delta_munlocked); -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irq (zone_lru_lock (zone));/* Now we can release pins of pages that we are not munlocking */ pagevec_release (&pvec_putback);
mm/page_alloc.c +2 -2
@@ -4933,10 +4933,10 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat, zone->min_slab_pages = (freesize * sysctl_min_slab_ratio) /100 ;#endif zone->name = zone_names[j]; + zone->zone_pgdat = pgdat;spin_lock_init (&zone->lock); -spin_lock_init (&zone->lru_lock); +spin_lock_init (zone_lru_lock (zone));zone_seqlock_init (zone); - zone->zone_pgdat = pgdat;zone_pcp_init (zone);/* For bootup, initialized properly in watermark setup */
mm/rmap.c +1 -1
@@ -26,7 +26,7 @@* mapping->i_mmap_rwsem * anon_vma->rwsem * mm->page_table_lock or pte_lock -* zone->lru_lock (in mark_page_accessed, isolate_lru_page) +* zone_lru_lock (in mark_page_accessed, isolate_lru_page) * swap_lock (in swap_duplicate, swap_info_get) * mmlist_lock (in mmput, drain_mmlist and others) * mapping->private_lock (in __set_page_dirty_buffers)
mm/swap.c +15 -15
@@ -55,12 +55,12 @@ static void __page_cache_release(struct page *page)struct lruvec *lruvec;unsigned long flags; -spin_lock_irqsave (&zone->lru_lock, flags); +spin_lock_irqsave (zone_lru_lock (zone), flags); lruvec =mem_cgroup_page_lruvec (page, zone);VM_BUG_ON_PAGE (!PageLRU (page), page);__ClearPageLRU (page);del_page_from_lru_list (page, lruvec,page_off_lru (page)); -spin_unlock_irqrestore (&zone->lru_lock, flags); +spin_unlock_irqrestore (zone_lru_lock (zone), flags); }mem_cgroup_uncharge (page); }
@@ -422,16 +422,16 @@ static void pagevec_lru_move_fn(struct pagevec *pvec,if (pagezone != zone) {if (zone) -spin_unlock_irqrestore (&zone->lru_lock, flags); +spin_unlock_irqrestore (zone_lru_lock (zone), flags); zone = pagezone; -spin_lock_irqsave (&zone->lru_lock, flags); +spin_lock_irqsave (zone_lru_lock (zone), flags); } lruvec =mem_cgroup_page_lruvec (page, zone); (*move_fn)(page, lruvec, arg); }if (zone) -spin_unlock_irqrestore (&zone->lru_lock, flags); +spin_unlock_irqrestore (zone_lru_lock (zone), flags);release_pages (pvec->pages, pvec->nr, pvec->cold);pagevec_reinit (pvec); }
@@ -551,9 +551,9 @@ void activate_page(struct page *page) {struct zone *zone =page_zone (page); -spin_lock_irq (&zone->lru_lock); +spin_lock_irq (zone_lru_lock (zone));__activate_page (page,mem_cgroup_page_lruvec (page, zone),NULL ); -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irq (zone_lru_lock (zone)); }#endif
@@ -679,13 +679,13 @@ void add_page_to_unevictable_list(struct page *page)struct zone *zone =page_zone (page);struct lruvec *lruvec; -spin_lock_irq (&zone->lru_lock); +spin_lock_irq (zone_lru_lock (zone)); lruvec =mem_cgroup_page_lruvec (page, zone);ClearPageActive (page);SetPageUnevictable (page);SetPageLRU (page);add_page_to_lru_list (page, lruvec,LRU_UNEVICTABLE ); -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irq (zone_lru_lock (zone)); }/**
@@ -910,7 +910,7 @@ void release_pages(struct page **pages, int nr, bool cold)if (unlikely (PageCompound (page))) {if (zone) { -spin_unlock_irqrestore (&zone->lru_lock, flags); +spin_unlock_irqrestore (zone_lru_lock (zone), flags); zone =NULL ; }put_compound_page (page);
@@ -923,7 +923,7 @@ void release_pages(struct page **pages, int nr, bool cold)* same zone. The lock is held only if zone != NULL. */ if (zone && ++lock_batch ==SWAP_CLUSTER_MAX ) { -spin_unlock_irqrestore (&zone->lru_lock, flags); +spin_unlock_irqrestore (zone_lru_lock (zone), flags); zone =NULL ; }
@@ -935,11 +935,11 @@ void release_pages(struct page **pages, int nr, bool cold)if (pagezone != zone) {if (zone) -spin_unlock_irqrestore (&zone->lru_lock, +spin_unlock_irqrestore (zone_lru_lock (zone), flags); lock_batch =0 ; zone = pagezone; -spin_lock_irqsave (&zone->lru_lock, flags); +spin_lock_irqsave (zone_lru_lock (zone), flags); } lruvec =mem_cgroup_page_lruvec (page, zone);
@@ -954,7 +954,7 @@ void release_pages(struct page **pages, int nr, bool cold)list_add (&page->lru, &pages_to_free); }if (zone) -spin_unlock_irqrestore (&zone->lru_lock, flags); +spin_unlock_irqrestore (zone_lru_lock (zone), flags);mem_cgroup_uncharge_list (&pages_to_free);free_hot_cold_page_list (&pages_to_free, cold);
@@ -990,7 +990,7 @@ void lru_add_page_tail(struct page *page, struct page *page_tail,VM_BUG_ON_PAGE (PageCompound (page_tail), page);VM_BUG_ON_PAGE (PageLRU (page_tail), page);VM_BUG_ON (NR_CPUS !=1 && - !spin_is_locked (&lruvec_zone (lruvec)->lru_lock)); + !spin_is_locked (zone_lru_lock (lruvec_zone (lruvec))));if (!list)SetPageLRU (page_tail);
mm/vmscan.c +21 -21
150 lines not on this page · raw message
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/25 mm, vmscan: Move LRU lists to node
In reply to Mel GormanThis moves the LRU lists from the zone to the node and all related data such as counters, tracing, congestion tracking and writeback tracking. This is mostly a mechanical patch but note that it introduces a number of anomalies. For example, the scans are per-zone but using per-node counters. We also mark a node as congested when a zone is congested. This causes weird problems that are fixed later but is easier to review.
--- arch/tile/mm/pgtable.c | 8 +- drivers/base/node.c | 19 +-- drivers/staging/android/lowmemorykiller.c | 8 +- include/linux/backing-dev.h | 2 +- include/linux/memcontrol.h | 8 +- include/linux/mm_inline.h | 4 +- include/linux/mmzone.h | 70 +++++----- include/linux/vm_event_item.h | 10 +- include/trace/events/vmscan.h | 10 +- kernel/power/snapshot.c | 10 +- mm/backing-dev.c | 14 +- mm/compaction.c | 19 +-- mm/huge_memory.c | 6 +- mm/internal.h | 2 +- mm/memcontrol.c | 18 +-- mm/memory-failure.c | 4 +- mm/memory_hotplug.c | 2 +- mm/mempolicy.c | 2 +- mm/migrate.c | 21 +-- mm/mlock.c | 2 +- mm/page-writeback.c | 8 +- mm/page_alloc.c | 103 +++++++++------ mm/swap.c | 56 ++++---- mm/vmscan.c | 208 ++++++++++++++++-------------- mm/vmstat.c | 45 +++---- mm/workingset.c | 8 +- 26 files changed, 354 insertions(+), 313 deletions(-)
arch/tile/mm/pgtable.c +4 -4
@@ -45,10 +45,10 @@ void show_mem(unsigned int filter)struct zone *zone; pr_err("Active:%lu inactive:%lu dirty:%lu writeback:%lu unstable:%lu free:%lu\n slab:%lu mapped:%lu pagetables:%lu bounce:%lu pagecache:%lu swap:%lu\n", - (global_page_state(NR_ACTIVE_ANON) + - global_page_state(NR_ACTIVE_FILE)), - (global_page_state(NR_INACTIVE_ANON) + - global_page_state(NR_INACTIVE_FILE)), + (global_node_page_state(NR_ACTIVE_ANON) + + 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),
drivers/base/node.c +10 -9
@@ -56,6 +56,7 @@ static ssize_t node_read_meminfo(struct device *dev, {int n;int nid = dev->id; +struct pglist_data *pgdat =NODE_DATA (nid);struct sysinfo i;si_meminfo_node (&i, nid);
@@ -74,15 +75,15 @@ static ssize_t node_read_meminfo(struct device *dev, nid,K (i.totalram), nid,K (i.freeram), nid,K (i.totalram - i.freeram), - nid,K (sum_zone_node_page_state (nid,NR_ACTIVE_ANON ) + -sum_zone_node_page_state (nid,NR_ACTIVE_FILE )), - nid,K (sum_zone_node_page_state (nid,NR_INACTIVE_ANON ) + -sum_zone_node_page_state (nid,NR_INACTIVE_FILE )), - nid,K (sum_zone_node_page_state (nid,NR_ACTIVE_ANON )), - nid,K (sum_zone_node_page_state (nid,NR_INACTIVE_ANON )), - nid,K (sum_zone_node_page_state (nid,NR_ACTIVE_FILE )), - nid,K (sum_zone_node_page_state (nid,NR_INACTIVE_FILE )), - nid,K (sum_zone_node_page_state (nid,NR_UNEVICTABLE )), + nid,K (node_page_state (pgdat,NR_ACTIVE_ANON ) + +node_page_state (pgdat,NR_ACTIVE_FILE )), + nid,K (node_page_state (pgdat,NR_INACTIVE_ANON ) + +node_page_state (pgdat,NR_INACTIVE_FILE )), + nid,K (node_page_state (pgdat,NR_ACTIVE_ANON )), + nid,K (node_page_state (pgdat,NR_INACTIVE_ANON )), + nid,K (node_page_state (pgdat,NR_ACTIVE_FILE )), + nid,K (node_page_state (pgdat,NR_INACTIVE_FILE )), + nid,K (node_page_state (pgdat,NR_UNEVICTABLE )), nid, K(sum_zone_node_page_state(nid, NR_MLOCK)));#ifdef CONFIG_HIGHMEM
drivers/staging/android/lowmemorykiller.c +4 -4
@@ -69,10 +69,10 @@ static unsigned long lowmem_deathpending_timeout;static unsigned long lowmem_count (struct shrinker *s,struct shrink_control *sc) { -return global_page_state (NR_ACTIVE_ANON ) + -global_page_state (NR_ACTIVE_FILE ) + -global_page_state (NR_INACTIVE_ANON ) + -global_page_state (NR_INACTIVE_FILE ); +return global_node_page_state (NR_ACTIVE_ANON ) + +global_node_page_state (NR_ACTIVE_FILE ) + +global_node_page_state (NR_INACTIVE_ANON ) + +global_node_page_state (NR_INACTIVE_FILE ); }static unsigned long lowmem_scan (struct shrinker *s,struct shrink_control *sc)
include/linux/backing-dev.h +1 -1
@@ -277,7 +277,7 @@ enum {void clear_bdi_congested (struct backing_dev_info *bdi,int sync);void set_bdi_congested (struct backing_dev_info *bdi,int sync);long congestion_wait (int sync,long timeout); -long wait_iff_congested (struct zone *zone,int sync,long timeout); +long wait_iff_congested (struct pglist_data *pgdat,int sync,long timeout);int pdflush_proc_obsolete (struct ctl_table *table,int write,void __user *buffer,size_t *lenp,loff_t *ppos);
include/linux/memcontrol.h +4 -4
@@ -85,7 +85,7 @@ void mem_cgroup_migrate(struct page *oldpage, struct page *newpage, bool lrucare);struct lruvec *mem_cgroup_zone_lruvec (struct zone *,struct mem_cgroup *); -struct lruvec *mem_cgroup_page_lruvec (struct page *,struct zone *); +struct lruvec *mem_cgroup_page_lruvec (struct page *,struct pglist_data *);bool mem_cgroup_is_descendant (struct mem_cgroup *memcg,struct mem_cgroup *root);
@@ -243,13 +243,13 @@ static inline void mem_cgroup_migrate(struct page *oldpage,static inline struct lruvec *mem_cgroup_zone_lruvec (struct zone *zone,struct mem_cgroup *memcg) { -return &zone->lruvec; +return zone_lruvec (zone); }static inline struct lruvec *mem_cgroup_page_lruvec (struct page *page, -struct zone *zone) +struct pglist_data *pgdat) { -return &zone->lruvec; +return &pgdat->lruvec; }static inline struct mem_cgroup *try_get_mem_cgroup_from_page (struct page *page)
include/linux/mm_inline.h +2 -2
@@ -28,7 +28,7 @@ static __always_inline void add_page_to_lru_list(struct page *page,int nr_pages =hpage_nr_pages (page);mem_cgroup_update_lru_size (lruvec, lru, nr_pages);list_add (&page->lru, &lruvec->lists[lru]); -__mod_zone_page_state (lruvec_zone (lruvec),NR_LRU_BASE + lru, nr_pages); +__mod_node_page_state (page_zone (page)->zone_pgdat,NR_LRU_BASE + lru, nr_pages); } static __always_inline void del_page_from_lru_list(struct page *page,
@@ -37,7 +37,7 @@ static __always_inline void del_page_from_lru_list(struct page *page,int nr_pages =hpage_nr_pages (page);mem_cgroup_update_lru_size (lruvec, lru, -nr_pages);list_del (&page->lru); -__mod_zone_page_state (lruvec_zone (lruvec),NR_LRU_BASE + lru, -nr_pages); +__mod_node_page_state (page_zone (page)->zone_pgdat,NR_LRU_BASE + lru, -nr_pages); }/**
include/linux/mmzone.h +40 -30
143 lines not on this page · raw message
include/linux/vm_event_item.h +5 -5
@@ -25,11 +25,11 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,FOR_ALL_ZONES (PGALLOC ),PGFREE ,PGACTIVATE ,PGDEACTIVATE ,PGFAULT ,PGMAJFAULT , -FOR_ALL_ZONES (PGREFILL ), -FOR_ALL_ZONES (PGSTEAL_KSWAPD ), -FOR_ALL_ZONES (PGSTEAL_DIRECT ), -FOR_ALL_ZONES (PGSCAN_KSWAPD ), -FOR_ALL_ZONES (PGSCAN_DIRECT ), +PGREFILL , +PGSTEAL_KSWAPD , +PGSTEAL_DIRECT , +PGSCAN_KSWAPD , +PGSCAN_DIRECT ,PGSCAN_DIRECT_THROTTLE , #ifdef CONFIG_NUMA PGSCAN_ZONE_RECLAIM_FAILED,
include/trace/events/vmscan.h +4 -6
@@ -353,15 +353,14 @@ TRACE_EVENT(mm_vmscan_writepage, TRACE_EVENT(mm_vmscan_lru_shrink_inactive, - TP_PROTO(int nid, int zid, + TP_PROTO(int nid, unsigned long nr_scanned, unsigned long nr_reclaimed, int priority, int reclaim_flags), - TP_ARGS(nid, zid, nr_scanned, nr_reclaimed, priority, reclaim_flags), + TP_ARGS(nid, nr_scanned, nr_reclaimed, priority, reclaim_flags), TP_STRUCT__entry( __field(int, nid) - __field(int, zid) __field(unsigned long, nr_scanned) __field(unsigned long, nr_reclaimed) __field(int, priority)
@@ -370,15 +369,14 @@ TRACE_EVENT(mm_vmscan_lru_shrink_inactive,TP_fast_assign ( __entry->nid = nid; - __entry->zid = zid; __entry->nr_scanned = nr_scanned; __entry->nr_reclaimed = nr_reclaimed; __entry->priority = priority; __entry->reclaim_flags = reclaim_flags; ), -TP_printk ("nid=%d zid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s" , - __entry->nid, __entry->zid, +TP_printk ("nid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s" , + __entry->nid, __entry->nr_scanned, __entry->nr_reclaimed, __entry->priority,show_reclaim_flags (__entry->reclaim_flags))
kernel/power/snapshot.c +5 -5
@@ -1525,11 +1525,11 @@ static unsigned long minimum_image_size(unsigned long saveable)unsigned long size; size =global_page_state (NR_SLAB_RECLAIMABLE ) - +global_page_state (NR_ACTIVE_ANON ) - +global_page_state (NR_INACTIVE_ANON ) - +global_page_state (NR_ACTIVE_FILE ) - +global_page_state (NR_INACTIVE_FILE ) - -global_page_state (NR_FILE_MAPPED ); + +global_node_page_state (NR_ACTIVE_ANON ) + +global_node_page_state (NR_INACTIVE_ANON ) + +global_node_page_state (NR_ACTIVE_FILE ) + +global_node_page_state (NR_INACTIVE_FILE ) + -global_node_page_state (NR_FILE_MAPPED );return saveable <= size ?0 : saveable - size; }
mm/backing-dev.c +7 -7
@@ -542,24 +542,24 @@ long congestion_wait(int sync, long timeout)EXPORT_SYMBOL (congestion_wait);/** -* wait_iff_congested - Conditionally wait for a backing_dev to become uncongested or a zone to complete writes -* @zone: A zone to check if it is heavily congested +* wait_iff_congested - Conditionally wait for a backing_dev to become uncongested or a pgdat to complete writes +* @pgdat: A pgdat to check if it is heavily congested * @sync: SYNC or ASYNC IO * @timeout: timeout in jiffies * * In the event of a congested backing_dev (any backing_dev) and the given -* @zone has experienced recent congestion, this waits for up to @timeout +* @pgdat has experienced recent congestion, this waits for up to @timeout * jiffies for either a BDI to exit congestion of the given @sync queue * or a write to complete. * -* In the absence of zone congestion, cond_resched() is called to yield +* In the absence of pgdat congestion, cond_resched() is called to yield * the processor if necessary but otherwise does not sleep. * * The return value is 0 if the sleep is for the full timeout. Otherwise, * it is the number of jiffies that were still remaining when the function * returned. return_value == timeout implies the function did not sleep. */ -long wait_iff_congested (struct zone *zone,int sync,long timeout) +long wait_iff_congested (struct pglist_data *pgdat,int sync,long timeout) {long ret;unsigned long start = jiffies;
@@ -568,11 +568,11 @@ long wait_iff_congested(struct zone *zone, int sync, long timeout)/* * If there is no congestion, or heavy congestion is not being -* encountered in the current zone, yield if necessary instead +* encountered in the current pgdat, yield if necessary instead * of sleeping on the congestion queue */ if (atomic_read (&nr_bdi_congested[sync]) ==0 || - !test_bit (ZONE_CONGESTED , &zone->flags)) { + !test_bit (PGDAT_CONGESTED , &pgdat->flags)) {cond_resched ();/* In case we scheduled, work out time remaining */
mm/compaction.c +10 -9
@@ -625,21 +625,22 @@ static void acct_isolated(struct zone *zone, struct compact_control *cc)list_for_each_entry (page, &cc->migratepages, lru) count[!!page_is_file_cache (page)]++; -mod_zone_page_state (zone,NR_ISOLATED_ANON , count[0 ]); -mod_zone_page_state (zone,NR_ISOLATED_FILE , count[1 ]); +mod_node_page_state (zone->zone_pgdat,NR_ISOLATED_ANON , count[0 ]); +mod_node_page_state (zone->zone_pgdat,NR_ISOLATED_FILE , count[1 ]); }/* Similar to reclaim, but different enough that they don't share logic */ static bool too_many_isolated (struct zone *zone) { +pg_data_t *pgdat = zone->zone_pgdat;unsigned long active, inactive, isolated; - inactive =zone_page_state (zone,NR_INACTIVE_FILE ) + -zone_page_state (zone,NR_INACTIVE_ANON ); - active =zone_page_state (zone,NR_ACTIVE_FILE ) + -zone_page_state (zone,NR_ACTIVE_ANON ); - isolated =zone_page_state (zone,NR_ISOLATED_FILE ) + -zone_page_state (zone,NR_ISOLATED_ANON ); + inactive =node_page_state (pgdat,NR_INACTIVE_FILE ) + +node_page_state (pgdat,NR_INACTIVE_ANON ); + active =node_page_state (pgdat,NR_ACTIVE_FILE ) + +node_page_state (pgdat,NR_ACTIVE_ANON ); + isolated =node_page_state (pgdat,NR_ISOLATED_FILE ) + +node_page_state (pgdat,NR_ISOLATED_ANON );return isolated > (inactive + active) /2 ; }
@@ -794,7 +795,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, } } - lruvec =mem_cgroup_page_lruvec (page, zone); + lruvec =mem_cgroup_page_lruvec (page, zone->zone_pgdat);/* Try isolate the page */ if (__isolate_lru_page (page, isolate_mode) !=0 )
mm/huge_memory.c +3 -3
@@ -1635,7 +1635,7 @@ static void __split_huge_page_refcount(struct page *page,/* prevent PageLRU to go away from under us, and freeze lru stats */ spin_lock_irq (zone_lru_lock (zone)); - lruvec =mem_cgroup_page_lruvec (page, zone); + lruvec =mem_cgroup_page_lruvec (page, zone->zone_pgdat);compound_lock (page);/* complete memcg works before add pages to LRU */
@@ -2100,7 +2100,7 @@ void __khugepaged_exit(struct mm_struct *mm)static void release_pte_page (struct page *page) {/* 0 stands for page_is_file_cache(page) == false */ -dec_zone_page_state (page,NR_ISOLATED_ANON +0 ); +dec_node_page_state (page,NR_ISOLATED_ANON +0 );unlock_page (page);putback_lru_page (page); }
@@ -2181,7 +2181,7 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, goto out; }/* 0 stands for page_is_file_cache(page) == false */ -inc_zone_page_state (page,NR_ISOLATED_ANON +0 ); +inc_node_page_state (page,NR_ISOLATED_ANON +0 );VM_BUG_ON_PAGE (!PageLocked (page), page);VM_BUG_ON_PAGE (PageLRU (page), page);
mm/internal.h +1 -1
@@ -98,7 +98,7 @@ extern unsigned long highest_memmap_pfn;*/ extern int isolate_lru_page (struct page *page);extern void putback_lru_page (struct page *page); -extern bool zone_reclaimable (struct zone *zone); +extern bool pgdat_reclaimable (struct pglist_data *pgdat);/* * in mm/rmap.c:
mm/memcontrol.c +9 -9
@@ -1185,7 +1185,7 @@ struct lruvec *mem_cgroup_zone_lruvec(struct zone *zone,struct lruvec *lruvec;if (mem_cgroup_disabled ()) { - lruvec = &zone->lruvec; + lruvec =zone_lruvec (zone); goto out; }
@@ -1197,8 +1197,8 @@ out:* we have to be prepared to initialize lruvec->zone here; * and if offlined then reonlined, we need to reinitialize it. */ -if (unlikely (lruvec->zone != zone)) - lruvec->zone = zone; +if (unlikely (lruvec->pgdat != zone->zone_pgdat)) + lruvec->pgdat = zone->zone_pgdat;return lruvec; }
@@ -1211,14 +1211,14 @@ out:* and putback protocol: the LRU lock must be held, and the page must * either be PageLRU() or the caller must have isolated/allocated it. */ -struct lruvec *mem_cgroup_page_lruvec (struct page *page,struct zone *zone) +struct lruvec *mem_cgroup_page_lruvec (struct page *page,struct pglist_data *pgdat) {struct mem_cgroup_per_zone *mz;struct mem_cgroup *memcg;struct lruvec *lruvec;if (mem_cgroup_disabled ()) { - lruvec = &zone->lruvec; + lruvec = &pgdat->lruvec; goto out; }
@@ -1238,8 +1238,8 @@ out:* we have to be prepared to initialize lruvec->zone here; * and if offlined then reonlined, we need to reinitialize it. */ -if (unlikely (lruvec->zone != zone)) - lruvec->zone = zone; +if (unlikely (lruvec->pgdat != pgdat)) + lruvec->pgdat = pgdat;return lruvec; }
@@ -2396,7 +2396,7 @@ static void lock_page_lru(struct page *page, int *isolated)if (PageLRU (page)) {struct lruvec *lruvec; - lruvec =mem_cgroup_page_lruvec (page, zone); + lruvec =mem_cgroup_page_lruvec (page, zone->zone_pgdat);ClearPageLRU (page);del_page_from_lru_list (page, lruvec,page_lru (page)); *isolated =1 ;
@@ -2411,7 +2411,7 @@ static void unlock_page_lru(struct page *page, int isolated)if (isolated) {struct lruvec *lruvec; - lruvec =mem_cgroup_page_lruvec (page, zone); + lruvec =mem_cgroup_page_lruvec (page, zone->zone_pgdat);VM_BUG_ON_PAGE (PageLRU (page), page);SetPageLRU (page);add_page_to_lru_list (page, lruvec,page_lru (page));
mm/memory-failure.c +2 -2
@@ -1620,7 +1620,7 @@ static int __soft_offline_page(struct page *page, int flags)put_page (page);if (!ret) {LIST_HEAD (pagelist); -inc_zone_page_state (page,NR_ISOLATED_ANON + +inc_node_page_state (page,NR_ISOLATED_ANON +page_is_file_cache (page));list_add (&page->lru, &pagelist); ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL,
@@ -1628,7 +1628,7 @@ static int __soft_offline_page(struct page *page, int flags)if (ret) {if (!list_empty (&pagelist)) {list_del (&page->lru); -dec_zone_page_state (page,NR_ISOLATED_ANON + +dec_node_page_state (page,NR_ISOLATED_ANON +page_is_file_cache (page));putback_lru_page (page); }
mm/memory_hotplug.c +1 -1
@@ -1426,7 +1426,7 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)put_page (page);list_add_tail (&page->lru, &source); move_pages--; -inc_zone_page_state (page,NR_ISOLATED_ANON + +inc_node_page_state (page,NR_ISOLATED_ANON +page_is_file_cache (page)); }else {
mm/mempolicy.c +1 -1
@@ -933,7 +933,7 @@ static void migrate_page_add(struct page *page, struct list_head *pagelist,if ((flags &MPOL_MF_MOVE_ALL ) ||page_mapcount (page) ==1 ) {if (!isolate_lru_page (page)) {list_add_tail (&page->lru, pagelist); -inc_zone_page_state (page,NR_ISOLATED_ANON + +inc_node_page_state (page,NR_ISOLATED_ANON +page_is_file_cache (page)); } }
mm/migrate.c +11 -10
@@ -90,7 +90,7 @@ void putback_movable_pages(struct list_head *l)continue ; }list_del (&page->lru); -dec_zone_page_state (page,NR_ISOLATED_ANON + +dec_node_page_state (page,NR_ISOLATED_ANON +page_is_file_cache (page));if (unlikely (isolated_balloon_page (page)))balloon_page_putback (page);
@@ -935,7 +935,7 @@ out:* restored. */ list_del (&page->lru); -dec_zone_page_state (page,NR_ISOLATED_ANON + +dec_node_page_state (page,NR_ISOLATED_ANON +page_is_file_cache (page));putback_lru_page (page); }
@@ -1244,7 +1244,7 @@ static int do_move_page_to_node_array(struct mm_struct *mm, err =isolate_lru_page (page);if (!err) {list_add_tail (&page->lru, &pagelist); -inc_zone_page_state (page,NR_ISOLATED_ANON + +inc_node_page_state (page,NR_ISOLATED_ANON +page_is_file_cache (page)); } put_and_set:
@@ -1514,15 +1514,16 @@ static bool migrate_balanced_pgdat(struct pglist_data *pgdat, unsigned long nr_migrate_pages) { int z; + + if (!pgdat_reclaimable(pgdat)) + return false; + for (z = pgdat->nr_zones - 1; z >= 0; z--) { struct zone *zone = pgdat->node_zones + z; if (!populated_zone(zone)) continue; - if (!zone_reclaimable(zone)) - continue; - /* Avoid waking kswapd by allocating pages_to_migrate pages. */ if (!zone_watermark_ok(zone, 0, high_wmark_pages(zone) +
@@ -1636,7 +1637,7 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) } page_lru =page_is_file_cache (page); -mod_zone_page_state (page_zone (page),NR_ISOLATED_ANON + page_lru, +mod_node_page_state (page_zone (page)->zone_pgdat,NR_ISOLATED_ANON + page_lru,hpage_nr_pages (page));/*
@@ -1694,7 +1695,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma,if (nr_remaining) {if (!list_empty (&migratepages)) {list_del (&page->lru); -dec_zone_page_state (page,NR_ISOLATED_ANON + +dec_node_page_state (page,NR_ISOLATED_ANON +page_is_file_cache (page));putback_lru_page (page); }
@@ -1784,7 +1785,7 @@ fail_putback:/* Retake the callers reference and putback on LRU */ get_page (page);putback_lru_page (page); -mod_zone_page_state (page_zone (page), +mod_node_page_state (page_zone (page)->zone_pgdat,NR_ISOLATED_ANON + page_lru, -HPAGE_PMD_NR ); goto out_unlock;
@@ -1837,7 +1838,7 @@ fail_putback:count_vm_events (PGMIGRATE_SUCCESS ,HPAGE_PMD_NR );count_vm_numa_events (NUMA_PAGE_MIGRATE ,HPAGE_PMD_NR ); -mod_zone_page_state (page_zone (page), +mod_node_page_state (page_zone (page)->zone_pgdat,NR_ISOLATED_ANON + page_lru, -HPAGE_PMD_NR );return isolated;
mm/mlock.c +1 -1
@@ -100,7 +100,7 @@ static bool __munlock_isolate_lru_page(struct page *page, bool getpage)if (PageLRU (page)) {struct lruvec *lruvec; - lruvec =mem_cgroup_page_lruvec (page,page_zone (page)); + lruvec =mem_cgroup_page_lruvec (page,page_zone (page)->zone_pgdat);if (getpage)get_page (page);ClearPageLRU (page);
mm/page-writeback.c +4 -4
@@ -187,8 +187,8 @@ static unsigned long zone_dirtyable_memory(struct zone *zone) nr_pages =zone_page_state (zone,NR_FREE_PAGES ); nr_pages -=min (nr_pages, zone->dirty_balance_reserve); - nr_pages +=zone_page_state (zone,NR_INACTIVE_FILE ); - nr_pages +=zone_page_state (zone,NR_ACTIVE_FILE ); + nr_pages +=node_page_state (zone->zone_pgdat,NR_INACTIVE_FILE ); + nr_pages +=node_page_state (zone->zone_pgdat,NR_ACTIVE_FILE );return nr_pages; }
@@ -241,8 +241,8 @@ static unsigned long global_dirtyable_memory(void) x =global_page_state (NR_FREE_PAGES ); x -=min (x, dirty_balance_reserve); - x +=global_page_state (NR_INACTIVE_FILE ); - x +=global_page_state (NR_ACTIVE_FILE ); + x +=global_node_page_state (NR_INACTIVE_FILE ); + x +=global_node_page_state (NR_ACTIVE_FILE );if (!vm_highmem_is_dirtyable) x -=highmem_dirtyable_memory (x);
mm/page_alloc.c +60 -43
201 lines not on this page · raw message
mm/swap.c +28 -28
129 lines not on this page · raw message
mm/vmscan.c +110 -98
559 lines not on this page · raw message
mm/vmstat.c +23 -22
102 lines not on this page · raw message
mm/workingset.c +4 -4
@@ -180,7 +180,7 @@ static void unpack_shadow(void *shadow, *zone =NODE_DATA (nid)->node_zones + zid; - refault =atomic_long_read (&(*zone)->inactive_age); + refault =atomic_long_read (&(*zone)->zone_pgdat->inactive_age); mask = ~0UL >> (NODES_SHIFT +ZONES_SHIFT +RADIX_TREE_EXCEPTIONAL_SHIFT );/*
@@ -215,7 +215,7 @@ void *workingset_eviction(struct address_space *mapping, struct page *page)struct zone *zone =page_zone (page);unsigned long eviction; - eviction =atomic_long_inc_return (&zone->inactive_age); + eviction =atomic_long_inc_return (&zone->zone_pgdat->inactive_age);return pack_shadow (eviction, zone); }
@@ -236,7 +236,7 @@ bool workingset_refault(void *shadow)unpack_shadow (shadow, &zone, &refault_distance);inc_zone_state (zone,WORKINGSET_REFAULT ); -if (refault_distance <=zone_page_state (zone,NR_ACTIVE_FILE )) { +if (refault_distance <=node_page_state (zone->zone_pgdat,NR_ACTIVE_FILE )) {inc_zone_state (zone,WORKINGSET_ACTIVATE );return true; }
@@ -249,7 +249,7 @@ bool workingset_refault(void *shadow)*/ void workingset_activation (struct page *page) { -atomic_long_inc (&page_zone (page)->inactive_age); +atomic_long_inc (&page_zone (page)->zone_pgdat->inactive_age); }/*
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/25 mm, vmscan: Begin reclaiming pages on a per-node basis
In reply to Mel GormanThis patch makes reclaim decisions on a per-node basis. A reclaimer knows what zone is required by the allocation request and skips unrelated pages. In many cases this will be ok because it's a GFP_HIGHMEM request of some description. On 64-bit, ZONE_DMA32 requests will cause some problems but 32-bit devices on 64-bit platforms are getting more rare. Historically it would have been a major problem on 32-bit with big Highmem:Lowmem ratios but that is also becoming very rare. If it really becomes a problem, it'll manifest as very low reclaim efficiencies.
--- mm/vmscan.c | 75 ++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 30 deletions(-)
mm/vmscan.c +45 -30
@@ -83,6 +83,9 @@ struct scan_control {/* Scan (total_size >> priority) pages at once */ int priority; +/* The highest zone to isolate pages for reclaim from */ +enum zone_type reclaim_idx; + unsigned int may_writepage:1;/* Can mapped pages be reclaimed? */
@@ -1319,6 +1322,7 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,struct list_head *src = &lruvec->lists[lru];unsigned long nr_taken =0 ;unsigned long scan; +LIST_HEAD (pages_skipped);for (scan =0 ; scan < nr_to_scan && !list_empty (src); scan++) {struct page *page;
@@ -1329,6 +1333,9 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,VM_BUG_ON_PAGE (!PageLRU (page), page); +if (page_zone_id (page) > sc->reclaim_idx) +list_move (&page->lru, &pages_skipped); +switch (__isolate_lru_page (page, mode)) {case 0 : nr_pages =hpage_nr_pages (page);
@@ -1347,6 +1354,15 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, } } +/* +* Splice any skipped pages to the start of the LRU list. Note that +* this disrupts the LRU order when reclaiming for lower zones but +* we cannot splice to the tail. If we did then the SWAP_CLUSTER_MAX +* scanning would soon rescan the same pages to skip and put the +* system at risk of premature OOM. +*/ +if (!list_empty (&pages_skipped)) +list_splice (&pages_skipped, src); *nr_scanned = scan;trace_mm_vmscan_lru_isolate (sc->order, nr_to_scan, scan, nr_taken, mode,is_file_lru (lru));
@@ -1508,7 +1524,7 @@ static int current_may_throttle(void) }/* -* shrink_inactive_list() is a helper for shrink_zone(). It returns the number +* shrink_inactive_list() is a helper for shrink_node(). It returns the number * of reclaimed pages */ static noinline_for_stack unsigned long
@@ -2319,12 +2335,14 @@ static inline bool should_continue_reclaim(struct zone *zone, } } -static bool shrink_zone (struct zone *zone,struct scan_control *sc, -bool is_classzone) +static bool shrink_node (pg_data_t *pgdat,struct scan_control *sc, +enum zone_type reclaim_idx, +enum zone_type classzone_idx) {struct reclaim_state *reclaim_state = current->reclaim_state;unsigned long nr_reclaimed, nr_scanned;bool reclaimable = false; +struct zone *zone = &pgdat->node_zones[classzone_idx]; do { struct mem_cgroup *root = sc->target_mem_cgroup;
@@ -2355,10 +2373,11 @@ static bool shrink_zone(struct zone *zone, struct scan_control *sc, swappiness =mem_cgroup_swappiness (memcg); scanned = sc->nr_scanned; + sc->reclaim_idx = reclaim_idx;shrink_lruvec (lruvec, swappiness, sc, &lru_pages); zone_lru_pages += lru_pages; -if (memcg && is_classzone) +if (!global_reclaim (sc) && reclaim_idx == classzone_idx)shrink_slab (sc->gfp_mask,zone_to_nid (zone), memcg, sc->nr_scanned - scanned, lru_pages);
@@ -2384,7 +2403,7 @@ static bool shrink_zone(struct zone *zone, struct scan_control *sc,* Shrink the slab caches in the same proportion that * the eligible LRU pages were scanned. */ -if (global_reclaim (sc) && is_classzone) +if (global_reclaim (sc) && reclaim_idx == classzone_idx)shrink_slab (sc->gfp_mask,zone_to_nid (zone),NULL , sc->nr_scanned - nr_scanned, zone_lru_pages);
@@ -2462,14 +2481,14 @@ static inline bool compaction_ready(struct zone *zone, int order)* * Returns true if a zone was reclaimable. */ -static bool shrink_zones (struct zonelist *zonelist,struct scan_control *sc) +static bool shrink_zones (struct zonelist *zonelist,struct scan_control *sc, +enum zone_type reclaim_idx,enum zone_type classzone_idx) {struct zoneref *z;struct zone *zone;unsigned long nr_soft_reclaimed;unsigned long nr_soft_scanned;gfp_t orig_mask; -enum zone_type requested_highidx =gfp_zone (sc->gfp_mask);bool reclaimable = false;/*
@@ -2482,16 +2501,12 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc) sc->gfp_mask |= __GFP_HIGHMEM;for_each_zone_zonelist_nodemask (zone, z, zonelist, - requested_highidx, sc->nodemask) { -enum zone_type classzone_idx; - -if (!populated_zone (zone)) -continue ; - - classzone_idx = requested_highidx; -while (!populated_zone (zone->zone_pgdat->node_zones + - classzone_idx)) + classzone_idx, sc->nodemask) { +if (!populated_zone (zone)) { + reclaim_idx--; classzone_idx--; +continue ; + }/* * Take care memory controller reclaiming has small influence
@@ -2517,7 +2532,7 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)*/ if (IS_ENABLED (CONFIG_COMPACTION ) && sc->order >PAGE_ALLOC_COSTLY_ORDER && -zonelist_zone_idx (z) <= requested_highidx && +zonelist_zone_idx (z) <= classzone_idx &&compaction_ready (zone, sc->order)) { sc->compaction_ready = true;continue ;
@@ -2537,10 +2552,10 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc) sc->nr_scanned += nr_soft_scanned;if (nr_soft_reclaimed) reclaimable = true; -/* need some check for avoid more shrink_zone() */ +/* need some check for avoid more shrink_node() */ } -if (shrink_zone (zone, sc,zone_idx (zone) == classzone_idx)) +if (shrink_node (zone->zone_pgdat, sc, reclaim_idx, classzone_idx)) reclaimable = true; if (global_reclaim(sc) &&
@@ -2580,6 +2595,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,unsigned long total_scanned =0 ;unsigned long writeback_threshold;bool zones_reclaimable; +enum zone_type classzone_idx =gfp_zone (sc->gfp_mask); retry:delayacct_freepages_start ();
@@ -2590,7 +2606,7 @@ retry:vmpressure_prio (sc->gfp_mask, sc->target_mem_cgroup, sc->priority); sc->nr_scanned =0 ; - zones_reclaimable =shrink_zones (zonelist, sc); + zones_reclaimable =shrink_zones (zonelist, sc, classzone_idx, classzone_idx); total_scanned += sc->nr_scanned;if (sc->nr_reclaimed >= sc->nr_to_reclaim)
@@ -3058,7 +3074,7 @@ static bool kswapd_shrink_zone(struct zone *zone, balance_gap, classzone_idx))return true; -shrink_zone (zone, sc,zone_idx (zone) == classzone_idx); +shrink_node (zone->zone_pgdat, sc,zone_idx (zone), classzone_idx);/* Account for the number of pages attempted to reclaim */ *nr_attempted += sc->nr_to_reclaim;
@@ -3201,15 +3217,14 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, sc.may_writepage =1 ;/* -* Now scan the zone in the dma->highmem direction, stopping -* at the last zone which needs scanning. -* -* We do this because the page allocator works in the opposite -* direction. This prevents the page allocator from allocating -* pages behind kswapd's direction of progress, which would -* cause too much scanning of the lower zones. +* Continue scanning in the highmem->dma direction stopping at +* the last zone which needs scanning. This may reclaim lowmem +* pages that are not necessary for zone balancing but it +* preserves LRU ordering. It is assumed that the bulk of +* allocation requests can use arbitrary zones with the +* possible exception of big highmem:lowmem configurations. */ -for (i =0 ; i <= end_zone; i++) { +for (i = end_zone; i >= end_zone; i--) {struct zone *zone = pgdat->node_zones + i;if (!populated_zone (zone))
@@ -3707,7 +3722,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)* priorities until we have enough memory freed. */ do { -shrink_zone (zone, &sc, true); +shrink_node (zone->zone_pgdat, &sc,zone_idx (zone),zone_idx (zone)); }while (sc.nr_reclaimed < nr_pages && --sc.priority >=0 ); }
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 5/25 mm, vmscan: Have kswapd only scan based on the highest requested zone
In reply to Mel Gormankswapd checks all eligible zones to see if they need balancing even if it was woken for a lower zone. This made sense when we reclaimed on a per-zone basis because we wanted to shrink zones fairly so avoid age-inversion problems. Ideally this is completely unnecessary when reclaiming on a per-node basis. In theory, there may still be anomalies when all requests are for lower zones and very old pages are preserved in higher zones but this should be the exceptional case.
--- mm/vmscan.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
mm/vmscan.c +2 -5
@@ -3142,11 +3142,8 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, sc.nr_reclaimed =0 ; -/* -* Scan in the highmem->dma direction for the highest -* zone which needs scanning -*/ -for (i = pgdat->nr_zones -1 ; i >=0 ; i--) { +/* Scan from the highest requested zone to dma */ +for (i = *classzone_idx; i >=0 ; i--) {struct zone *zone = pgdat->node_zones + i;if (!populated_zone (zone))
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 6/25 mm, vmscan: Avoid a second search through zones checking if compaction is required
In reply to Mel GormanThis patch removes an unnecessary loop.
--- mm/vmscan.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-)
mm/vmscan.c +13 -18
@@ -3182,30 +3182,25 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order,*/ clear_bit (PGDAT_CONGESTED , &zone->zone_pgdat->flags);clear_bit (PGDAT_DIRTY , &zone->zone_pgdat->flags); + +/* +* If any zone is currently balanced then kswapd will +* not call compaction as it is expected that the +* necessary pages are already available. +*/ +if (pgdat_needs_compaction && +zone_watermark_ok (zone, order, +low_wmark_pages (zone), + *classzone_idx,0 )) { + pgdat_needs_compaction = false; + } + } }if (i <0 ) goto out; -for (i =0 ; i <= end_zone; i++) { -struct zone *zone = pgdat->node_zones + i; - -if (!populated_zone (zone)) -continue ; - -/* -* If any zone is currently balanced then kswapd will -* not call compaction as it is expected that the -* necessary pages are already available. -*/ -if (pgdat_needs_compaction && -zone_watermark_ok (zone, order, -low_wmark_pages (zone), - *classzone_idx,0 )) - pgdat_needs_compaction = false; - } -/* * If we're getting trouble reclaiming, start doing writepage * even in laptop mode.
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 7/25 mm, vmscan: Make kswapd think of reclaim in terms of nodes
In reply to Mel GormanPatch "mm: vmscan: Begin reclaiming pages on a per-node basis" was the start of thinking of reclaim in terms of nodes but kswapd is still very zone-centric. This patch gets rid of many of the node-based versus zone-based decisions.
o A node is considered balanced when any eligible lower zone is balanced. This eliminates one class of age-inversion problem because we avoid reclaiming a newer page just because it's in the wrong zone
o pgdat_balanced disappears because we now only care about one zone being balanced.
o Some anomalies related to writeback and congestion tracking being based on zones disappear.
o kswapd no longer has to take care to reclaim zones in the reverse order that the page allocator uses.
o Most importantly of all, reclaim from node 0 which often has multiple zones will have similar aging and reclaiming characteristics as every other node.
--- mm/vmscan.c | 264 ++++++++++++++++++++---------------------------------------- 1 file changed, 87 insertions(+), 177 deletions(-)
mm/vmscan.c +87 -177
@@ -2900,7 +2900,8 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, }#endif -static void age_active_anon (struct zone *zone,struct scan_control *sc) +static void age_active_anon (struct pglist_data *pgdat, +struct zone *zone,struct scan_control *sc) {struct mem_cgroup *memcg;
@@ -2934,65 +2935,6 @@ static bool zone_balanced(struct zone *zone, int order, }/* -* pgdat_balanced() is used when checking if a node is balanced. -* -* For order-0, all zones must be balanced! -* -* For high-order allocations only zones that meet watermarks and are in a -* zone allowed by the callers classzone_idx are added to balanced_pages. The -* total of balanced pages must be at least 25% of the zones allowed by -* classzone_idx for the node to be considered balanced. Forcing all zones to -* be balanced for high orders can cause excessive reclaim when there are -* imbalanced zones. -* The choice of 25% is due to -* o a 16M DMA zone that is balanced will not balance a zone on any -* reasonable sized machine -* o On all other machines, the top zone must be at least a reasonable -* percentage of the middle zones. For example, on 32-bit x86, highmem -* would need to be at least 256M for it to be balance a whole node. -* Similarly, on x86-64 the Normal zone would need to be at least 1G -* to balance a node on its own. These seemed like reasonable ratios. -*/ -static bool pgdat_balanced (pg_data_t *pgdat,int order,int classzone_idx) -{ -unsigned long managed_pages =0 ; -unsigned long balanced_pages =0 ; -int i; - -/* Check the watermark levels */ -for (i =0 ; i <= classzone_idx; i++) { -struct zone *zone = pgdat->node_zones + i; - -if (!populated_zone (zone)) -continue ; - - managed_pages += zone->managed_pages; - -/* -* A special case here: -* -* balance_pgdat() skips over all_unreclaimable after -* DEF_PRIORITY. Effectively, it considers them balanced so -* they must be considered balanced here as well! -*/ -if (!pgdat_reclaimable (zone->zone_pgdat)) { - balanced_pages += zone->managed_pages; -continue ; - } - -if (zone_balanced (zone, order,0 , i)) - balanced_pages += zone->managed_pages; -else if (!order) -return false; - } - -if (order) -return balanced_pages >= (managed_pages >>2 ); -else -return true; -} - -/* * Prepare kswapd for sleeping. This verifies that there are no processes * waiting in throttle_direct_reclaim() and that watermarks have been met. *
@@ -3001,6 +2943,8 @@ static bool pgdat_balanced(pg_data_t *pgdat, int order, int classzone_idx)static bool prepare_kswapd_sleep (pg_data_t *pgdat,int order,long remaining,int classzone_idx) { +int i; +/* If a direct reclaimer woke kswapd within HZ/10, it's premature */ if (remaining)return false;
@@ -3021,78 +2965,69 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, long remaining,if (waitqueue_active (&pgdat->pfmemalloc_wait))wake_up_all (&pgdat->pfmemalloc_wait); -return pgdat_balanced (pgdat, order, classzone_idx); +for (i =0 ; i <= classzone_idx; i++) { +struct zone *zone = pgdat->node_zones + i; + +if (zone_balanced (zone, order,0 , classzone_idx)) +return true; + } + +return false; }/* -* kswapd shrinks the zone by the number of pages required to reach -* the high watermark. +* kswapd shrinks a node of pages that are at or below the highest usable +* zone that is currently unbalanced. * * Returns true if kswapd scanned at least the requested number of pages to * reclaim or if the lack of progress was due to pages under writeback. * This is used to determine if the scanning priority needs to be raised. */ -static bool kswapd_shrink_zone (struct zone *zone, -int classzone_idx, -struct scan_control *sc, +static bool kswapd_shrink_node (pg_data_t *pgdat, +int end_zone,struct scan_control *sc,unsigned long *nr_attempted) { -int testorder = sc->order; -unsigned long balance_gap; -bool lowmem_pressure; -struct pglist_data *pgdat = zone->zone_pgdat; +struct zone *zone; +unsigned long nr_to_reclaim =0 ; +int z; -/* Reclaim above the high watermark. */ - sc->nr_to_reclaim =max (SWAP_CLUSTER_MAX ,high_wmark_pages (zone)); +/* Aim to reclaim above all the zone high watermarks */ +for (z =0 ; z <= end_zone; z++) { + zone = pgdat->node_zones + end_zone; + nr_to_reclaim +=high_wmark_pages (zone); -/* -* Kswapd reclaims only single pages with compaction enabled. Trying -* too hard to reclaim until contiguous free pages have become -* available can hurt performance by evicting too much useful data -* from memory. Do not reclaim more than needed for compaction. -*/ -if (IS_ENABLED (CONFIG_COMPACTION ) && sc->order && -compaction_suitable (zone, sc->order,0 , classzone_idx) +/* +* Kswapd reclaims only single pages with compaction enabled. +* Trying too hard to reclaim until contiguous free pages have +* become available can hurt performance by evicting too much +* useful data from memory. Do not reclaim more than needed +* for compaction. +*/ +if (IS_ENABLED (CONFIG_COMPACTION ) && sc->order && +compaction_suitable (zone, sc->order,0 , end_zone) !=COMPACT_SKIPPED ) - testorder =0 ; - -/* -* We put equal pressure on every zone, unless one zone has way too -* many pages free already. The "too many pages" is defined as the -* high wmark plus a "gap" where the gap is either the low -* watermark or 1% of the zone, whichever is smaller. -*/ - balance_gap =min (low_wmark_pages (zone),DIV_ROUND_UP ( - zone->managed_pages,KSWAPD_ZONE_BALANCE_GAP_RATIO )); + sc->order =0 ; + } + sc->nr_to_reclaim =max (SWAP_CLUSTER_MAX , nr_to_reclaim);/* -* If there is no low memory pressure or the zone is balanced then no -* reclaim is necessary +* Historically care was taken to put equal pressure on all zones but +* now pressure is applied based on node LRU order. */ - lowmem_pressure = (buffer_heads_over_limit &&is_highmem (zone)); -if (!lowmem_pressure &&zone_balanced (zone, testorder, - balance_gap, classzone_idx)) -return true; - -shrink_node (zone->zone_pgdat, sc,zone_idx (zone), classzone_idx); +shrink_node (zone->zone_pgdat, sc, end_zone, end_zone);/* Account for the number of pages attempted to reclaim */ *nr_attempted += sc->nr_to_reclaim; -/* TODO: ANOMALY */ -clear_bit (PGDAT_WRITEBACK , &pgdat->flags); -/* -* If a zone reaches its high watermark, consider it to be no longer -* congested. It's possible there are dirty pages backed by congested -* BDIs but as pressure is relieved, speculatively avoid congestion -* waits. +* Fragmentation may mean that the system cannot be rebalanced for +* high-order allocations. If twice the allocation size has been +* reclaimed then recheck watermarks only at order-0 to prevent +* excessive reclaim. Assume that a process requested a high-order +* can direct reclaim/compact. */ -if (pgdat_reclaimable (zone->zone_pgdat) && -zone_balanced (zone, testorder,0 , classzone_idx)) { -clear_bit (PGDAT_CONGESTED , &pgdat->flags); -clear_bit (PGDAT_DIRTY , &pgdat->flags); - } +if (sc->order && sc->nr_reclaimed >=2UL << sc->order) + sc->order =0 ;return sc->nr_scanned >= sc->nr_to_reclaim; }
@@ -3122,9 +3057,10 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, int *classzone_idx) {int i; -int end_zone =0 ;/* Inclusive. 0 = ZONE_DMA */ +int end_zone =MAX_NR_ZONES -1 ;unsigned long nr_soft_reclaimed;unsigned long nr_soft_scanned; +struct zone *zone;struct scan_control sc = { .gfp_mask =GFP_KERNEL , .order = order,
@@ -3142,23 +3078,16 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, sc.nr_reclaimed =0 ; +/* Allow writeout later if the pgdat appears unreclaimable */ +if (!pgdat_reclaimable (pgdat)) + sc.priority =min (sc.priority,DEF_PRIORITY -3 ); +/* Scan from the highest requested zone to dma */ for (i = *classzone_idx; i >=0 ; i--) { -struct zone *zone = pgdat->node_zones + i; - + zone = pgdat->node_zones + i;if (!populated_zone (zone))continue ; -if (sc.priority !=DEF_PRIORITY && - !pgdat_reclaimable (zone->zone_pgdat)) -continue ; - -/* -* Do some background aging of the anon list, to give -* pages a chance to be referenced before reclaiming. -*/ -age_active_anon (zone, &sc); -/* * If the number of buffer_heads in the machine * exceeds the maximum allowed level and this node
@@ -3175,10 +3104,8 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order,break ; }else {/* -* If balanced, clear the dirty and congested -* flags -* -* TODO: ANOMALY +* If any eligible zone is balanced then the +* node is not considered congested or dirty. */ clear_bit (PGDAT_CONGESTED , &zone->zone_pgdat->flags);clear_bit (PGDAT_DIRTY , &zone->zone_pgdat->flags);
@@ -3202,51 +3129,32 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, goto out;/* +* Do some background aging of the anon list, to give +* pages a chance to be referenced before reclaiming. +*/ +age_active_anon (pgdat, &pgdat->node_zones[end_zone], &sc); + +/* * If we're getting trouble reclaiming, start doing writepage * even in laptop mode. */ if (sc.priority <DEF_PRIORITY -2 ) sc.may_writepage =1 ; +/* Call soft limit reclaim before calling shrink_node. */ + sc.nr_scanned =0 ; + nr_soft_scanned =0 ; + nr_soft_reclaimed =mem_cgroup_soft_limit_reclaim (zone, order, + sc.gfp_mask, &nr_soft_scanned); + sc.nr_reclaimed += nr_soft_reclaimed; +/* -* Continue scanning in the highmem->dma direction stopping at -* the last zone which needs scanning. This may reclaim lowmem -* pages that are not necessary for zone balancing but it -* preserves LRU ordering. It is assumed that the bulk of -* allocation requests can use arbitrary zones with the -* possible exception of big highmem:lowmem configurations. +* There should be no need to raise the scanning priority if +* enough pages are already being scanned that that high +* watermark would be met at 100% efficiency. */ -for (i = end_zone; i >= end_zone; i--) { -struct zone *zone = pgdat->node_zones + i; - -if (!populated_zone (zone)) -continue ; - -if (sc.priority !=DEF_PRIORITY && - !pgdat_reclaimable (zone->zone_pgdat)) -continue ; - - sc.nr_scanned =0 ; - - nr_soft_scanned =0 ; -/* -* Call soft limit reclaim before calling shrink_zone. -*/ - nr_soft_reclaimed =mem_cgroup_soft_limit_reclaim (zone, - order, sc.gfp_mask, - &nr_soft_scanned); - sc.nr_reclaimed += nr_soft_reclaimed; - -/* -* There should be no need to raise the scanning -* priority if enough pages are already being scanned -* that that high watermark would be met at 100% -* efficiency. -*/ -if (kswapd_shrink_zone (zone, end_zone, - &sc, &nr_attempted)) - raise_priority = false; - } +if (kswapd_shrink_node (pgdat, end_zone, &sc, &nr_attempted)) + raise_priority = false;/* * If the low watermark is met there is no need for processes
@@ -3257,17 +3165,6 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, pfmemalloc_watermark_ok(pgdat))wake_up_all (&pgdat->pfmemalloc_wait); -/* -* Fragmentation may mean that the system cannot be rebalanced -* for high-order allocations in all zones. If twice the -* allocation size has been reclaimed and the zones are still -* not balanced then recheck the watermarks at order-0 to -* prevent kswapd reclaiming excessively. Assume that a -* process requested a high-order can direct reclaim/compact. -*/ -if (order && sc.nr_reclaimed >=2UL << order) - order = sc.order =0 ; -/* Check if kswapd should be suspending */ if (try_to_freeze () ||kthread_should_stop ())break ;
@@ -3280,13 +3177,26 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order,compact_pgdat (pgdat, order);/* +* Stop reclaiming if any eligible zone is balanced and clear +* node writeback or congested. +*/ +for (i =0 ; i <= *classzone_idx; i++) { + zone = pgdat->node_zones + i; + +if (zone_balanced (zone, sc.order,0 , *classzone_idx)) { +clear_bit (PGDAT_CONGESTED , &pgdat->flags); +clear_bit (PGDAT_DIRTY , &pgdat->flags); +break ; + } + } + +/* * Raise priority if scanning rate is too low or there was no * progress in reclaiming pages */ if (raise_priority || !sc.nr_reclaimed) sc.priority--; - }while (sc.priority >=1 && - !pgdat_balanced (pgdat, order, *classzone_idx)); + }while (sc.priority >=1 ); out:/*
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 8/25 mm, vmscan: By default have direct reclaim only shrink once per node
In reply to Mel GormanDirect reclaim iterates over all zones in the zonelist and shrinking them but this is in conflict with node-based reclaim. In the default case, only shrink once per node.
--- mm/vmscan.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
mm/vmscan.c +12 -12
@@ -2468,14 +2468,6 @@ static inline bool compaction_ready(struct zone *zone, int order)* try to reclaim pages from zones which will satisfy the caller's allocation * request. * -* We reclaim from a zone even if that zone is over high_wmark_pages(zone). -* Because: -* a) The caller may be trying to free *extra* pages to satisfy a higher-order -* allocation or -* b) The target zone may be at high_wmark_pages(zone) but the lower zones -* must go *over* high_wmark_pages(zone) to satisfy the `incremental min' -* zone defense algorithm. -* * If a zone is deemed to be full of pinned pages then just give it a light * scan then give up on it. *
@@ -2490,6 +2482,7 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc,unsigned long nr_soft_scanned;gfp_t orig_mask;bool reclaimable = false; +pg_data_t *last_pgdat =NULL ;/* * If the number of buffer_heads in the machine exceeds the maximum
@@ -2502,11 +2495,18 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc,for_each_zone_zonelist_nodemask (zone, z, zonelist, classzone_idx, sc->nodemask) { -if (!populated_zone (zone)) { - reclaim_idx--; - classzone_idx--; +BUG_ON (!populated_zone (zone)); + +/* +* Shrink each node in the zonelist once. If the zonelist is +* ordered by zone (not the default) then a node may be +* shrunk multiple times but in that case the user prefers +* lower zones being preserved +*/ +if (zone->zone_pgdat == last_pgdat)continue ; - } + last_pgdat = zone->zone_pgdat; + reclaim_idx =zone_idx (zone);/* * Take care memory controller reclaiming has small influence
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 9/25 mm, vmscan: Clear congestion, dirty and need for compaction on a per-node basis
In reply to Mel GormanCongested and dirty tracking of a node and whether reclaim should stall is still based on zone activity. This patch considers whether the kernel should stall based on node-based reclaim activity.
--- mm/vmscan.c | 54 ++++++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 30 deletions(-)
mm/vmscan.c +24 -30
@@ -2921,16 +2921,30 @@ static void age_active_anon(struct pglist_data *pgdat, }static bool zone_balanced (struct zone *zone,int order, -unsigned long balance_gap,int classzone_idx) +unsigned long balance_gap,int classzone_idx, +bool *pgdat_needs_compaction) {if (!zone_watermark_ok_safe (zone, order,high_wmark_pages (zone) + balance_gap, classzone_idx,0 ))return false; +/* +* If any eligible zone is balanced then the node is not considered +* to be congested or dirty +*/ +clear_bit (PGDAT_CONGESTED , &zone->zone_pgdat->flags); +clear_bit (PGDAT_DIRTY , &zone->zone_pgdat->flags); +if (IS_ENABLED (CONFIG_COMPACTION ) && order &&compaction_suitable (zone, order,0 , classzone_idx) ==COMPACT_SKIPPED )return false; +/* +* If a zone is balanced and compaction can start then there is no +* need for kswapd to call compact_pgdat +*/ + *pgdat_needs_compaction = false; +return true; }
@@ -2944,6 +2958,7 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, long remaining, int classzone_idx) {int i; +bool dummy;/* If a direct reclaimer woke kswapd within HZ/10, it's premature */ if (remaining)
@@ -2968,7 +2983,7 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, long remaining,for (i =0 ; i <= classzone_idx; i++) {struct zone *zone = pgdat->node_zones + i; -if (zone_balanced (zone, order,0 , classzone_idx)) +if (zone_balanced (zone, order,0 , classzone_idx, &dummy))return true; }
@@ -3099,29 +3114,10 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order,break ; } -if (!zone_balanced (zone, order,0 ,0 )) { +if (!zone_balanced (zone, order,0 ,0 , + &pgdat_needs_compaction)) { end_zone = i;break ; - }else { -/* -* If any eligible zone is balanced then the -* node is not considered congested or dirty. -*/ -clear_bit (PGDAT_CONGESTED , &zone->zone_pgdat->flags); -clear_bit (PGDAT_DIRTY , &zone->zone_pgdat->flags); - -/* -* If any zone is currently balanced then kswapd will -* not call compaction as it is expected that the -* necessary pages are already available. -*/ -if (pgdat_needs_compaction && -zone_watermark_ok (zone, order, -low_wmark_pages (zone), - *classzone_idx,0 )) { - pgdat_needs_compaction = false; - } - } }
@@ -3182,12 +3178,9 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order,*/ for (i =0 ; i <= *classzone_idx; i++) { zone = pgdat->node_zones + i; - -if (zone_balanced (zone, sc.order,0 , *classzone_idx)) { -clear_bit (PGDAT_CONGESTED , &pgdat->flags); -clear_bit (PGDAT_DIRTY , &pgdat->flags); -break ; - } +if (zone_balanced (zone, sc.order,0 , *classzone_idx, + &pgdat_needs_compaction)) + goto out; }/*
@@ -3379,6 +3372,7 @@ static int kswapd(void *p)void wakeup_kswapd (struct zone *zone,int order,enum zone_type classzone_idx) {pg_data_t *pgdat; +bool dummy;if (!populated_zone (zone))return ;
@@ -3392,7 +3386,7 @@ void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx) }if (!waitqueue_active (&pgdat->kswapd_wait))return ; -if (zone_balanced (zone, order,0 ,0 )) +if (zone_balanced (zone, order,0 ,0 , &dummy))return ;trace_mm_vmscan_wakeup_kswapd (pgdat->node_id,zone_idx (zone), order);
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 10/25 mm, vmscan: Make shrink_node decisions more node-centric
In reply to Mel GormanEarlier patches focused on having direct reclaim and kswapd use data that is node-centric for reclaiming but shrink_node() itself still uses too much zone information. This patch removes unnecessary zone-based information with the most important decision being whether to continue reclaim or not. Some memcg APIs are adjusted as a result even though memcg itself still uses some zone information.
--- include/linux/memcontrol.h | 9 ++++---- include/linux/mmzone.h | 4 ++-- include/linux/swap.h | 2 +- mm/memcontrol.c | 17 ++++++++------- mm/page_alloc.c | 2 +- mm/vmscan.c | 53 ++++++++++++++++++++++++++-------------------- 6 files changed, 48 insertions(+), 39 deletions(-)
include/linux/memcontrol.h +5 -4
@@ -84,7 +84,8 @@ void mem_cgroup_uncharge_list(struct list_head *page_list);void mem_cgroup_migrate (struct page *oldpage,struct page *newpage,bool lrucare); -struct lruvec *mem_cgroup_zone_lruvec (struct zone *,struct mem_cgroup *); +struct lruvec *mem_cgroup_lruvec (struct pglist_data *,struct zone *zone, +struct mem_cgroup *);struct lruvec *mem_cgroup_page_lruvec (struct page *,struct pglist_data *); bool mem_cgroup_is_descendant(struct mem_cgroup *memcg,
@@ -240,10 +241,10 @@ static inline void mem_cgroup_migrate(struct page *oldpage, { } -static inline struct lruvec *mem_cgroup_zone_lruvec (struct zone *zone, -struct mem_cgroup *memcg) +static inline struct lruvec *mem_cgroup_lruvec (struct pglist_data *pgdat, +struct zone *zone,struct mem_cgroup *memcg) { -return zone_lruvec (zone); +return node_lruvec (pgdat); } static inline struct lruvec *mem_cgroup_page_lruvec(struct page *page,
include/linux/mmzone.h +2 -2
@@ -799,9 +799,9 @@ static inline spinlock_t *zone_lru_lock(struct zone *zone)return &zone->zone_pgdat->lru_lock; } -static inline struct lruvec *zone_lruvec (struct zone *zone) +static inline struct lruvec *node_lruvec (struct pglist_data *pgdat) { -return &zone->zone_pgdat->lruvec; +return &pgdat->lruvec; }static inline unsigned long pgdat_end_pfn (pg_data_t *pgdat)
include/linux/swap.h +1 -1
@@ -323,7 +323,7 @@ extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,unsigned long nr_pages, gfp_t gfp_mask, bool may_swap); -extern unsigned long mem_cgroup_shrink_node_zone (struct mem_cgroup *mem, +extern unsigned long mem_cgroup_shrink_node (struct mem_cgroup *mem,gfp_t gfp_mask,bool noswap,struct zone *zone,unsigned long *nr_scanned);
mm/memcontrol.c +9 -8
@@ -1170,22 +1170,23 @@ out:EXPORT_SYMBOL (__mem_cgroup_count_vm_event);/** -* mem_cgroup_zone_lruvec - get the lru list vector for a zone and memcg +* mem_cgroup_lruvec - get the lru list vector for a node or a memcg zone +* @node: node of the wanted lruvec * @zone: zone of the wanted lruvec * @memcg: memcg of the wanted lruvec * -* Returns the lru list vector holding pages for the given @zone and -* @mem. This can be the global zone lruvec, if the memory controller +* Returns the lru list vector holding pages for a given @node or a given +* @memcg and @zone. This can be the node lruvec, if the memory controller * is disabled. */ -struct lruvec *mem_cgroup_zone_lruvec (struct zone *zone, -struct mem_cgroup *memcg) +struct lruvec *mem_cgroup_lruvec (struct pglist_data *pgdat, +struct zone *zone,struct mem_cgroup *memcg) {struct mem_cgroup_per_zone *mz;struct lruvec *lruvec;if (mem_cgroup_disabled ()) { - lruvec =zone_lruvec (zone); + lruvec =node_lruvec (pgdat); goto out; }
@@ -1721,8 +1722,8 @@ static int mem_cgroup_soft_reclaim(struct mem_cgroup *root_memcg, }continue ; } - total +=mem_cgroup_shrink_node_zone (victim, gfp_mask, false, - zone, &nr_scanned); + total +=mem_cgroup_shrink_node (victim, gfp_mask, false, + zone, &nr_scanned); *total_scanned += nr_scanned;if (!soft_limit_excess (root_memcg))break ;
mm/page_alloc.c +1 -1
@@ -4879,6 +4879,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat,init_waitqueue_head (&pgdat->kswapd_wait);init_waitqueue_head (&pgdat->pfmemalloc_wait);pgdat_page_ext_init (pgdat); +lruvec_init (node_lruvec (pgdat));for (j =0 ; j <MAX_NR_ZONES ; j++) {struct zone *zone = pgdat->node_zones + j;
@@ -4948,7 +4949,6 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat,/* For bootup, initialized properly in watermark setup */ mod_zone_page_state (zone,NR_ALLOC_BATCH , zone->managed_pages); -lruvec_init (zone_lruvec (zone));if (!size)continue ;
mm/vmscan.c +30 -23
146 lines not on this page · raw message
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 11/25 mm, workingset: Make working set detection node-aware
In reply to Mel GormanWorking set and refault detection is still zone-based, fix it.
--- include/linux/mmzone.h | 6 +++--- mm/vmstat.c | 6 +++--- mm/workingset.c | 47 +++++++++++++++++++++-------------------------- 3 files changed, 27 insertions(+), 32 deletions(-)
include/linux/mmzone.h +3 -3
@@ -143,9 +143,6 @@ enum zone_stat_item {NUMA_LOCAL ,/* allocation from local node */ NUMA_OTHER ,/* allocation from other node */ #endif -WORKINGSET_REFAULT , -WORKINGSET_ACTIVATE , -WORKINGSET_NODERECLAIM ,NR_ANON_TRANSPARENT_HUGEPAGES ,NR_FREE_CMA_PAGES , NR_VM_ZONE_STAT_ITEMS };
@@ -160,6 +157,9 @@ enum node_stat_item {NR_ISOLATED_ANON ,/* Temporary isolated pages from anon lru */ NR_ISOLATED_FILE ,/* Temporary isolated pages from file lru */ NR_PAGES_SCANNED ,/* pages scanned since last reclaim */ +WORKINGSET_REFAULT , +WORKINGSET_ACTIVATE , +WORKINGSET_NODERECLAIM , NR_VM_NODE_STAT_ITEMS };
mm/vmstat.c +3 -3
@@ -921,9 +921,6 @@ const char * const vmstat_text[] = {"numa_local" ,"numa_other" , #endif -"workingset_refault" , -"workingset_activate" , -"workingset_nodereclaim" ,"nr_anon_transparent_hugepages" , "nr_free_cma",
@@ -936,6 +933,9 @@ const char * const vmstat_text[] = {"nr_isolated_anon" ,"nr_isolated_file" ,"nr_pages_scanned" , +"workingset_refault" , +"workingset_activate" , +"workingset_nodereclaim" ,/* enum writeback_stat_item counters */ "nr_dirty_threshold",
mm/workingset.c +21 -26
114 lines not on this page · raw message
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 12/25 mm, page_alloc: Consider dirtyable memory in terms of nodes
In reply to Mel GormanHistorically dirty pages were spread among zones but now that LRUs are per-node it is more appropriate to consider dirty pages in a node.
--- include/linux/mmzone.h | 12 +++---- include/linux/writeback.h | 2 +- mm/page-writeback.c | 89 ++++++++++++++++++++++++++--------------------- mm/page_alloc.c | 8 +++-- 4 files changed, 62 insertions(+), 49 deletions(-)
include/linux/mmzone.h +6 -6
@@ -355,12 +355,6 @@ struct zone {struct pglist_data *zone_pgdat;struct per_cpu_pageset __percpu *pageset; -/* -* This is a per-zone reserve of pages that should not be -* considered dirtyable memory. -*/ -unsigned long dirty_balance_reserve; -#ifndef CONFIG_SPARSEMEM /* * Flags for a pageblock_nr_pages block. See pageblock-flags.h.
@@ -760,6 +754,12 @@ typedef struct pglist_data {/* Number of pages migrated during the rate limiting time interval */ unsigned long numabalancing_migrate_nr_pages;#endif +/* +* This is a per-node reserve of pages that should not be +* considered dirtyable memory. +*/ +unsigned long dirty_balance_reserve; +/* Write-intensive fields used from the page allocator */ ZONE_PADDING (_pad1_) spinlock_t lru_lock;
include/linux/writeback.h +1 -1
@@ -119,7 +119,7 @@ void laptop_mode_timer_fn(unsigned long data);static inline void laptop_sync_completion (void ) { }#endif void throttle_vm_writeout (gfp_t gfp_mask); -bool zone_dirty_ok (struct zone *zone); +bool node_dirty_ok (struct pglist_data *pgdat);extern unsigned long global_dirty_limit;
mm/page-writeback.c +49 -40
134 lines not on this page · raw message
mm/page_alloc.c +6 -2
@@ -2042,6 +2042,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, (gfp_mask & __GFP_WRITE);int nr_fair_skipped =0 ;bool zonelist_rescan; +struct pglist_data *last_pgdat =NULL ; zonelist_scan: zonelist_rescan = false;
@@ -2101,8 +2102,11 @@ zonelist_scan:* will require awareness of zones in the * dirty-throttling and the flusher threads. */ -if (consider_zone_dirty && !zone_dirty_ok (zone)) +if (consider_zone_dirty && last_pgdat != zone->zone_pgdat && + !node_dirty_ok (zone->zone_pgdat)) {continue ; + } + last_pgdat = zone->zone_pgdat; mark = zone->watermark[alloc_flags &ALLOC_WMARK_MASK ]; if (!zone_watermark_ok(zone, order, mark,
@@ -5656,7 +5660,7 @@ static void calculate_totalreserve_pages(void)* situation where reclaim has to clean pages * in order to balance the zones. */ - zone->dirty_balance_reserve = max; + pgdat->dirty_balance_reserve += max; } } dirty_balance_reserve = reserve_pages;
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 13/25 mm: Move NR_FILE_MAPPED accounting to the node
In reply to Mel GormanReclaim makes decisions based on the number of file pages that are mapped but it's mixing node and zone information. Account NR_FILE_MAPPED pages on the node.
--- arch/tile/mm/pgtable.c | 2 +- drivers/base/node.c | 4 ++-- fs/proc/meminfo.c | 4 ++-- include/linux/mmzone.h | 6 +++--- mm/page_alloc.c | 6 +++--- mm/rmap.c | 12 ++++++------ mm/vmscan.c | 2 +- mm/vmstat.c | 4 ++-- 8 files changed, 20 insertions(+), 20 deletions(-)
arch/tile/mm/pgtable.c +1 -1
@@ -55,7 +55,7 @@ void show_mem(unsigned int filter)global_page_state (NR_FREE_PAGES ), (global_page_state (NR_SLAB_RECLAIMABLE ) +global_page_state (NR_SLAB_UNRECLAIMABLE )), -global_page_state (NR_FILE_MAPPED ), +global_node_page_state (NR_FILE_MAPPED ),global_page_state (NR_PAGETABLE ),global_page_state (NR_BOUNCE ), global_page_state(NR_FILE_PAGES),
drivers/base/node.c +2 -2
@@ -119,8 +119,8 @@ static ssize_t node_read_meminfo(struct device *dev, 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 (sum_zone_node_page_state (nid,NR_FILE_MAPPED )), - nid,K (sum_zone_node_page_state (nid,NR_ANON_PAGES )), + nid,K (node_page_state (pgdat,NR_FILE_MAPPED )), + nid,K (node_page_state (pgdat,NR_ANON_PAGES )), nid,K (i.sharedram), nid,sum_zone_node_page_state (nid,NR_KERNEL_STACK ) * THREAD_SIZE / 1024,
fs/proc/meminfo.c +2 -2
@@ -173,8 +173,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v)K (i.freeswap),K (global_page_state (NR_FILE_DIRTY )),K (global_page_state (NR_WRITEBACK )), -K (global_page_state (NR_ANON_PAGES )), -K (global_page_state (NR_FILE_MAPPED )), +K (global_node_page_state (NR_ANON_PAGES )), +K (global_node_page_state (NR_FILE_MAPPED )),K (i.sharedram),K (global_page_state (NR_SLAB_RECLAIMABLE ) + global_page_state(NR_SLAB_UNRECLAIMABLE)),
include/linux/mmzone.h +3 -3
@@ -116,9 +116,6 @@ enum zone_stat_item {NR_FREE_PAGES ,NR_ALLOC_BATCH ,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,
@@ -160,6 +157,9 @@ enum node_stat_item {WORKINGSET_REFAULT ,WORKINGSET_ACTIVATE ,WORKINGSET_NODERECLAIM , +NR_ANON_PAGES ,/* Mapped anonymous pages */ +NR_FILE_MAPPED ,/* pagecache pages mapped into pagetables. +only modified from process context */ NR_VM_NODE_STAT_ITEMS };
mm/page_alloc.c +3 -3
@@ -3251,7 +3251,7 @@ void show_free_areas(unsigned int filter)global_page_state (NR_FREE_PAGES ),global_page_state (NR_SLAB_RECLAIMABLE ),global_page_state (NR_SLAB_UNRECLAIMABLE ), -global_page_state (NR_FILE_MAPPED ), +global_node_page_state (NR_FILE_MAPPED ),global_page_state (NR_SHMEM ),global_page_state (NR_PAGETABLE ), global_page_state(NR_BOUNCE),
@@ -3266,6 +3266,7 @@ void show_free_areas(unsigned int filter)" unevictable:%lukB" " isolated(anon):%lukB" " isolated(file):%lukB" +" mapped:%lukB" " all_unreclaimable? %s" "\n" , pgdat->node_id,
@@ -3276,6 +3277,7 @@ void show_free_areas(unsigned int filter)K (node_page_state (pgdat,NR_UNEVICTABLE )),K (node_page_state (pgdat,NR_ISOLATED_ANON )),K (node_page_state (pgdat,NR_ISOLATED_FILE )), +K (node_page_state (pgdat,NR_FILE_MAPPED )), !pgdat_reclaimable(pgdat) ? "yes" : "no"); }
@@ -3295,7 +3297,6 @@ void show_free_areas(unsigned int filter)" mlocked:%lukB" " dirty:%lukB" " writeback:%lukB" -" mapped:%lukB" " shmem:%lukB" " slab_reclaimable:%lukB" " slab_unreclaimable:%lukB"
@@ -3317,7 +3318,6 @@ void show_free_areas(unsigned int filter)K (zone_page_state (zone,NR_MLOCK )),K (zone_page_state (zone,NR_FILE_DIRTY )),K (zone_page_state (zone,NR_WRITEBACK )), -K (zone_page_state (zone,NR_FILE_MAPPED )),K (zone_page_state (zone,NR_SHMEM )),K (zone_page_state (zone,NR_SLAB_RECLAIMABLE )), K(zone_page_state(zone, NR_SLAB_UNRECLAIMABLE)),
mm/rmap.c +6 -6
@@ -1046,8 +1046,8 @@ void do_page_add_anon_rmap(struct page *page,if (PageTransHuge (page))__inc_zone_page_state (page,NR_ANON_TRANSPARENT_HUGEPAGES ); -__mod_zone_page_state (page_zone (page),NR_ANON_PAGES , -hpage_nr_pages (page)); +__mod_node_page_state (page_zone (page)->zone_pgdat, +NR_ANON_PAGES ,hpage_nr_pages (page)); }if (unlikely (PageKsm (page)))return ;
@@ -1078,7 +1078,7 @@ void page_add_new_anon_rmap(struct page *page,atomic_set (&page->_mapcount,0 );/* increment count (starts at -1) */ if (PageTransHuge (page))__inc_zone_page_state (page,NR_ANON_TRANSPARENT_HUGEPAGES ); -__mod_zone_page_state (page_zone (page),NR_ANON_PAGES , +__mod_node_page_state (page_zone (page)->zone_pgdat,NR_ANON_PAGES ,hpage_nr_pages (page));__page_set_anon_rmap (page, vma, address,1 ); }
@@ -1095,7 +1095,7 @@ void page_add_file_rmap(struct page *page) memcg =mem_cgroup_begin_page_stat (page);if (atomic_inc_and_test (&page->_mapcount)) { -__inc_zone_page_state (page,NR_FILE_MAPPED ); +__inc_node_page_state (page,NR_FILE_MAPPED );mem_cgroup_inc_page_stat (memcg,MEM_CGROUP_STAT_FILE_MAPPED ); }mem_cgroup_end_page_stat (memcg);
@@ -1120,7 +1120,7 @@ static void page_remove_file_rmap(struct page *page)* these counters are not modified in interrupt context, and * pte lock(a spinlock) is held, which implies preemption disabled. */ -__dec_zone_page_state (page,NR_FILE_MAPPED ); +__dec_node_page_state (page,NR_FILE_MAPPED );mem_cgroup_dec_page_stat (memcg,MEM_CGROUP_STAT_FILE_MAPPED );if (unlikely (PageMlocked (page)))
@@ -1158,7 +1158,7 @@ void page_remove_rmap(struct page *page)if (PageTransHuge (page))__dec_zone_page_state (page,NR_ANON_TRANSPARENT_HUGEPAGES ); -__mod_zone_page_state (page_zone (page),NR_ANON_PAGES , +__mod_node_page_state (page_zone (page)->zone_pgdat,NR_ANON_PAGES , -hpage_nr_pages (page));if (unlikely (PageMlocked (page)))
mm/vmscan.c +1 -1
@@ -3549,7 +3549,7 @@ int sysctl_min_slab_ratio = 5;static inline unsigned long zone_unmapped_file_pages (struct zone *zone) { -unsigned long file_mapped =zone_page_state (zone,NR_FILE_MAPPED ); +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 );
mm/vmstat.c +2 -2
@@ -895,8 +895,6 @@ const char * const vmstat_text[] = {"nr_free_pages" ,"nr_alloc_batch" ,"nr_mlock" , -"nr_anon_pages" , -"nr_mapped" ,"nr_file_pages" ,"nr_dirty" , "nr_writeback",
@@ -936,6 +934,8 @@ const char * const vmstat_text[] = {"workingset_refault" ,"workingset_activate" ,"workingset_nodereclaim" , +"nr_anon_pages" , +"nr_mapped" ,/* enum writeback_stat_item counters */ "nr_dirty_threshold",
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 14/25 mm: Rename NR_ANON_PAGES to NR_ANON_MAPPED
In reply to Mel GormanNR_FILE_PAGES is the number of file pages.NR_FILE_MAPPED is the number of mapped file pages. NR_ANON_PAGES is the number of mapped anon pages.
This is unhelpful naming as it's easy to confuse NR_FILE_MAPPED and NR_ANON_PAGES for mapped pages. This patch renames NR_ANON_PAGES so we have
NR_FILE_PAGES is the number of file pages.NR_FILE_MAPPED is the number of mapped file pages. NR_ANON_MAPPED is the number of mapped anon pages.
--- fs/proc/meminfo.c | 2 +- include/linux/mmzone.h | 2 +- mm/migrate.c | 2 +- mm/rmap.c | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-)
fs/proc/meminfo.c +1 -1
@@ -173,7 +173,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)K (i.freeswap),K (global_page_state (NR_FILE_DIRTY )),K (global_page_state (NR_WRITEBACK )), -K (global_node_page_state (NR_ANON_PAGES )), +K (global_node_page_state (NR_ANON_MAPPED )),K (global_node_page_state (NR_FILE_MAPPED )),K (i.sharedram), K(global_page_state(NR_SLAB_RECLAIMABLE) +
include/linux/mmzone.h +1 -1
@@ -157,7 +157,7 @@ enum node_stat_item {WORKINGSET_REFAULT ,WORKINGSET_ACTIVATE ,WORKINGSET_NODERECLAIM , -NR_ANON_PAGES ,/* Mapped anonymous pages */ +NR_ANON_MAPPED ,/* Mapped anonymous pages */ NR_FILE_MAPPED ,/* pagecache pages mapped into pagetables. only modified from process context */ NR_VM_NODE_STAT_ITEMS
mm/migrate.c +1 -1
@@ -376,7 +376,7 @@ int migrate_page_move_mapping(struct address_space *mapping,* new page and drop references to the old page. * * Note that anonymous pages are accounted for -* via NR_FILE_PAGES and NR_ANON_PAGES if they +* via NR_FILE_PAGES and NR_ANON_MAPPED if they * are mapped to swap space. */ __dec_zone_page_state (page,NR_FILE_PAGES );
mm/rmap.c +4 -4
@@ -1047,7 +1047,7 @@ void do_page_add_anon_rmap(struct page *page,__inc_zone_page_state (page,NR_ANON_TRANSPARENT_HUGEPAGES );__mod_node_page_state (page_zone (page)->zone_pgdat, -NR_ANON_PAGES ,hpage_nr_pages (page)); +NR_ANON_MAPPED ,hpage_nr_pages (page)); }if (unlikely (PageKsm (page)))return ;
@@ -1078,7 +1078,7 @@ void page_add_new_anon_rmap(struct page *page,atomic_set (&page->_mapcount,0 );/* increment count (starts at -1) */ if (PageTransHuge (page))__inc_zone_page_state (page,NR_ANON_TRANSPARENT_HUGEPAGES ); -__mod_node_page_state (page_zone (page)->zone_pgdat,NR_ANON_PAGES , +__mod_node_page_state (page_zone (page)->zone_pgdat,NR_ANON_MAPPED ,hpage_nr_pages (page));__page_set_anon_rmap (page, vma, address,1 ); }
@@ -1146,7 +1146,7 @@ void page_remove_rmap(struct page *page)if (!atomic_add_negative (-1 , &page->_mapcount))return ; -/* Hugepages are not counted in NR_ANON_PAGES for now. */ +/* Hugepages are not counted in NR_ANON_MAPPED for now. */ if (unlikely (PageHuge (page)))return ;
@@ -1158,7 +1158,7 @@ void page_remove_rmap(struct page *page)if (PageTransHuge (page))__dec_zone_page_state (page,NR_ANON_TRANSPARENT_HUGEPAGES ); -__mod_node_page_state (page_zone (page)->zone_pgdat,NR_ANON_PAGES , +__mod_node_page_state (page_zone (page)->zone_pgdat,NR_ANON_MAPPED , -hpage_nr_pages (page));if (unlikely (PageMlocked (page)))
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 15/25 mm: Move most file-based accounting to the node
In reply to Mel GormanThere 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.
--- arch/s390/appldata/appldata_mem.c | 2 +- arch/tile/mm/pgtable.c | 8 +++---- drivers/base/node.c | 12 +++++----- drivers/staging/android/lowmemorykiller.c | 4 ++-- fs/fs-writeback.c | 8 +++---- fs/fuse/file.c | 8 +++---- fs/nfs/internal.h | 2 +- fs/nfs/write.c | 2 +- fs/proc/meminfo.c | 10 ++++---- include/linux/mmzone.h | 12 +++++----- include/trace/events/writeback.h | 6 ++--- mm/filemap.c | 12 +++++----- mm/migrate.c | 8 +++---- mm/mmap.c | 4 ++-- mm/nommu.c | 4 ++-- mm/page-writeback.c | 38 ++++++++++++------------------- mm/page_alloc.c | 34 +++++++++++++-------------- mm/shmem.c | 12 +++++----- mm/swap_state.c | 4 ++-- mm/truncate.c | 2 +- mm/vmscan.c | 16 ++++++------- mm/vmstat.c | 12 +++++----- 22 files changed, 106 insertions(+), 114 deletions(-)
arch/s390/appldata/appldata_mem.c +1 -1
@@ -102,7 +102,7 @@ static void appldata_get_mem_data(void *data) 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 +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 +6 -6
@@ -116,18 +116,18 @@ static ssize_t node_read_meminfo(struct device *dev,"Node %d AnonHugePages: %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_PAGES )), + 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)),
drivers/staging/android/lowmemorykiller.c +2 -2
@@ -87,8 +87,8 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)short 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)
fs/fs-writeback.c +4 -4
@@ -836,8 +836,8 @@ static bool over_bground_thresh(struct backing_dev_info *bdi)global_dirty_limits (&background_thresh, &dirty_thresh); -if (global_page_state (NR_FILE_DIRTY ) + -global_page_state (NR_UNSTABLE_NFS ) > background_thresh) +if (global_node_page_state (NR_FILE_DIRTY ) + +global_node_page_state (NR_UNSTABLE_NFS ) > background_thresh)return true; if (bdi_stat(bdi, BDI_RECLAIMABLE) >
@@ -991,8 +991,8 @@ get_next_work_item(struct backing_dev_info *bdi)*/ 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 +4 -4
@@ -1470,7 +1470,7 @@ static void fuse_writepage_finish(struct fuse_conn *fc, struct fuse_req *req)list_del (&req->writepages_entry);for (i =0 ; i < req->num_pages; i++) {dec_bdi_stat (bdi,BDI_WRITEBACK ); -dec_zone_page_state (req->pages[i],NR_WRITEBACK_TEMP ); +dec_node_page_state (req->pages[i],NR_WRITEBACK_TEMP );bdi_writeout_inc (bdi); }wake_up (&fi->page_waitq);
@@ -1659,7 +1659,7 @@ static int fuse_writepage_locked(struct page *page) req->inode = inode;inc_bdi_stat (inode_to_bdi (inode),BDI_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);
@@ -1774,7 +1774,7 @@ static bool fuse_writepage_in_flight(struct fuse_req *new_req,spin_unlock (&fc->lock);dec_bdi_stat (bdi,BDI_WRITEBACK ); -dec_zone_page_state (page,NR_WRITEBACK_TEMP ); +dec_node_page_state (page,NR_WRITEBACK_TEMP );bdi_writeout_inc (bdi);fuse_writepage_free (fc, new_req);fuse_request_free (new_req);
@@ -1873,7 +1873,7 @@ static int fuse_writepages_fill(struct page *page, req->page_descs[req->num_pages].length =PAGE_SIZE ;inc_bdi_stat (inode_to_bdi (inode),BDI_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 +1 -1
@@ -606,7 +606,7 @@ void nfs_mark_page_unstable(struct page *page) {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_bdi_stat (inode_to_bdi (inode),BDI_RECLAIMABLE );__mark_inode_dirty (inode,I_DIRTY_DATASYNC ); }
fs/nfs/write.c +1 -1
@@ -852,7 +852,7 @@ nfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg,static 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_bdi_stat (inode_to_bdi (page_file_mapping (page)->host),BDI_RECLAIMABLE ); }
fs/proc/meminfo.c +5 -5
@@ -44,7 +44,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)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 ;
@@ -171,8 +171,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v)#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),
@@ -185,9 +185,9 @@ static int meminfo_proc_show(struct seq_file *m, void *v)#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,
include/linux/mmzone.h +6 -6
@@ -116,20 +116,14 @@ enum zone_stat_item {NR_FREE_PAGES ,NR_ALLOC_BATCH ,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 */ #ifdef CONFIG_NUMA
@@ -160,6 +154,12 @@ 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_UNSTABLE_NFS ,/* NFS unstable pages */ NR_VM_NODE_STAT_ITEMS };
include/trace/events/writeback.h +3 -3
@@ -337,9 +337,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 +6 -6
@@ -197,9 +197,9 @@ void __delete_from_page_cache(struct page *page, void *shadow) page->mapping =NULL ;/* Leave page->index set: truncation lookup relies upon it */ -__dec_zone_page_state (page,NR_FILE_PAGES ); +__dec_node_page_state (page,NR_FILE_PAGES );if (PageSwapBacked (page)) -__dec_zone_page_state (page,NR_SHMEM ); +__dec_node_page_state (page,NR_SHMEM );BUG_ON (page_mapped (page));/*
@@ -210,7 +210,7 @@ void __delete_from_page_cache(struct page *page, void *shadow)* having removed the page entirely. */ if (PageDirty (page) &&mapping_cap_account_dirty (mapping)) { -dec_zone_page_state (page,NR_FILE_DIRTY ); +dec_node_page_state (page,NR_FILE_DIRTY );dec_bdi_stat (inode_to_bdi (mapping->host),BDI_RECLAIMABLE ); } }
@@ -485,9 +485,9 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) error =radix_tree_insert (&mapping->page_tree, offset, new);BUG_ON (error); mapping->nrpages++; -__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_irq (&mapping->tree_lock);mem_cgroup_migrate (old, new, true);radix_tree_preload_end ();
@@ -577,7 +577,7 @@ static int __add_to_page_cache_locked(struct page *page,radix_tree_preload_end ();if (unlikely (error)) goto err_insert; -__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);
mm/migrate.c +4 -4
@@ -379,11 +379,11 @@ int migrate_page_move_mapping(struct address_space *mapping,* via NR_FILE_PAGES and NR_ANON_MAPPED if they * are mapped to swap space. */ -__dec_zone_page_state (page,NR_FILE_PAGES ); -__inc_zone_page_state (newpage,NR_FILE_PAGES ); +__dec_node_page_state (page,NR_FILE_PAGES ); +__inc_node_page_state (newpage,NR_FILE_PAGES );if (!PageSwapCache (page) &&PageSwapBacked (page)) { -__dec_zone_page_state (page,NR_SHMEM ); -__inc_zone_page_state (newpage,NR_SHMEM ); +__dec_node_page_state (page,NR_SHMEM ); +__inc_node_page_state (newpage,NR_SHMEM ); }spin_unlock_irq (&mapping->tree_lock);
mm/mmap.c +2 -2
@@ -168,7 +168,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)if (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
@@ -176,7 +176,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)* 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/nommu.c +2 -2
@@ -1930,7 +1930,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)if (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
@@ -1938,7 +1938,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)* 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/page-writeback.c +15 -23
@@ -320,20 +320,12 @@ static unsigned long node_dirty_limit(struct pglist_data *pgdat)*/ bool node_dirty_ok (struct pglist_data *pgdat) { -int z;unsigned long limit =node_dirty_limit (pgdat);unsigned long nr_pages =0 ; -for (z =0 ; z <MAX_NR_ZONES ; z++) { -struct zone *zone = pgdat->node_zones + z; - -if (!populated_zone (zone)) -continue ; - - nr_pages +=zone_page_state (zone,NR_FILE_DIRTY ); - nr_pages +=zone_page_state (zone,NR_UNSTABLE_NFS ); - nr_pages +=zone_page_state (zone,NR_WRITEBACK ); - } + nr_pages +=node_page_state (pgdat,NR_FILE_DIRTY ); + nr_pages +=node_page_state (pgdat,NR_UNSTABLE_NFS ); + nr_pages +=node_page_state (pgdat,NR_WRITEBACK );return nr_pages <= limit; }
@@ -1381,9 +1373,9 @@ static void balance_dirty_pages(struct address_space *mapping,* written to the server's write cache, but has not yet * been flushed to permanent storage. */ - nr_reclaimable =global_page_state (NR_FILE_DIRTY ) + -global_page_state (NR_UNSTABLE_NFS ); - nr_dirty = nr_reclaimable +global_page_state (NR_WRITEBACK ); + nr_reclaimable =global_node_page_state (NR_FILE_DIRTY ) + +global_node_page_state (NR_UNSTABLE_NFS ); + nr_dirty = nr_reclaimable +global_node_page_state (NR_WRITEBACK );global_dirty_limits (&background_thresh, &dirty_thresh);
@@ -1645,8 +1637,8 @@ void throttle_vm_writeout(gfp_t gfp_mask)*/ dirty_thresh += dirty_thresh /10 ;/* wheeee... */ -if (global_page_state (NR_UNSTABLE_NFS ) + -global_page_state (NR_WRITEBACK ) <= dirty_thresh) +if (global_node_page_state (NR_UNSTABLE_NFS ) + +global_node_page_state (NR_WRITEBACK ) <= dirty_thresh)break ;congestion_wait (BLK_RW_ASYNC ,HZ /10 );
@@ -1674,8 +1666,8 @@ int dirty_writeback_centisecs_handler(struct ctl_table *table, int write,void laptop_mode_timer_fn (unsigned long data) {struct request_queue *q = (struct request_queue *)data; -int nr_pages =global_page_state (NR_FILE_DIRTY ) + -global_page_state (NR_UNSTABLE_NFS ); +int nr_pages =global_node_page_state (NR_FILE_DIRTY ) + +global_node_page_state (NR_UNSTABLE_NFS );/* * We want to write everything out, not just down to the dirty
@@ -2108,8 +2100,8 @@ void account_page_dirtied(struct page *page, struct address_space *mapping)if (mapping_cap_account_dirty (mapping)) {struct backing_dev_info *bdi =inode_to_bdi (mapping->host); -__inc_zone_page_state (page,NR_FILE_DIRTY ); -__inc_zone_page_state (page,NR_DIRTIED ); +__inc_node_page_state (page,NR_FILE_DIRTY ); +__inc_node_page_state (page,NR_DIRTIED );__inc_bdi_stat (bdi,BDI_RECLAIMABLE );__inc_bdi_stat (bdi,BDI_DIRTIED );task_io_account_write (PAGE_CACHE_SIZE );
@@ -2311,7 +2303,7 @@ int clear_page_dirty_for_io(struct page *page)* exclusion. */ if (TestClearPageDirty (page)) { -dec_zone_page_state (page,NR_FILE_DIRTY ); +dec_node_page_state (page,NR_FILE_DIRTY );dec_bdi_stat (inode_to_bdi (mapping->host),BDI_RECLAIMABLE );return 1 ;
@@ -2350,7 +2342,7 @@ int test_clear_page_writeback(struct page *page) }if (ret) {mem_cgroup_dec_page_stat (memcg,MEM_CGROUP_STAT_WRITEBACK ); -dec_zone_page_state (page,NR_WRITEBACK ); +dec_node_page_state (page,NR_WRITEBACK );inc_zone_page_state (page,NR_WRITTEN ); }mem_cgroup_end_page_stat (memcg);
@@ -2391,7 +2383,7 @@ int __test_set_page_writeback(struct page *page, bool keep_write) }if (!ret) {mem_cgroup_inc_page_stat (memcg,MEM_CGROUP_STAT_WRITEBACK ); -inc_zone_page_state (page,NR_WRITEBACK ); +inc_node_page_state (page,NR_WRITEBACK ); }mem_cgroup_end_page_stat (memcg);return ret;
mm/page_alloc.c +17 -17
@@ -3118,7 +3118,7 @@ static inline void show_node(struct zone *zone)void si_meminfo (struct sysinfo *val) { val->totalram = totalram_pages; - val->sharedram =global_page_state (NR_SHMEM ); + val->sharedram =global_node_page_state (NR_SHMEM ); val->freeram =global_page_state (NR_FREE_PAGES ); val->bufferram =nr_blockdev_pages (); val->totalhigh = totalhigh_pages;
@@ -3138,7 +3138,7 @@ void si_meminfo_node(struct sysinfo *val, int nid)for (zone_type =0 ; zone_type <MAX_NR_ZONES ; zone_type++) managed_pages += pgdat->node_zones[zone_type].managed_pages; val->totalram = managed_pages; - val->sharedram =sum_zone_node_page_state (nid,NR_SHMEM ); + val->sharedram =node_page_state (pgdat,NR_SHMEM ); val->freeram =sum_zone_node_page_state (nid,NR_FREE_PAGES );#ifdef CONFIG_HIGHMEM val->totalhigh = pgdat->node_zones[ZONE_HIGHMEM ].managed_pages;
@@ -3245,14 +3245,14 @@ void show_free_areas(unsigned int filter)global_node_page_state (NR_INACTIVE_FILE ),global_node_page_state (NR_ISOLATED_FILE ),global_node_page_state (NR_UNEVICTABLE ), -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_SHMEM ), +global_node_page_state (NR_SHMEM ),global_page_state (NR_PAGETABLE ),global_page_state (NR_BOUNCE ), global_page_state(NR_FREE_CMA_PAGES));
@@ -3267,6 +3267,11 @@ void show_free_areas(unsigned int filter)" isolated(anon):%lukB" " isolated(file):%lukB" " mapped:%lukB" +" dirty:%lukB" +" writeback:%lukB" +" shmem:%lukB" +" writeback_tmp:%lukB" +" unstable:%lukB" " all_unreclaimable? %s" "\n" , pgdat->node_id,
@@ -3278,6 +3283,11 @@ void show_free_areas(unsigned int filter)K (node_page_state (pgdat,NR_ISOLATED_ANON )),K (node_page_state (pgdat,NR_ISOLATED_FILE )),K (node_page_state (pgdat,NR_FILE_MAPPED )), +K (node_page_state (pgdat,NR_FILE_DIRTY )), +K (node_page_state (pgdat,NR_WRITEBACK )), +K (node_page_state (pgdat,NR_SHMEM )), +K (node_page_state (pgdat,NR_WRITEBACK_TEMP )), +K (node_page_state (pgdat,NR_UNSTABLE_NFS )), !pgdat_reclaimable(pgdat) ? "yes" : "no"); }
@@ -3295,17 +3305,12 @@ void show_free_areas(unsigned int filter)" present:%lukB" " managed:%lukB" " mlocked:%lukB" -" dirty:%lukB" -" writeback:%lukB" -" shmem:%lukB" " slab_reclaimable:%lukB" " slab_unreclaimable:%lukB" " kernel_stack:%lukB" " pagetables:%lukB" -" unstable:%lukB" " bounce:%lukB" " free_cma:%lukB" -" writeback_tmp:%lukB" " node_pages_scanned:%lu" "\n" , zone->name,
@@ -3316,18 +3321,13 @@ void show_free_areas(unsigned int filter)K (zone->present_pages),K (zone->managed_pages),K (zone_page_state (zone,NR_MLOCK )), -K (zone_page_state (zone,NR_FILE_DIRTY )), -K (zone_page_state (zone,NR_WRITEBACK )), -K (zone_page_state (zone,NR_SHMEM )),K (zone_page_state (zone,NR_SLAB_RECLAIMABLE )),K (zone_page_state (zone,NR_SLAB_UNRECLAIMABLE )),zone_page_state (zone,NR_KERNEL_STACK ) *THREAD_SIZE /1024 ,K (zone_page_state (zone,NR_PAGETABLE )), -K (zone_page_state (zone,NR_UNSTABLE_NFS )),K (zone_page_state (zone,NR_BOUNCE )),K (zone_page_state (zone,NR_FREE_CMA_PAGES )), -K (zone_page_state (zone,NR_WRITEBACK_TEMP )), K(node_page_state(zone->zone_pgdat, NR_PAGES_SCANNED)));printk ("lowmem_reserve[]:" );for (i =0 ; i <MAX_NR_ZONES ; i++)
@@ -3369,7 +3369,7 @@ void show_free_areas(unsigned int filter)hugetlb_show_meminfo (); -printk ("%ld total pagecache pages\n" ,global_page_state (NR_FILE_PAGES )); +printk ("%ld total pagecache pages\n" ,global_node_page_state (NR_FILE_PAGES ));show_swap_cache_info (); }
mm/shmem.c +6 -6
@@ -310,8 +310,8 @@ static int shmem_add_to_page_cache(struct page *page, page);if (!error) { mapping->nrpages++; -__inc_zone_page_state (page,NR_FILE_PAGES ); -__inc_zone_page_state (page,NR_SHMEM ); +__inc_node_page_state (page,NR_FILE_PAGES ); +__inc_node_page_state (page,NR_SHMEM );spin_unlock_irq (&mapping->tree_lock); }else { page->mapping =NULL ;
@@ -333,8 +333,8 @@ static void shmem_delete_from_page_cache(struct page *page, void *radswap) 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);page_cache_release (page);BUG_ON (error);
@@ -995,8 +995,8 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp, 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 +2 -2
@@ -95,7 +95,7 @@ int __add_to_swap_cache(struct page *page, swp_entry_t entry) 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 page *page)set_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/truncate.c +1 -1
@@ -111,7 +111,7 @@ void cancel_dirty_page(struct page *page, unsigned int account_size)if (TestClearPageDirty (page)) {struct address_space *mapping = page->mapping;if (mapping &&mapping_cap_account_dirty (mapping)) { -dec_zone_page_state (page,NR_FILE_DIRTY ); +dec_node_page_state (page,NR_FILE_DIRTY );dec_bdi_stat (inode_to_bdi (mapping->host),BDI_RECLAIMABLE );if (account_size)
mm/vmscan.c +8 -8
@@ -3547,11 +3547,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
@@ -3570,17 +3570,17 @@ static long zone_pagecache_reclaimable(struct zone *zone)/* * If RECLAIM_SWAP 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_SWAP ) - 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 +6 -6
@@ -895,19 +895,13 @@ const char * const vmstat_text[] = {"nr_free_pages" ,"nr_alloc_batch" ,"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",
@@ -936,6 +930,12 @@ 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_unstable" ,/* enum writeback_stat_item counters */ "nr_dirty_threshold",
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 16/25 mm, vmscan: Update classzone_idx if buffer_heads_over_limit
In reply to Mel GormanIf buffer heads are over the limit then the direct reclaim gfp_mask is promoted to __GFP_HIGHMEM so that lowmem is indirectly freed. With node-based reclaim, it is also required that the classzone_idx be updated or the pages will be skipped.
--- mm/vmscan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/vmscan.c +3 -1
@@ -2497,8 +2497,10 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc,* highmem pages could be pinning lowmem pages storing buffer_heads */ orig_mask = sc->gfp_mask; -if (buffer_heads_over_limit) +if (buffer_heads_over_limit) { sc->gfp_mask |= __GFP_HIGHMEM; + classzone_idx =gfp_zone (sc->gfp_mask); + }for_each_zone_zonelist_nodemask (zone, z, zonelist, classzone_idx, sc->nodemask) {
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 17/25 mm, vmscan: Check if cpusets are enabled during direct reclaim
In reply to Mel GormanDirect reclaim obeys cpusets but misses the cpusets_enabled() check. The overhead is unlikely to be measurable in the direct reclaim path which is expensive but there is no harm is doing it.
--- mm/vmscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/vmscan.c +1 -1
@@ -2522,7 +2522,7 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc,* to global LRU. */ if (global_reclaim (sc)) { -if (!cpuset_zone_allowed (zone, +if (cpusets_enabled () && !cpuset_zone_allowed (zone,GFP_KERNEL | __GFP_HARDWALL))continue ;
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 18/25 mm, vmscan: Only wakeup kswapd once per node for the requested classzone
In reply to Mel Gormankswapd is woken when zones are below the low watermark but the wakeup decision is not taking the classzone into account. Now that reclaim is node-based, it is only required to wake kswapd once per node and only if all zones are unbalanced for the requested classzone.
Note that one node might be checked multiple times but there is no cheap way of tracking what nodes have already been visited for zoneslists that be ordered by either zone or node.
--- mm/vmscan.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
mm/vmscan.c +9 -2
@@ -3381,6 +3381,7 @@ static int kswapd(void *p)void wakeup_kswapd (struct zone *zone,int order,enum zone_type classzone_idx) {pg_data_t *pgdat; +int z;bool dummy;if (!populated_zone (zone))
@@ -3395,8 +3396,14 @@ void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx) }if (!waitqueue_active (&pgdat->kswapd_wait))return ; -if (zone_balanced (zone, order,0 ,0 , &dummy)) -return ; + +/* Only wake kswapd if all zones are unbalanced */ +for (z =0 ; z <=zone_idx (zone); z++) { + zone = pgdat->node_zones + z; + +if (zone_balanced (zone, order,0 , classzone_idx, &dummy)) +return ; + }trace_mm_vmscan_wakeup_kswapd (pgdat->node_id,zone_idx (zone), order);wake_up_interruptible (&pgdat->kswapd_wait);
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 19/25 mm, vmscan: Account in vmstat for pages skipped during reclaim
In reply to Mel GormanLow reclaim efficiency occurs when many pages are scanned that cannot be reclaimed. This occurs for example when pages are dirty or under writeback. Node-based LRU reclaim introduces a new source as reclaim for allocation requests requiring lower zones will skip pages belonging to higher zones. This patch adds vmstat counters to count pages that were skipped because the calling context could not use pages from that zone. It will help distinguish one source of low reclaim efficiency.
--- include/linux/vm_event_item.h | 1 + mm/vmscan.c | 6 +++++- mm/vmstat.c | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-)
include/linux/vm_event_item.h +1 -0
@@ -25,6 +25,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,FOR_ALL_ZONES (PGALLOC ),PGFREE ,PGACTIVATE ,PGDEACTIVATE ,PGFAULT ,PGMAJFAULT , +FOR_ALL_ZONES (PGSCAN_SKIP ),PGREFILL ,PGSTEAL_KSWAPD , PGSTEAL_DIRECT,
mm/vmscan.c +5 -1
@@ -1326,6 +1326,7 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,for (scan =0 ; scan < nr_to_scan && !list_empty (src); scan++) {struct page *page; +struct zone *zone;int nr_pages; page =lru_to_page (src);
@@ -1333,8 +1334,11 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,VM_BUG_ON_PAGE (!PageLRU (page), page); -if (page_zone_id (page) > sc->reclaim_idx) + zone =page_zone (page); +if (page_zone_id (page) > sc->reclaim_idx) {list_move (&page->lru, &pages_skipped); +__count_zone_vm_events (PGSCAN_SKIP ,page_zone (page),1 ); + }switch (__isolate_lru_page (page, mode)) {case 0 :
mm/vmstat.c +2 -0
@@ -957,6 +957,8 @@ const char * const vmstat_text[] = {"pgfault" ,"pgmajfault" , + TEXTS_FOR_ZONES("pgskip") +"pgrefill" ,"pgsteal_kswapd" , "pgsteal_direct",
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 20/25 mm, page_alloc: Remove fair zone allocation policy
In reply to Mel GormanThe fair zone allocation policy interleaves allocation requests between zones to avoid an age inversion problem whereby new pages are reclaimed to balance a zone. Reclaim is now node-based so this should no longer be an issue and the fair zone allocation policy is not free. This patch removes it.
--- include/linux/mmzone.h | 2 -- mm/internal.h | 1 - mm/page_alloc.c | 69 +------------------------------------------------- mm/vmstat.c | 1 - 4 files changed, 1 insertion(+), 72 deletions(-)
include/linux/mmzone.h +0 -2
@@ -114,7 +114,6 @@ struct zone_padding {enum zone_stat_item {/* First 128 byte cacheline (assuming 64 bit words) */ NR_FREE_PAGES , -NR_ALLOC_BATCH ,NR_MLOCK ,/* mlock()ed pages found and moved off LRU */ NR_SLAB_RECLAIMABLE ,NR_SLAB_UNRECLAIMABLE ,
@@ -521,7 +520,6 @@ struct zone {enum zone_flags {ZONE_RECLAIM_LOCKED ,/* prevents concurrent reclaim */ ZONE_OOM_LOCKED ,/* zone is in OOM killer zonelist */ -ZONE_FAIR_DEPLETED ,/* fair zone policy batch depleted */ };enum pgdat_flags {
mm/internal.h +0 -1
@@ -429,6 +429,5 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone,#define ALLOC_HIGH 0x20/* __GFP_HIGH set */ #define ALLOC_CPUSET 0x40/* check for correct cpuset */ #define ALLOC_CMA 0x80/* allow allocations from CMA areas */ -#define ALLOC_FAIR 0x100/* fair zone allocation */ #endif /* __MM_INTERNAL_H */
mm/page_alloc.c +1 -68
129 lines not on this page · raw message
mm/vmstat.c +0 -1
@@ -893,7 +893,6 @@ int fragmentation_index(struct zone *zone, unsigned int order)const char *const vmstat_text[] = {/* enum zone_stat_item countes */ "nr_free_pages" , -"nr_alloc_batch" ,"nr_mlock" ,"nr_slab_reclaimable" ,"nr_slab_unreclaimable" ,
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 21/25 mm, page_alloc: Defer zlc_setup until it is known it is required
In reply to Mel GormanThe zonelist cache (zlc) records if zone_reclaim() is necessary but it is setup before it is checked if zone_reclaim is even enabled. This patch defers the setup until after zone_reclaim is checked.
--- mm/page_alloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
mm/page_alloc.c +4 -4
@@ -2076,6 +2076,10 @@ zonelist_scan:if (alloc_flags &ALLOC_NO_WATERMARKS ) goto try_this_zone; +if (zone_reclaim_mode ==0 || + !zone_allows_reclaim (ac->preferred_zone, zone)) + goto this_zone_full; +if (IS_ENABLED (CONFIG_NUMA ) && !did_zlc_setup && nr_online_nodes >1 ) {/*
@@ -2088,10 +2092,6 @@ zonelist_scan: did_zlc_setup =1 ; } -if (zone_reclaim_mode ==0 || - !zone_allows_reclaim (ac->preferred_zone, zone)) - goto this_zone_full; -/* * As we may have just activated ZLC, check if the first * eligible zone has failed zone_reclaim recently.
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 22/25 mm: Convert zone_reclaim to node_reclaim
In reply to Mel GormanAs reclaim is now per-node based, convert zone_reclaim to be node_reclaim and avoid reclaiming a node multiple times due to having multiple populated zones. The documentation and interface to userspace is the same as from a configuration and behaviour perspective, it will be similar unless the node-local allocation requests were also limited to lower zones.
--- include/linux/mmzone.h | 18 +++++------ include/linux/swap.h | 9 +++--- include/linux/topology.h | 2 +- kernel/sysctl.c | 4 +-- mm/huge_memory.c | 4 +-- mm/internal.h | 8 ++--- mm/page_alloc.c | 35 +++++++++++++++------- mm/vmscan.c | 77 ++++++++++++++++++++++++------------------------ 8 files changed, 85 insertions(+), 72 deletions(-)
include/linux/mmzone.h +9 -9
@@ -362,14 +362,6 @@ struct zone {unsigned long *pageblock_flags;#endif /* CONFIG_SPARSEMEM */ -#ifdef CONFIG_NUMA -/* -* zone reclaim becomes active if more unmapped pages exist. -*/ -unsigned long min_unmapped_pages; -unsigned long min_slab_pages; -#endif /* CONFIG_NUMA */ -/* zone_start_pfn == zone_start_paddr >> PAGE_SHIFT */ unsigned long zone_start_pfn;
@@ -518,7 +510,6 @@ struct zone { }____cacheline_internodealigned_in_smp ;enum zone_flags { -ZONE_RECLAIM_LOCKED ,/* prevents concurrent reclaim */ ZONE_OOM_LOCKED ,/* zone is in OOM killer zonelist */ };
@@ -533,6 +524,7 @@ enum pgdat_flags {PGDAT_WRITEBACK ,/* reclaim scanning has recently found * many pages under writeback */ + PGDAT_RECLAIM_LOCKED, /* prevents concurrent reclaim */ };static inline unsigned long zone_end_pfn (const struct zone *zone)
@@ -758,6 +750,14 @@ typedef struct pglist_data {*/ unsigned long dirty_balance_reserve; +#ifdef CONFIG_NUMA +/* +* zone reclaim becomes active if more unmapped pages exist. +*/ +unsigned long min_unmapped_pages; +unsigned long min_slab_pages; +#endif /* CONFIG_NUMA */ +/* Write-intensive fields used from the page allocator */ ZONE_PADDING (_pad1_) spinlock_t lru_lock;
include/linux/swap.h +5 -4
@@ -333,13 +333,14 @@ extern int remove_mapping(struct address_space *mapping, struct page *page);extern unsigned long vm_total_pages;#ifdef CONFIG_NUMA -extern int zone_reclaim_mode; +extern int node_reclaim_mode;extern int sysctl_min_unmapped_ratio;extern int sysctl_min_slab_ratio; -extern int zone_reclaim (struct zone *,gfp_t ,unsigned int ); +extern int node_reclaim (struct pglist_data *,gfp_t ,unsigned int );#else -#define zone_reclaim_mode 0 -static inline int zone_reclaim (struct zone *z,gfp_t mask,unsigned int order) +#define node_reclaim_mode 0 +static inline int node_reclaim (struct pglist_data *pgdat,gfp_t mask, +unsigned int order) {return 0 ; }
include/linux/topology.h +1 -1
@@ -58,7 +58,7 @@ int arch_update_cpu_topology(void);/* * If the distance between nodes in a system is larger than RECLAIM_DISTANCE * (in whatever arch specific measurement units returned by node_distance()) -* and zone_reclaim_mode is enabled then the VM will only call zone_reclaim() +* and node_reclaim_mode is enabled then the VM will only call node_reclaim() * on nodes within this distance. */ #define RECLAIM_DISTANCE 30
kernel/sysctl.c +2 -2
@@ -1394,8 +1394,8 @@ static struct ctl_table vm_table[] = {#ifdef CONFIG_NUMA { .procname = "zone_reclaim_mode", - .data = &zone_reclaim_mode, - .maxlen = sizeof(zone_reclaim_mode), + .data = &node_reclaim_mode, + .maxlen = sizeof(node_reclaim_mode), .mode = 0644, .proc_handler = proc_dointvec, .extra1 = &zero,
mm/huge_memory.c +2 -2
@@ -2249,10 +2249,10 @@ static bool khugepaged_scan_abort(int nid)int i;/* -* If zone_reclaim_mode is disabled, then no extra effort is made to +* If node_reclaim_mode is disabled, then no extra effort is made to * allocate memory locally. */ -if (!zone_reclaim_mode) +if (!node_reclaim_mode)return false;/* If there is a count for this node already, it must be acceptable */
mm/internal.h +4 -4
@@ -395,10 +395,10 @@ static inline void mminit_validate_memmodel_limits(unsigned long *start_pfn, }#endif /* CONFIG_SPARSEMEM */ -#define ZONE_RECLAIM_NOSCAN -2 -#define ZONE_RECLAIM_FULL -1 -#define ZONE_RECLAIM_SOME 0 -#define ZONE_RECLAIM_SUCCESS 1 +#define NODE_RECLAIM_NOSCAN -2 +#define NODE_RECLAIM_FULL -1 +#define NODE_RECLAIM_SOME 0 +#define NODE_RECLAIM_SUCCESS 1extern int hwpoison_filter (struct page *p);
mm/page_alloc.c +24 -11
@@ -2064,7 +2064,6 @@ zonelist_scan: !node_dirty_ok(zone->zone_pgdat)) {continue ; } - last_pgdat = zone->zone_pgdat; mark = zone->watermark[alloc_flags &ALLOC_WMARK_MASK ]; if (!zone_watermark_ok(zone, order, mark,
@@ -2076,7 +2075,7 @@ zonelist_scan:if (alloc_flags &ALLOC_NO_WATERMARKS ) goto try_this_zone; -if (zone_reclaim_mode ==0 || +if (node_reclaim_mode ==0 || !zone_allows_reclaim (ac->preferred_zone, zone)) goto this_zone_full;
@@ -2094,18 +2093,22 @@ zonelist_scan:/* * As we may have just activated ZLC, check if the first -* eligible zone has failed zone_reclaim recently. +* eligible zone has failed node_reclaim recently. */ if (IS_ENABLED (CONFIG_NUMA ) && zlc_active && !zlc_zone_worth_trying (zonelist, z, allowednodes))continue ; - ret =zone_reclaim (zone, gfp_mask, order); +/* Skip if we have already attemped node_reclaim */ +if (last_pgdat == zone->zone_pgdat) + goto try_this_zone; + + ret =node_reclaim (zone->zone_pgdat, gfp_mask, order);switch (ret) { -case ZONE_RECLAIM_NOSCAN : +case NODE_RECLAIM_NOSCAN :/* did not scan */ continue ; -case ZONE_RECLAIM_FULL : +case NODE_RECLAIM_FULL :/* scanned but unreclaimable */ continue ;default :
@@ -2124,7 +2127,7 @@ zonelist_scan:* min watermarks. */ if (((alloc_flags &ALLOC_WMARK_MASK ) ==ALLOC_WMARK_MIN ) || - ret ==ZONE_RECLAIM_SOME ) + ret ==NODE_RECLAIM_SOME ) goto this_zone_full;continue ;
@@ -2132,6 +2135,7 @@ zonelist_scan: } try_this_zone: + last_pgdat = zone->zone_pgdat; page =buffered_rmqueue (ac->preferred_zone, zone, order, gfp_mask, ac->migratetype);if (page) {
@@ -2140,6 +2144,7 @@ try_this_zone:return page; } this_zone_full: + last_pgdat = zone->zone_pgdat;if (IS_ENABLED (CONFIG_NUMA ) && zlc_active)zlc_mark_zone_full (zonelist, z); }
@@ -4879,9 +4884,9 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat, zone->managed_pages =is_highmem_idx (j) ? realsize : freesize;#ifdef CONFIG_NUMA zone->node = nid; - zone->min_unmapped_pages = (freesize*sysctl_min_unmapped_ratio) + pgdat->min_unmapped_pages += (freesize*sysctl_min_unmapped_ratio) /100 ; - zone->min_slab_pages = (freesize * sysctl_min_slab_ratio) /100 ; + pgdat->min_slab_pages += (freesize * sysctl_min_slab_ratio) /100 ;#endif zone->name = zone_names[j]; zone->zone_pgdat = pgdat;
@@ -5839,6 +5844,7 @@ int min_free_kbytes_sysctl_handler(struct ctl_table *table, int write,int sysctl_min_unmapped_ratio_sysctl_handler (struct ctl_table *table,int write,void __user *buffer,size_t *length,loff_t *ppos) { +struct pglist_data *pgdat;struct zone *zone;int rc;
@@ -5846,8 +5852,11 @@ int sysctl_min_unmapped_ratio_sysctl_handler(struct ctl_table *table, int write,if (rc)return rc; +for_each_online_pgdat (pgdat) + pgdat->min_slab_pages =0 ; +for_each_zone (zone) - zone->min_unmapped_pages = (zone->managed_pages * + zone->zone_pgdat->min_unmapped_pages += (zone->managed_pages * sysctl_min_unmapped_ratio) /100 ;return 0 ; }
@@ -5855,6 +5864,7 @@ int sysctl_min_unmapped_ratio_sysctl_handler(struct ctl_table *table, int write,int sysctl_min_slab_ratio_sysctl_handler (struct ctl_table *table,int write,void __user *buffer,size_t *length,loff_t *ppos) { +struct pglist_data *pgdat;struct zone *zone;int rc;
@@ -5862,8 +5872,11 @@ int sysctl_min_slab_ratio_sysctl_handler(struct ctl_table *table, int write,if (rc)return rc; +for_each_online_pgdat (pgdat) + pgdat->min_slab_pages =0 ; +for_each_zone (zone) - zone->min_slab_pages = (zone->managed_pages * + zone->zone_pgdat->min_slab_pages += (zone->managed_pages * sysctl_min_slab_ratio) /100 ;return 0 ; }
mm/vmscan.c +38 -39
170 lines not on this page · raw message
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 23/25 mm, page_alloc: Delete the zonelist_cache
In reply to Mel GormanThe zonelist cache (zlc) was introduced to quickly skip over full zones when zone_reclaim was active. This made some sense before there were zone flags and when zone_reclaim was the default. Now reclaim is node-based and zone_reclaim is disabled by default. If it was being implemented today, it would use a pgdat flag with a timeout to reset it but as zone_reclaim is extraordinarily expensive the entire concept is of dubious merit. This patch deletes it entirely.
--- include/linux/mmzone.h | 78 +----------------- mm/page_alloc.c | 210 +------------------------------------------------ mm/vmstat.c | 8 +- 3 files changed, 8 insertions(+), 288 deletions(-)
include/linux/mmzone.h +2 -76
@@ -558,84 +558,14 @@ static inline bool zone_is_empty(struct zone *zone)#define MAX_ZONES_PER_ZONELIST (MAX_NUMNODES * MAX_NR_ZONES)#ifdef CONFIG_NUMA -/* * The NUMA zonelists are doubled because we need zonelists that restrict the * allocations to a single node for __GFP_THISNODE. * -* [0] : Zonelist with fallback -* [1] : No fallback (__GFP_THISNODE) +* [0] : Zonelist with fallback +* [1] : No fallback (__GFP_THISNODE) */ #define MAX_ZONELISTS 2 - - -/* -* We cache key information from each zonelist for smaller cache -* footprint when scanning for free pages in get_page_from_freelist(). -* -* 1) The BITMAP fullzones tracks which zones in a zonelist have come -* up short of free memory since the last time (last_fullzone_zap) -* we zero'd fullzones. -* 2) The array z_to_n[] maps each zone in the zonelist to its node -* id, so that we can efficiently evaluate whether that node is -* set in the current tasks mems_allowed. -* -* Both fullzones and z_to_n[] are one-to-one with the zonelist, -* indexed by a zones offset in the zonelist zones[] array. -* -* The get_page_from_freelist() routine does two scans. During the -* first scan, we skip zones whose corresponding bit in 'fullzones' -* is set or whose corresponding node in current->mems_allowed (which -* comes from cpusets) is not set. During the second scan, we bypass -* this zonelist_cache, to ensure we look methodically at each zone. -* -* Once per second, we zero out (zap) fullzones, forcing us to -* reconsider nodes that might have regained more free memory. -* The field last_full_zap is the time we last zapped fullzones. -* -* This mechanism reduces the amount of time we waste repeatedly -* reexaming zones for free memory when they just came up low on -* memory momentarilly ago. -* -* The zonelist_cache struct members logically belong in struct -* zonelist. However, the mempolicy zonelists constructed for -* MPOL_BIND are intentionally variable length (and usually much -* shorter). A general purpose mechanism for handling structs with -* multiple variable length members is more mechanism than we want -* here. We resort to some special case hackery instead. -* -* The MPOL_BIND zonelists don't need this zonelist_cache (in good -* part because they are shorter), so we put the fixed length stuff -* at the front of the zonelist struct, ending in a variable length -* zones[], as is needed by MPOL_BIND. -* -* Then we put the optional zonelist cache on the end of the zonelist -* struct. This optional stuff is found by a 'zlcache_ptr' pointer in -* the fixed length portion at the front of the struct. This pointer -* both enables us to find the zonelist cache, and in the case of -* MPOL_BIND zonelists, (which will just set the zlcache_ptr to NULL) -* to know that the zonelist cache is not there. -* -* The end result is that struct zonelists come in two flavors: -* 1) The full, fixed length version, shown below, and -* 2) The custom zonelists for MPOL_BIND. -* The custom MPOL_BIND zonelists have a NULL zlcache_ptr and no zlcache. -* -* Even though there may be multiple CPU cores on a node modifying -* fullzones or last_full_zap in the same zonelist_cache at the same -* time, we don't lock it. This is just hint data - if it is wrong now -* and then, the allocator will still function, perhaps a bit slower. -*/ - - -struct zonelist_cache { -unsigned short z_to_n[MAX_ZONES_PER_ZONELIST ];/* zone->nid */ - DECLARE_BITMAP(fullzones, MAX_ZONES_PER_ZONELIST); /* zone full? */ -unsigned long last_full_zap;/* when last zap'd (jiffies) */ -}; -#else -#define MAX_ZONELISTS 1 -struct zonelist_cache ;#endif /*
@@ -665,11 +595,7 @@ struct zoneref {* zonelist_node_idx() - Return the index of the node for an entry */ struct zonelist { -struct zonelist_cache *zlcache_ptr;// NULL or &zlcache struct zoneref _zonerefs[MAX_ZONES_PER_ZONELIST +1 ]; -#ifdef CONFIG_NUMA -struct zonelist_cache zlcache;// optional ... -#endif };#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
mm/page_alloc.c +2 -208
298 lines not on this page · raw message
mm/vmstat.c +4 -4
@@ -1500,14 +1500,14 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos) v[i] =global_page_state (i); v +=NR_VM_ZONE_STAT_ITEMS ; -for (i =0 ; i <NR_VM_NODE_STAT_ITEMS ; i++) - v[i] =global_node_page_state (i); - v +=NR_VM_NODE_STAT_ITEMS ; -global_dirty_limits (v +NR_DIRTY_BG_THRESHOLD , v +NR_DIRTY_THRESHOLD ); v +=NR_VM_WRITEBACK_STAT_ITEMS ; +for (i =0 ; i <NR_VM_NODE_STAT_ITEMS ; i++) + v[i] =global_node_page_state (i); + v +=NR_VM_NODE_STAT_ITEMS ; +#ifdef CONFIG_VM_EVENT_COUNTERS all_vm_events (v); v[PGPGIN ] /=2 ;/* sectors -> kbytes */
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 24/25 mm, page_alloc: Use ac->classzone_idx instead of zone_idx(preferred_zone)
In reply to Mel Gormanac->classzone_idx is determined by the index of the preferred zone and cached to avoid repeated calculations. wake_all_kswapds() should use it instead of using zone_idx() within a loop.
--- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
@@ -2307,7 +2307,7 @@ static void wake_all_kswapds(unsigned int order, const struct alloc_context *ac)for_each_zone_zonelist_nodemask (zone, z, ac->zonelist, ac->high_zoneidx, ac->nodemask) -wakeup_kswapd (zone, order,zone_idx (ac->preferred_zone)); +wakeup_kswapd (zone, order, ac->classzone_idx); } static inline int
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 25/25 mm: page_alloc: Take fewer passes when allocating to the low watermark
In reply to Mel Gorman--- mm/page_alloc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
mm/page_alloc.c +21 -0
@@ -1927,6 +1927,27 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,if (alloc_flags &ALLOC_NO_WATERMARKS ) goto try_this_zone; +/* +* If checking the low watermark, see if we meet the +* min watermark and if so, try the zone and wake +* kswapd instead of falling back to a remote zone +* or having to take a second pass +*/ +if (alloc_flags &ALLOC_WMARK_LOW ) { +int min_flags = alloc_flags; + + min_flags &= ~ALLOC_WMARK_LOW ; + min_flags |=ALLOC_WMARK_MIN ; + +if (zone_watermark_ok (zone, order, + zone->watermark[min_flags &ALLOC_WMARK_MASK ], + ac->classzone_idx, + min_flags)) { +wakeup_kswapd (zone, order, ac->classzone_idx); + goto try_this_zone; + } + } +if (node_reclaim_mode ==0 || !zone_allows_reclaim (ac->preferred_zone, zone)) goto this_zone_full;
Signature · 7 lines
2.3.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerHi Mel,
these are cool patches, I very much like the direction this is headed.
Quoted 7 lines · Mel Gorman
This is an RFC series against 4.0 that moves LRUs from the zones to the node. In concept, this is straight forward but there are a lot of details so I'm posting it early to see what people think. The motivations are;
1. Currently, reclaim on node 0 behaves differently to node 1 with subtly different aging rules. Workloads may exhibit different behaviour depending on what node it was scheduled on as a result.
How so? Don't we ultimately age pages in proportion to node size, regardless of how many zones they are broken into?
Quoted 4 lines
2. The residency of a page partially depends on what zone the page was allocated from. This is partially combatted by the fair zone allocation policy but that is a partial solution that introduces overhead in the page allocator paths.
Yeah, it's ugly and I'm happy you're getting rid of this again. That being said, in my tests it seemed like a complete solution to remove any influence from allocation placement on aging behavior. Where do you still see aging artifacts?
Quoted 2 lines
3. kswapd and the page allocator play special games with the order they scan zones to avoid interfering with each other but it's unpredictable.
It would be good to recall here these interference issues, how they are currently coped with, and how your patches address them.
Quoted 2 lines
4. The different scan activity and ordering for zone reclaim is very difficult to predict.
I'm not sure what this means.
Quoted 2 lines
5. slab shrinkers are node-based which makes relating page reclaim to slab reclaim harder than it should be.
Agreed. And I'm sure dchinner also much prefers moving the VM towards a node model over moving the shrinkers towards the zone model.
Quoted 11 lines
The reason we have zone-based reclaim is that we used to have large highmem zones in common configurations and it was necessary to quickly find
ZONE_NORMALpages for reclaim. Today, this is much less of a concern as machines with lots of memory will (or should) use 64-bit kernels. Combinations of 32-bit hardware and 64-bit hardware are rare. Machines that do use highmem should have relatively low highmem:lowmem ratios than we worried about in the past.Conceptually, moving to node LRUs should be easier to understand. The page allocator plays fewer tricks to game reclaim and reclaim behaves similarly on all nodes.
Do you think it's feasible to serve the occasional address-restricted request from CMA, or a similar mechanism based on PFN ranges? In the longterm, it would be great to eradicate struct zone entirely, and have the page allocator and reclaim talk about the same thing again without having to translate back and forth between zones and nodes.
It would also be much better for DMA allocations that don't align with the zone model, such as 31-bit address requests, which currently have to play the lottery with GFP_DMA32 and fall back to GFP_DMA.
Quoted 6 lines
It was tested on a UMA (8 cores single socket) and a NUMA machine (48 cores, 4 sockets). The page allocator tests showed marginal differences in aim9, page fault microbenchmark, page allocator micro-benchmark and ebizzy. This was expected as the affected paths are small in comparison to the overall workloads.
Quoted 6 lines
I also tested using fstest on zero-length files to stress slab reclaim. It showed no major differences in performance or stats.
A THP-based test case that stresses compaction was inconclusive. It showed differences in the THP allocation success rate and both gains and losses in the time it takes to allocate THP depending on the number of threads running.
It would useful to include a "reasonable" highmem test here as well.
Quoted 5 lines
Tests did show there were differences in the pages allocated from each zone. This is due to the fact the fair zone allocation policy is removed as with node-based LRU reclaim, it *should* not be necessary. It would be preferable if the original database workload that motivated the introduction of that policy was retested with this series though.
It's as simple as repeatedly reading a file that is ever-so-slightly bigger than the available memory. The result should be a perfect tail-chasing scenario, with the entire file being served from disk every single time. If parts of it get activated, that is a problem, because it means that some pages get aged differently than others.
When I worked on the fair zone allocator, I hacked mincore() to report PG_active, to be extra sure about where the pages of interest are, but monitoring pgactivate during the test, or comparing its deltas between kernels, should be good enough.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 9 lines · Johannes Weiner
Hi Mel,
these are cool patches, I very much like the direction this is headed.
Quoted 4 lines · Mel Gorman
This is an RFC series against 4.0 that moves LRUs from the zones to the node. In concept, this is straight forward but there are a lot of details so I'm posting it early to see what people think. The motivations are;
Quoted 7 lines
Quoted 3 lines
1. Currently, reclaim on node 0 behaves differently to node 1 with subtly different aging rules. Workloads may exhibit different behaviour depending on what node it was scheduled on as a result.
How so? Don't we ultimately age pages in proportion to node size, regardless of how many zones they are broken into?
For example, direct reclaim scans in zonelist order (highest eligible zone first) and stops when SWAP_CLUSTER_MAX pages are reclaimed which could be entirely from one zone. The fair zone policy limits age inversion problems but it's still different to what happens when direct reclaim starts on a node with one populated zone.
kswapd will not reclaim from the highest zone if it's already balanced. If the distribution of anon/file pages differs between zones due to when they were allocated then it's slightly different.
I expect in most cases that it makes little difference but moving to node-base reclaim gets rid of some of these differences.
Quoted 10 lines
Quoted 4 lines
2. The residency of a page partially depends on what zone the page was allocated from. This is partially combatted by the fair zone allocation policy but that is a partial solution that introduces overhead in the page allocator paths.
Yeah, it's ugly and I'm happy you're getting rid of this again. That being said, in my tests it seemed like a complete solution to remove any influence from allocation placement on aging behavior. Where do you still see aging artifacts?
I actually have not created an artifical test case that games the fair zone allocation policy and I expect in almost all cases that the fair zone allocation policy is adequate. It's just not necessary if we reclaim on a per-node basis.
Quoted 6 lines
Quoted 2 lines
3. kswapd and the page allocator play special games with the order they scan zones to avoid interfering with each other but it's unpredictable.
It would be good to recall here these interference issues, how they are currently coped with, and how your patches address them.
It is coped with by having kswapd reclaim in the opposite order that the page allocator prefers. This prevents the allocator always reusing pages reclaimed by kswapd recently. It's not handled at all with direct reclaim as it reclaims in zonelist order. With the patches it should be simply unnecessary to avoid this problem as pages are reclaimed in the order of their age unless the caller requires a page from a low zone.
Quoted 5 lines
Quoted 2 lines
4. The different scan activity and ordering for zone reclaim is very difficult to predict.
I'm not sure what this means.
The order that pages get reclaimed in partially depends on when allocataions push a zone below a watermark. The time that kswapd examines a zone versus the page allocator matters more than it should.
Quoted 14 lines
Quoted 2 lines
5. slab shrinkers are node-based which makes relating page reclaim to slab reclaim harder than it should be.
Agreed. And I'm sure dchinner also much prefers moving the VM towards a node model over moving the shrinkers towards the zone model.
Quoted 8 lines
The reason we have zone-based reclaim is that we used to have large highmem zones in common configurations and it was necessary to quickly find
ZONE_NORMALpages for reclaim. Today, this is much less of a concern as machines with lots of memory will (or should) use 64-bit kernels. Combinations of 32-bit hardware and 64-bit hardware are rare. Machines that do use highmem should have relatively low highmem:lowmem ratios than we worried about in the past.
Quoted 6 lines
Quoted 3 lines
Conceptually, moving to node LRUs should be easier to understand. The page allocator plays fewer tricks to game reclaim and reclaim behaves similarly on all nodes.
Do you think it's feasible to serve the occasional address-restricted request from CMA, or a similar mechanism based on PFN ranges?
I worried that it would get very expensive as we would have to search the free lists to find a page of the correct address. If one is not found then we have to reclaim based on PFN ranges and then retry. Each address-restricted allocation would have to retry the search. Potentially we could use migrate types to prevent a percentage of the lower zones being used for unmovable allocations but we'd still have to do the search.
Quoted 5 lines
In the
longterm, it would be great to eradicate struct zone entirely, and have the page allocator and reclaim talk about the same thing again without having to translate back and forth between zones and nodes.
I agree it would be great in the long term. I don't see how it could be done now but that is partially because node-based reclaim alone is a big set of changes.
Quoted 4 lines
It would also be much better for DMA allocations that don't align with the zone model, such as 31-bit address requests, which currently have to play the lottery with
GFP_DMA32and fall back toGFP_DMA.
Also true. Maybe it would be a reserve-based mechanism and subsystems register their requirements and then use a mempool-like mechanism to limit searching. It certainly would be worth examining if/when node-based reclaim gets ironed out and we are confident that there are no regressions.
Quoted 6 lines
Quoted 6 lines
It was tested on a UMA (8 cores single socket) and a NUMA machine (48 cores, 4 sockets). The page allocator tests showed marginal differences in aim9, page fault microbenchmark, page allocator micro-benchmark and ebizzy. This was expected as the affected paths are small in comparison to the overall workloads.
Quoted 9 lines
Quoted 6 lines
I also tested using fstest on zero-length files to stress slab reclaim. It showed no major differences in performance or stats.
A THP-based test case that stresses compaction was inconclusive. It showed differences in the THP allocation success rate and both gains and losses in the time it takes to allocate THP depending on the number of threads running.
It would useful to include a "reasonable" highmem test here as well.
I think something IO-intensive with a large highmem zone would do the job.
Quoted 6 lines
Quoted 5 lines
Tests did show there were differences in the pages allocated from each zone. This is due to the fact the fair zone allocation policy is removed as with node-based LRU reclaim, it *should* not be necessary. It would be preferable if the original database workload that motivated the introduction of that policy was retested with this series though.
Quoted 6 lines
It's as simple as repeatedly reading a file that is ever-so-slightly bigger than the available memory. The result should be a perfect tail-chasing scenario, with the entire file being served from disk every single time. If parts of it get activated, that is a problem, because it means that some pages get aged differently than others.
Ok, that is trivial to put together.
Quoted 4 lines
When I worked on the fair zone allocator, I hacked
mincore()to reportPG_active, to be extra sure about where the pages of interest are, but monitoring pgactivate during the test, or comparing its deltas between kernels, should be good enough.
Thanks.
Signature · 8 lines
Mel Gorman SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>