Move LRU page reclaim from zones to nodes v7
Subsystems (29)
cover Move LRU page reclaim from zones to nodes v7
(sorry for resend, the previous attempt didn't go through fully for some reason)
The bulk of the updates are in response to review from Vlastimil Babka and received a lot more testing than v6.
Changelog since v6
o Correct reclaim_idx when direct reclaiming for memcg
o Also account LRU pages per zone for compaction/reclaim
o Add page_pgdat helper with more efficient lookup
o Init pgdat LRU lock only once
o Slight optimisation to wake_all_kswapds
o Always wake kcompactd when kswapd is going to sleep
o Rebase to mmotm as of June 15th, 2016
Changelog since v5
o Rebase and adjust to changes
Changelog since v4
o Rebase on top of v3 of page allocator optimisation series
Changelog since v3
o Rebase on top of the page allocator optimisation series
o Remove RFC tag
This is the latest version of a series that moves LRUs from the zones to the node that is based upon 4.6-rc3 plus the page allocator optimisation series. Conceptually, this is simple but there are a lot of details. Some of the broad motivations for this are;
1. 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.
2. Currently, reclaim on node 0 behaves slightly different to node 1. For example, direct reclaim scans in zonelist order and reclaims even if the zone is over the high watermark regardless of the age of pages in that LRU. Kswapd on the other hand starts reclaim on the highest unbalanced zone. A difference in distribution of file/anon pages due to when they were allocated results can result in a difference in again. While the fair zone allocation policy mitigates some of the problems here, the page reclaim results on a multi-zone node will always be different to a single-zone node.
it was scheduled on as a result.
3. kswapd and the page allocator scan zones in the opposite order to avoid interfering with each other but it's sensitive to timing. This mitigates the page allocator using pages that were allocated very recently in the ideal case but it's sensitive to timing. When kswapd is allocating from lower zones then it's great but during the rebalancing of the highest zone, the page allocator and kswapd interfere with each other. It's worse if the highest zone is small and difficult to balance.
4. slab shrinkers are node-based which makes it harder to identify the exact relationship between slab reclaim and LRU reclaim.
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 has been tested on a 16 core UMA machine and a 2-socket 48 core NUMA machine. The UMA results are presented in most cases as the NUMA machine behaved similarly.
pagealloc
---------
This is a microbenchmark that shows the benefit of removing the fair zone allocation policy. It was tested uip to order-4 but only orders 0 and 1 are shown as the other orders were comparable.
4.7.0-rc3 4.7.0-rc3
mmotm-20160615 nodelru-v7r17
Min total-odr0-1 485.00 ( 0.00%) 462.00 ( 4.74%)
Min total-odr0-2 354.00 ( 0.00%) 341.00 ( 3.67%)
Min total-odr0-4 285.00 ( 0.00%) 277.00 ( 2.81%)
Min total-odr0-8 249.00 ( 0.00%) 240.00 ( 3.61%)
Min total-odr0-16 230.00 ( 0.00%) 224.00 ( 2.61%)
Min total-odr0-32 222.00 ( 0.00%) 215.00 ( 3.15%)
Min total-odr0-64 216.00 ( 0.00%) 210.00 ( 2.78%)
Min total-odr0-128 214.00 ( 0.00%) 208.00 ( 2.80%)
Min total-odr0-256 248.00 ( 0.00%) 233.00 ( 6.05%)
Min total-odr0-512 277.00 ( 0.00%) 270.00 ( 2.53%)
Min total-odr0-1024 294.00 ( 0.00%) 284.00 ( 3.40%)
Min total-odr0-2048 308.00 ( 0.00%) 298.00 ( 3.25%)
Min total-odr0-4096 318.00 ( 0.00%) 307.00 ( 3.46%)
Min total-odr0-8192 322.00 ( 0.00%) 308.00 ( 4.35%)
Min total-odr0-16384 324.00 ( 0.00%) 309.00 ( 4.63%)
Min total-odr1-1 729.00 ( 0.00%) 686.00 ( 5.90%)
Min total-odr1-2 533.00 ( 0.00%) 520.00 ( 2.44%)
Min total-odr1-4 434.00 ( 0.00%) 415.00 ( 4.38%)
Min total-odr1-8 390.00 ( 0.00%) 364.00 ( 6.67%)
Min total-odr1-16 359.00 ( 0.00%) 335.00 ( 6.69%)
Min total-odr1-32 356.00 ( 0.00%) 327.00 ( 8.15%)
Min total-odr1-64 356.00 ( 0.00%) 321.00 ( 9.83%)
Min total-odr1-128 356.00 ( 0.00%) 333.00 ( 6.46%)
Min total-odr1-256 354.00 ( 0.00%) 337.00 ( 4.80%)
Min total-odr1-512 366.00 ( 0.00%) 340.00 ( 7.10%)
Min total-odr1-1024 373.00 ( 0.00%) 354.00 ( 5.09%)
Min total-odr1-2048 375.00 ( 0.00%) 354.00 ( 5.60%)
Min total-odr1-4096 374.00 ( 0.00%) 354.00 ( 5.35%)
Min total-odr1-8192 370.00 ( 0.00%) 355.00 ( 4.05%)This shows a steady improvement throughout. The primary benefit is from reduced system CPU usage which is obvious from the overall times;
4.7.0-rc3 4.7.0-rc3
mmotm-20160615 nodelru-v7
User 174.06 174.58
System 2656.78 2485.21
Elapsed 2885.07 2713.67The vmstats also showed that the fair zone allocation policy was definitely removed as can be seen here;
4.7.0-rc3 4.7.0-rc3
mmotm-20160615nodelru-v7r17DMA32 allocs 28794408561 0
Normal allocs 48431969998 77226313470
Movable allocs 0 0
tiobench on ext4
----------------
tiobench is a benchmark that artifically benefits if old pages remain resident while new pages get reclaimed. The fair zone allocation policy mitigates this problem so pages age fairly. While the benchmark has problems, it is important that tiobench performance remains constant as it implies that page aging problems that the fair zone allocation policy fixes are not re-introduced.
4.7.0-rc3 4.7.0-rc3
mmotm-20160615 nodelru-v7r17
Min PotentialReadSpeed 90.24 ( 0.00%) 90.14 ( -0.11%)
Min SeqRead-MB/sec-1 80.63 ( 0.00%) 83.09 ( 3.05%)
Min SeqRead-MB/sec-2 71.91 ( 0.00%) 72.44 ( 0.74%)
Min SeqRead-MB/sec-4 75.20 ( 0.00%) 74.32 ( -1.17%)
Min SeqRead-MB/sec-8 65.30 ( 0.00%) 65.21 ( -0.14%)
Min SeqRead-MB/sec-16 62.62 ( 0.00%) 62.12 ( -0.80%)
Min RandRead-MB/sec-1 0.90 ( 0.00%) 0.94 ( 4.44%)
Min RandRead-MB/sec-2 0.96 ( 0.00%) 0.97 ( 1.04%)
Min RandRead-MB/sec-4 1.43 ( 0.00%) 1.41 ( -1.40%)
Min RandRead-MB/sec-8 1.67 ( 0.00%) 1.72 ( 2.99%)
Min RandRead-MB/sec-16 1.77 ( 0.00%) 1.86 ( 5.08%)
Min SeqWrite-MB/sec-1 78.12 ( 0.00%) 79.78 ( 2.12%)
Min SeqWrite-MB/sec-2 72.74 ( 0.00%) 73.23 ( 0.67%)
Min SeqWrite-MB/sec-4 79.40 ( 0.00%) 78.32 ( -1.36%)
Min SeqWrite-MB/sec-8 73.18 ( 0.00%) 71.40 ( -2.43%)
Min SeqWrite-MB/sec-16 75.82 ( 0.00%) 75.24 ( -0.76%)
Min RandWrite-MB/sec-1 1.18 ( 0.00%) 1.15 ( -2.54%)
Min RandWrite-MB/sec-2 1.05 ( 0.00%) 0.99 ( -5.71%)
Min RandWrite-MB/sec-4 1.00 ( 0.00%) 0.96 ( -4.00%)
Min RandWrite-MB/sec-8 0.91 ( 0.00%) 0.92 ( 1.10%)
Min RandWrite-MB/sec-16 0.92 ( 0.00%) 0.92 ( 0.00%)This shows that the series has little or not impact on tiobench which is desirable. It indicates that the fair zone allocation policy was removed in a manner that didn't reintroduce one class of page aging bug. There were only minor differences in overall reclaim activity
4.7.0-rc3 4.7.0-rc3
mmotm-20160615nodelru-v7r17
Minor Faults 640992 640721
Major Faults 728 623
Swap Ins 0 0
Swap Outs 0 0
DMA allocs 0 0
DMA32 allocs 46174282 44219717
Normal allocs 77949344 79858024
Movable allocs 0 0
Allocation stalls 38 76
Direct pages scanned 17463 34865
Kswapd pages scanned 93331163 93302388
Kswapd pages reclaimed 93328173 93299677Direct pages reclaimed 17463 34865
Kswapd efficiency 99% 99%
Kswapd velocity 13729.855 13755.612
Direct efficiency 100% 100%
Direct velocity 2.569 5.140
Percentage direct scans 0% 0%
Page writes by reclaim 0 0 Page writes file 0 0 Page writes anon 0 0
Page reclaim immediate 54 36
kswapd activity was roughly comparable. There was slight differences in direct reclaim activity but negligible in the context of the overall workload (velocity of 5 pages per second with the patches applied, 2 pages per second in the baseline kernel).
pgbench read-only large configuration on ext4
---------------------------------------------
pgbench is a database benchmark that can be sensitive to page reclaim decisions. This also checks if removing the fair zone allocation policy is safe
pgbench Transactions
4.7.0-rc3 4.7.0-rc3
mmotm-20160615 nodelru-v7r17
Hmean 1 191.00 ( 0.00%) 193.67 ( 1.40%)
Hmean 5 338.59 ( 0.00%) 336.99 ( -0.47%)
Hmean 12 374.03 ( 0.00%) 386.15 ( 3.24%)
Hmean 21 372.24 ( 0.00%) 372.02 ( -0.06%)
Hmean 30 383.98 ( 0.00%) 370.69 ( -3.46%)
Hmean 32 431.01 ( 0.00%) 438.47 ( 1.73%)Negligible differences again. As with tiobench, overall reclaim activity was comparable.
bonnie++ on ext4
----------------
No interesting performance difference, negligible differences on reclaim stats.
paralleldd on ext4
------------------
This workload uses varying numbers of dd instances to read large amounts of data from disk.
paralleldd
4.7.0-rc3 4.7.0-rc3
mmotm-20160615 nodelru-v7r17
Amean Elapsd-1 181.57 ( 0.00%) 179.63 ( 1.07%)
Amean Elapsd-3 188.29 ( 0.00%) 183.68 ( 2.45%)
Amean Elapsd-5 188.02 ( 0.00%) 181.73 ( 3.35%)
Amean Elapsd-7 186.07 ( 0.00%) 184.11 ( 1.05%)
Amean Elapsd-12 188.16 ( 0.00%) 183.51 ( 2.47%)
Amean Elapsd-16 189.03 ( 0.00%) 181.27 ( 4.10%) 4.7.0-rc3 4.7.0-rc3
mmotm-20160615nodelru-v7r17
User 1439.23 1433.37
System 8332.31 8216.01
Elapsed 3619.80 3532.69There is a slight gain in performance, some of which is from the reduced system CPU usage. There areminor differences in reclaim activity but nothing significant
4.7.0-rc3 4.7.0-rc3
mmotm-20160615nodelru-v7r17Minor Faults 362486 358215
Major Faults 1143 1113
Swap Ins 26 0
Swap Outs 2920 482
DMA allocs 0 0
DMA32 allocs 31568814 28598887 Normal allocs 46539922 49514444 Movable allocs 0 0 Allocation stalls 0 0 Direct pages scanned 0 0 Kswapd pages scanned 40886878 40849710 Kswapd pages reclaimed 40869923 40835207
Direct pages reclaimed 0 0
Kswapd efficiency 99% 99%
Kswapd velocity 11295.342 11563.344
Direct efficiency 100% 100%
Direct velocity 0.000 0.000
Slabs scanned 131673 126099
Direct inode steals 57 60
Kswapd inode steals 762 18
It basically shows that kswapd was active at roughly the same rate in both kernels. There was also comparable slab scanning activity and direct reclaim was avoided in both cases. There appears to be a large difference in numbers of inodes reclaimed but the workload has few active inodes and is likely a timing artifact. It's interesting to note that the node-lru did not swap in any pages but given the low swap activity, it's unlikely to be significant.
stutter
-------
stutter simulates a simple workload. One part uses a lot of anonymous memory, a second measures mmap latency and a third copies a large file. The primary metric is checking for mmap latency.
stutter
4.7.0-rc3 4.7.0-rc3
mmotm-20160615 nodelru-v7r17
Min mmap 16.8422 ( 0.00%) 15.9821 ( 5.11%)
1st-qrtle mmap 57.8709 ( 0.00%) 58.0794 ( -0.36%)
2nd-qrtle mmap 58.4335 ( 0.00%) 59.4286 ( -1.70%)
3rd-qrtle mmap 58.6957 ( 0.00%) 59.6862 ( -1.69%)
Max-90% mmap 58.9388 ( 0.00%) 59.8759 ( -1.59%)
Max-93% mmap 59.0505 ( 0.00%) 59.9333 ( -1.50%)
Max-95% mmap 59.1877 ( 0.00%) 59.9844 ( -1.35%)
Max-99% mmap 60.3237 ( 0.00%) 60.2337 ( 0.15%)
Max mmap 285.6454 ( 0.00%) 135.6006 ( 52.53%)
Mean mmap 57.8366 ( 0.00%) 58.4884 ( -1.13%)This shows that there is a slight impact on mmap latency but that the worst-case outlier is much improved. As the problem with this benchmark used to be that the kernel stalled for minutes, this difference is negligible.
Some of the vmstats are interesting
4.7.0-rc3 4.7.0-rc3
mmotm-20160615nodelru-v7r17
Swap Ins 58 42
Swap Outs 0 0
Allocation stalls 16 0
Direct pages scanned 1374 0
Kswapd pages scanned 42454910 41782544
Kswapd pages reclaimed 41571035 41781833Direct pages reclaimed 1167 0
Kswapd efficiency 97% 99%
Kswapd velocity 14774.479 14223.796
Direct efficiency 84% 100%
Direct velocity 0.478 0.000
Percentage direct scans 0% 0%
Page writes by reclaim 696918 0 Page writes file 696918 0 Page writes anon 0 0 Page reclaim immediate 2940 137 Sector Reads 81644424 81699544 Sector Writes 99193620 98862160
Page rescued immediate 0 0
Slabs scanned 1279838 22640
kswapd and direct reclaim activity are similar but the node LRU series did not attempt to trigger any page writes from reclaim context.
This series is not without its hazards. There are at least three areas that I'm concerned with even though I could not reproduce any problems in that area.
1. Reclaim/compaction is going to be affected because the amount of reclaim is no longer targetted at a specific zone. Compaction works on a per-zone basis so there is no guarantee that reclaiming a few THP's worth page pages will have a positive impact on compaction success rates.
2. The Slab/LRU reclaim ratio is affected because the frequency the shrinkers are called is now different. This may or may not be a problem but if it is, it'll be because shrinkers are not called enough and some balancing is required.
3. The anon/file reclaim ratio may be affected. Pages about to be dirtied are distributed between zones and the fair zone allocation policy used to do something very similar for anon. The distribution is now different but not necessarily in any way that matters but it's still worth bearing in mind.
Documentation/cgroup-v1/memcg_test.txt | 4 +- Documentation/cgroup-v1/memory.txt | 4 +- 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 | 4 +- 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 | 32 +- include/linux/mm.h | 5 + include/linux/mm_inline.h | 21 +- include/linux/mm_types.h | 2 +- include/linux/mmzone.h | 158 +++--- include/linux/swap.h | 23 +- include/linux/topology.h | 2 +- include/linux/vm_event_item.h | 14 +- include/linux/vmstat.h | 111 +++- include/linux/writeback.h | 2 +- include/trace/events/vmscan.h | 63 ++- include/trace/events/writeback.h | 10 +- kernel/power/snapshot.c | 10 +- kernel/sysctl.c | 4 +- mm/backing-dev.c | 15 +- mm/compaction.c | 28 +- mm/filemap.c | 14 +- mm/huge_memory.c | 33 +- mm/internal.h | 11 +- mm/memcontrol.c | 246 ++++---- mm/memory-failure.c | 4 +- mm/memory_hotplug.c | 7 +- mm/mempolicy.c | 2 +- mm/migrate.c | 35 +- mm/mlock.c | 12 +- mm/page-writeback.c | 124 ++-- mm/page_alloc.c | 268 ++++----- mm/page_idle.c | 4 +- mm/rmap.c | 14 +- mm/shmem.c | 12 +- mm/swap.c | 66 +-- mm/swap_state.c | 4 +- mm/util.c | 4 +- mm/vmscan.c | 901 +++++++++++++++--------------- mm/vmstat.c | 376 ++++++++++--- mm/workingset.c | 54 +- 48 files changed, 1573 insertions(+), 1263 deletions(-)
Signature · 7 lines
2.6.4 -- 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/27 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. The most notable change is that the old node_page_state is renamed to sum_zone_node_page_state. The new node_page_state takes a pglist_data and uses per-node stats but none exist yet. There is some renaming such as vm_stat to vm_zone_stat and the addition of vm_node_stat and the renaming of mod_state to mod_zone_state. Otherwise, this is mostly a mechanical patch with no functional change. There is a lot of similarity between the node and zone helpers which is unfortunate but there was no obvious way of reusing the code and maintaining type safety.
--- drivers/base/node.c | 72 +++++++------ include/linux/mm.h | 5 + include/linux/mmzone.h | 13 +++ include/linux/vmstat.h | 92 +++++++++++++--- mm/page_alloc.c | 10 +- mm/vmstat.c | 282 +++++++++++++++++++++++++++++++++++++++++++++---- mm/workingset.c | 9 +- 7 files changed, 409 insertions(+), 74 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/mm.h +5 -0
@@ -908,6 +908,11 @@ static inline struct zone *page_zone(const struct page *page)return &NODE_DATA (page_to_nid (page))->node_zones[page_zonenum (page)]; } +static inline pg_data_t *page_pgdat (const struct page *page) +{ +return NODE_DATA (page_to_nid (page)); +} +#ifdef SECTION_IN_PAGE_FLAGS static inline void set_page_section (struct page *page,unsigned long section) {
include/linux/mmzone.h +13 -0
@@ -158,6 +158,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
@@ -265,6 +269,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 {
@@ -693,6 +702,10 @@ typedef struct pglist_data {struct list_head split_queue;unsigned long split_queue_len;#endif + +/* Per-node vmstats */ +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 +80 -12
166 lines not on this page · raw message
mm/page_alloc.c +8 -2
@@ -4209,8 +4209,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 for (zone_type =0 ; zone_type <MAX_NR_ZONES ; zone_type++) {struct zone *zone = &pgdat->node_zones[zone_type];
@@ -5316,6 +5316,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); + } }/*
@@ -6021,6 +6026,7 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size,reset_deferred_meminit (pgdat); pgdat->node_id = nid; pgdat->node_start_pfn = node_start_pfn; + pgdat->per_cpu_nodestats =NULL ;#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP get_pfn_range_for_nid (nid, &start_pfn, &end_pfn); pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
mm/vmstat.c +259 -23
449 lines not on this page · raw message
mm/workingset.c +5 -4
@@ -349,12 +349,13 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker, shadow_nodes =list_lru_shrink_count (&workingset_shadow_nodes, sc);local_irq_enable (); -if (memcg_kmem_enabled ()) +if (memcg_kmem_enabled ()) { pages =mem_cgroup_node_nr_lru_pages (sc->memcg, sc->nid,LRU_ALL_FILE ); -else - pages =node_page_state (sc->nid,NR_ACTIVE_FILE ) + -node_page_state (sc->nid,NR_INACTIVE_FILE ); + }else { + pages =sum_zone_node_page_state (sc->nid,NR_ACTIVE_FILE ) + +sum_zone_node_page_state (sc->nid,NR_INACTIVE_FILE ); + }/* * Active cache pages are limited to 50% of memory, and shadow
Signature · 7 lines
2.6.4 -- 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/27 mm, vmscan: Move lru_lock to the node
In reply to Mel GormanNode-based reclaim requires node-based LRUs and locking. This is a preparation patch that just moves the lru_lock to the node so later patches are easier to review. It is a mechanical change but note this patch makes contention worse because the LRU lock is hotter and direct reclaim and kswapd can contend on the same lock even when reclaiming from different zones.
--- Documentation/cgroup-v1/memcg_test.txt | 4 +-- Documentation/cgroup-v1/memory.txt | 4 +-- include/linux/mm_types.h | 2 +- include/linux/mmzone.h | 10 +++++-- mm/compaction.c | 10 +++---- mm/filemap.c | 4 +-- mm/huge_memory.c | 4 +-- mm/memcontrol.c | 6 ++--- mm/mlock.c | 10 +++---- mm/page_alloc.c | 4 +-- mm/page_idle.c | 4 +-- mm/rmap.c | 2 +- mm/swap.c | 30 ++++++++++----------- mm/vmscan.c | 48 +++++++++++++++++----------------- 14 files changed, 74 insertions(+), 68 deletions(-)
Documentation/cgroup-v1/memcg_test.txt +2 -2
@@ -107,9 +107,9 @@ Under below explanation, we assume CONFIG_MEM_RES_CTRL_SWAP=y. 8. LRU Each memcg has its own private LRU. Now, its handling is under global - VM's control (means that it's handled under global zone->lru_lock). + VM's control (means that it's handled under global zone_lru_lock). Almost all routines around memcg's LRU is called by global LRU's - list management functions under zone->lru_lock(). + list management functions under zone_lru_lock(). A special function is mem_cgroup_isolate_pages(). This scans memcg's private LRU and call __isolate_lru_page() to extract a page
Documentation/cgroup-v1/memory.txt +2 -2
@@ -267,11 +267,11 @@ When oom event notifier is registered, event will be delivered. Other lock order is following: PG_locked. mm->page_table_lock - zone->lru_lock + zone_lru_lock lock_page_cgroup. In many cases, just lock_page_cgroup() is called. per-zone-per-cgroup LRU (cgroup's private LRU) is just guarded by - zone->lru_lock, it has no lock of its own. + zone_lru_lock, it has no lock of its own. 2.7 Kernel Memory Extension (CONFIG_MEMCG_KMEM)
include/linux/mm_types.h +1 -1
@@ -118,7 +118,7 @@ struct page {*/ union {struct list_head lru;/* Pageout list, eg. active_list -* protected by zone->lru_lock ! +* protected by zone_lru_lock ! * Can be used as a generic list * by the page owner. */
include/linux/mmzone.h +8 -2
@@ -93,7 +93,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.
@@ -494,7 +494,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;/*
@@ -688,6 +687,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;#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT /*
@@ -719,6 +721,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 +5 -5
@@ -754,7 +754,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 ;
@@ -816,7 +816,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,if (unlikely (__PageMovable (page)) && !PageIsolated (page)) {if (locked) { -spin_unlock_irqrestore (&zone->lru_lock, +spin_unlock_irqrestore (zone_lru_lock (zone), flags); locked = false; }
@@ -839,7 +839,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 ;
@@ -902,7 +902,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,*/ if (nr_isolated) {if (locked) { -spin_unlock_irqrestore (&zone->lru_lock, flags); +spin_unlock_irqrestore (zone_lru_lock (zone), flags); locked = false; }acct_isolated (zone, cc);
@@ -930,7 +930,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, 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(zone) (follow_page->mark_page_accessed) +* ->zone_lru_lock(zone) (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
@@ -3305,7 +3305,7 @@ static void __split_huge_page(struct page *page, struct list_head *list)int i;/* 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 (head, zone);/* complete memcg works before add pages to LRU */
@@ -3315,7 +3315,7 @@ static void __split_huge_page(struct page *page, struct list_head *list)__split_huge_page_tail (head, i, lruvec, list);ClearPageCompound (head); -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irq (zone_lru_lock (zone));unfreeze_page (head);
mm/memcontrol.c +3 -3
@@ -2107,7 +2107,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;
@@ -2131,7 +2131,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,
@@ -2431,7 +2431,7 @@ void memcg_kmem_uncharge(struct page *page, int order)/* * Because tail pages are not marked as "used", set it. We're under -* zone->lru_lock and migration entries setup in all page mappings. +* zone_lru_lock and migration entries setup in all page mappings. */ void mem_cgroup_split_huge_fixup (struct page *head) {
mm/mlock.c +5 -5
@@ -188,7 +188,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))
@@ -197,14 +197,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 ;
@@ -289,7 +289,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];
@@ -315,7 +315,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
@@ -5890,6 +5890,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat)init_waitqueue_head (&pgdat->kcompactd_wait);#endif pgdat_page_ext_init (pgdat); +spin_lock_init (&pgdat->lru_lock);for (j =0 ; j <MAX_NR_ZONES ; j++) {struct zone *zone = pgdat->node_zones + j;
@@ -5944,10 +5945,9 @@ 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);zone_seqlock_init (zone); - zone->zone_pgdat = pgdat;zone_pcp_init (zone);/* For bootup, initialized properly in watermark setup */
mm/page_idle.c +2 -2
@@ -41,12 +41,12 @@ static struct page *page_idle_get_page(unsigned long pfn)return NULL ; zone =page_zone (page); -spin_lock_irq (&zone->lru_lock); +spin_lock_irq (zone_lru_lock (zone));if (unlikely (!PageLRU (page))) {put_page (page); page =NULL ; } -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irq (zone_lru_lock (zone));return page; }
mm/rmap.c +1 -1
@@ -27,7 +27,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
@@ -62,12 +62,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); }
@@ -189,16 +189,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); }
@@ -316,9 +316,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
@@ -447,13 +447,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)); }/**
@@ -743,7 +743,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 ; }
@@ -758,7 +758,7 @@ void release_pages(struct page **pages, int nr, bool cold)if (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);
@@ -770,11 +770,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);
@@ -789,7 +789,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);
@@ -825,7 +825,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 +24 -24
169 lines not on this page · raw message
Signature · 7 lines
2.6.4 -- 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/27 mm, vmscan: Move LRU lists to node
In reply to Mel GormanThis moves the LRU lists from the zone to the node and related data such as counters, tracing, congestion tracking and writeback tracking. Unfortunately, due to reclaim and compaction retry logic, it is necessary to account for the number of LRU pages on both zone and node logic. Most reclaim logic is based on the node counters but the retry logic uses the zone counters which do not distinguish inactive and inactive sizes. It would be possible to leave the LRU counters on a per-zone basis but it's a heavier calculation across multiple cache lines that is much more frequent than the retry checks.
Other than the LRU counters, 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 | 10 +- include/linux/mm_inline.h | 21 ++- include/linux/mmzone.h | 69 +++++---- include/linux/swap.h | 1 + include/linux/vm_event_item.h | 10 +- include/linux/vmstat.h | 17 +++ include/trace/events/vmscan.h | 12 +- kernel/power/snapshot.c | 10 +- mm/backing-dev.c | 15 +- mm/compaction.c | 18 +-- mm/huge_memory.c | 6 +- mm/internal.h | 2 +- mm/memcontrol.c | 23 +-- 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 | 70 ++++----- mm/swap.c | 56 ++++---- mm/vmscan.c | 226 +++++++++++++++++------------- mm/vmstat.c | 47 ++++--- mm/workingset.c | 4 +- 28 files changed, 390 insertions(+), 303 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
@@ -72,10 +72,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
@@ -197,7 +197,7 @@ static inline int wb_congested(struct bdi_writeback *wb, int cong_bits) }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 +5 -5
@@ -307,7 +307,7 @@ void mem_cgroup_uncharge_list(struct list_head *page_list);void mem_cgroup_migrate (struct page *oldpage,struct page *newpage);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 task_in_mem_cgroup (struct task_struct *task,struct mem_cgroup *memcg);struct mem_cgroup *mem_cgroup_from_task (struct task_struct *p);
@@ -401,7 +401,7 @@ static inline bool mem_cgroup_online(struct mem_cgroup *memcg)int mem_cgroup_select_victim_node (struct mem_cgroup *memcg);void mem_cgroup_update_lru_size (struct lruvec *lruvec,enum lru_list lru, -int nr_pages); +enum zone_type zid,int nr_pages);unsigned long mem_cgroup_node_nr_lru_pages (struct mem_cgroup *memcg,int nid,unsigned int lru_mask);
@@ -576,13 +576,13 @@ static inline void mem_cgroup_migrate(struct page *old, struct page *new)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 bool mm_match_cgroup(struct mm_struct *mm,
include/linux/mm_inline.h +14 -7
@@ -23,25 +23,32 @@ static inline int page_is_file_cache(struct page *page) } static __always_inline void __update_lru_size(struct lruvec *lruvec, -enum lru_list lru,int nr_pages) +enum lru_list lru,enum zone_type zid, +int nr_pages) { -__mod_zone_page_state (lruvec_zone (lruvec),NR_LRU_BASE + lru, nr_pages); +struct pglist_data *pgdat =lruvec_pgdat (lruvec); + +__mod_node_page_state (pgdat,NR_LRU_BASE + lru, nr_pages); +__mod_zone_page_state (&pgdat->node_zones[zid], +NR_ZONE_LRU_BASE + !!is_file_lru (lru), + nr_pages); } static __always_inline void update_lru_size(struct lruvec *lruvec, -enum lru_list lru,int nr_pages) +enum lru_list lru,enum zone_type zid, +int nr_pages) {#ifdef CONFIG_MEMCG -mem_cgroup_update_lru_size (lruvec, lru, nr_pages); +mem_cgroup_update_lru_size (lruvec, lru, zid, nr_pages);#else -__update_lru_size (lruvec, lru, nr_pages); +__update_lru_size (lruvec, lru, zid, nr_pages);#endif } static __always_inline void add_page_to_lru_list(struct page *page,struct lruvec *lruvec,enum lru_list lru) { -update_lru_size (lruvec, lru,hpage_nr_pages (page)); +update_lru_size (lruvec, lru,page_zonenum (page),hpage_nr_pages (page));list_add (&page->lru, &lruvec->lists[lru]); }
@@ -49,7 +56,7 @@ static __always_inline void del_page_from_lru_list(struct page *page, struct lruvec *lruvec, enum lru_list lru) {list_del (&page->lru); -update_lru_size (lruvec, lru, -hpage_nr_pages (page)); +update_lru_size (lruvec, lru,page_zonenum (page), -hpage_nr_pages (page)); }/**
include/linux/mmzone.h +42 -27
148 lines not on this page · raw message
include/linux/swap.h +1 -0
@@ -317,6 +317,7 @@ extern void lru_cache_add_active_or_unevictable(struct page *page,/* linux/mm/vmscan.c */ extern unsigned long zone_reclaimable_pages (struct zone *zone); +extern unsigned long pgdat_reclaimable_pages (struct pglist_data *pgdat);extern unsigned long try_to_free_pages (struct zonelist *zonelist,int order,gfp_t gfp_mask,nodemask_t *mask);extern int __isolate_lru_page (struct page *page,isolate_mode_t mode);
include/linux/vm_event_item.h +5 -5
@@ -26,11 +26,11 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,PGFREE ,PGACTIVATE ,PGDEACTIVATE ,PGFAULT ,PGMAJFAULT ,PGLAZYFREED , -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/linux/vmstat.h +17 -0
@@ -184,6 +184,23 @@ static inline unsigned long zone_page_state_snapshot(struct zone *zone,return x; } +static inline unsigned long node_page_state_snapshot (pg_data_t *pgdat, +enum zone_stat_item item) +{ +long x =atomic_long_read (&pgdat->vm_stat[item]); + +#ifdef CONFIG_SMP +int cpu; +for_each_online_cpu (cpu) + x +=per_cpu_ptr (pgdat->per_cpu_nodestats, cpu)->vm_node_stat_diff[item]; + +if (x <0 ) + x =0 ; +#endif +return x; +} + +#ifdef CONFIG_NUMA extern unsigned long sum_zone_node_page_state (int node,enum zone_stat_item item);
include/trace/events/vmscan.h +5 -7
@@ -352,15 +352,14 @@ TRACE_EVENT(mm_vmscan_writepage, TRACE_EVENT(mm_vmscan_lru_shrink_inactive, - TP_PROTO(struct zone *zone, + TP_PROTO(int nid, unsigned long nr_scanned, unsigned long nr_reclaimed, int priority, int file), - TP_ARGS(zone, nr_scanned, nr_reclaimed, priority, file), + TP_ARGS(nid, nr_scanned, nr_reclaimed, priority, file), TP_STRUCT__entry( __field(int, nid) - __field(int, zid) __field(unsigned long, nr_scanned) __field(unsigned long, nr_reclaimed) __field(int, priority)
@@ -368,16 +367,15 @@ TRACE_EVENT(mm_vmscan_lru_shrink_inactive, ), TP_fast_assign( - __entry->nid = zone_to_nid(zone); - __entry->zid =zone_idx (zone); + __entry->nid = nid; __entry->nr_scanned = nr_scanned; __entry->nr_reclaimed = nr_reclaimed; __entry->priority = priority; __entry->reclaim_flags =trace_shrink_flags (file); ), -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 +8 -7
@@ -982,24 +982,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;
@@ -1008,12 +1008,13 @@ 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_wb_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 */ ret = timeout - (jiffies - start);if (ret <0 )
mm/compaction.c +9 -9
@@ -647,8 +647,8 @@ 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 */
@@ -656,12 +656,12 @@ static bool too_many_isolated(struct zone *zone) {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 (zone->zone_pgdat,NR_INACTIVE_FILE ) + +node_page_state (zone->zone_pgdat,NR_INACTIVE_ANON ); + active =node_page_state (zone->zone_pgdat,NR_ACTIVE_FILE ) + +node_page_state (zone->zone_pgdat,NR_ACTIVE_ANON ); + isolated =node_page_state (zone->zone_pgdat,NR_ISOLATED_FILE ) + +node_page_state (zone->zone_pgdat,NR_ISOLATED_ANON );return isolated > (inactive + active) /2 ; }
@@ -859,7 +859,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
@@ -2028,7 +2028,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); }
@@ -2124,7 +2124,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);
@@ -3306,7 +3306,7 @@ static void __split_huge_page(struct page *page, struct list_head *list)/* prevent PageLRU to go away from under us, and freeze lru stats */ spin_lock_irq (zone_lru_lock (zone)); - lruvec =mem_cgroup_page_lruvec (head, zone); + lruvec =mem_cgroup_page_lruvec (head, zone->zone_pgdat);/* complete memcg works before add pages to LRU */ mem_cgroup_split_huge_fixup (head);
mm/internal.h +1 -1
@@ -80,7 +80,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 +12 -11
@@ -959,7 +959,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; }
@@ -971,8 +971,8 @@ struct lruvec *mem_cgroup_zone_lruvec(struct zone *zone,* 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; }
@@ -985,14 +985,14 @@ struct lruvec *mem_cgroup_zone_lruvec(struct zone *zone,* 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; }
@@ -1012,8 +1012,8 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct zone *zone)* 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; }
@@ -1021,6 +1021,7 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct zone *zone)* mem_cgroup_update_lru_size - account for adding or removing an lru page * @lruvec: mem_cgroup per zone lru vector * @lru: index of lru list the page is sitting on +* @zid: Zone ID of the zone pages have been added to * @nr_pages: positive when adding or negative when removing * * This function must be called under lru_lock, just before a page is added
@@ -1028,14 +1029,14 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct zone *zone)* so as to allow it to check that lru_size 0 is consistent with list_empty). */ void mem_cgroup_update_lru_size (struct lruvec *lruvec,enum lru_list lru, -int nr_pages) +enum zone_type zid,int nr_pages) {struct mem_cgroup_per_zone *mz;unsigned long *lru_size;long size;bool empty; -__update_lru_size (lruvec, lru, nr_pages); +__update_lru_size (lruvec, lru, zid, nr_pages);if (mem_cgroup_disabled ())return ;
@@ -2111,7 +2112,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 ;
@@ -2126,7 +2127,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
@@ -1663,7 +1663,7 @@ static int __soft_offline_page(struct page *page, int flags)put_hwpoison_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,
@@ -1671,7 +1671,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
@@ -1586,7 +1586,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
@@ -962,7 +962,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
@@ -168,7 +168,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));/* * We isolated non-lru movable page so here we can use
@@ -1117,7 +1117,7 @@ static ICE_noinline int unmap_and_move(new_page_t get_new_page,* 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)); }
@@ -1458,7 +1458,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:
@@ -1724,15 +1724,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) +
@@ -1826,7 +1827,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_pgdat (page),NR_ISOLATED_ANON + page_lru,hpage_nr_pages (page));/*
@@ -1884,7 +1885,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); }
@@ -1977,7 +1978,7 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,/* 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_pgdat (page),NR_ISOLATED_ANON + page_lru, -HPAGE_PMD_NR ); goto out_unlock;
@@ -2029,7 +2030,7 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,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_pgdat (page),NR_ISOLATED_ANON + page_lru, -HPAGE_PMD_NR );return isolated;
mm/mlock.c +1 -1
@@ -103,7 +103,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_pgdat (page));if (getpage)get_page (page);ClearPageLRU (page);
mm/page-writeback.c +4 -4
@@ -285,8 +285,8 @@ static unsigned long zone_dirtyable_memory(struct zone *zone)*/ nr_pages -=min (nr_pages, zone->totalreserve_pages); - 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; }
@@ -348,8 +348,8 @@ static unsigned long global_dirtyable_memory(void)*/ x -=min (x, totalreserve_pages); - 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 +38 -32
138 lines not on this page · raw message
mm/swap.c +28 -28
129 lines not on this page · raw message
mm/vmscan.c +131 -95
580 lines not on this page · raw message
mm/vmstat.c +25 -22
104 lines not on this page · raw message
mm/workingset.c +2 -2
@@ -353,8 +353,8 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker, pages =mem_cgroup_node_nr_lru_pages (sc->memcg, sc->nid,LRU_ALL_FILE ); }else { - pages =sum_zone_node_page_state (sc->nid,NR_ACTIVE_FILE ) + -sum_zone_node_page_state (sc->nid,NR_INACTIVE_FILE ); + pages =node_page_state (NODE_DATA (sc->nid),NR_ACTIVE_FILE ) + +node_page_state (NODE_DATA (sc->nid),NR_INACTIVE_FILE ); }/*
Signature · 7 lines
2.6.4 -- 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>
Re: [PATCH 03/27] mm, vmscan: Move LRU lists to node
Quoted 10 lines · Mel Gorman
This moves the LRU lists from the zone to the node and related data such as counters, tracing, congestion tracking and writeback tracking. Unfortunately, due to reclaim and compaction retry logic, it is necessary to account for the number of LRU pages on both zone and node logic. Most reclaim logic is based on the node counters but the retry logic uses the zone counters which do not distinguish inactive and inactive sizes. It would be possible to leave the LRU counters on a per-zone basis but it's a heavier calculation across multiple cache lines that is much more frequent than the retry checks.
Quoted 8 lines
Other than the LRU counters, 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.
Signed-off-by Mel Gorman <[email protected]>Acked-by Johannes Weiner <[email protected]>
--
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/27 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 pages from higher zones. 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 increasingly rare. Historically it would have been a major problem on 32-bit with big Highmem:Lowmem ratios but such configurations are also now rare and even where they exist, they are not encouraged. If it really becomes a problem, it'll manifest as very low reclaim efficiencies.
--- mm/vmscan.c | 78 +++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 25 deletions(-)
mm/vmscan.c +53 -25
@@ -84,6 +84,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? */
@@ -1386,6 +1389,7 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,unsigned long nr_taken =0 ;unsigned long nr_zone_taken[MAX_NR_ZONES ] = {0 };unsigned long scan, nr_pages; +LIST_HEAD (pages_skipped);for (scan =0 ; scan < nr_to_scan && nr_taken < nr_to_scan && !list_empty (src); scan++) {
@@ -1396,6 +1400,11 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,VM_BUG_ON_PAGE (!PageLRU (page), page); +if (page_zonenum (page) > sc->reclaim_idx) { +list_move (&page->lru, &pages_skipped); +continue ; + } +switch (__isolate_lru_page (page, mode)) {case 0 : nr_pages =hpage_nr_pages (page);
@@ -1414,6 +1423,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));
@@ -1583,7 +1601,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
@@ -2395,12 +2413,13 @@ 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 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;
@@ -2432,7 +2451,7 @@ static bool shrink_zone(struct zone *zone, struct scan_control *sc,shrink_zone_memcg (zone, memcg, sc, &lru_pages); zone_lru_pages += lru_pages; -if (memcg && is_classzone) +if (!global_reclaim (sc) && sc->reclaim_idx == classzone_idx)shrink_slab (sc->gfp_mask,zone_to_nid (zone), memcg, sc->nr_scanned - scanned, lru_pages);
@@ -2463,7 +2482,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) && sc->reclaim_idx == classzone_idx)shrink_slab (sc->gfp_mask,zone_to_nid (zone),NULL , sc->nr_scanned - nr_scanned, zone_lru_pages);
@@ -2540,14 +2559,14 @@ static inline bool compaction_ready(struct zone *zone, int order, int classzone_* If a zone is deemed to be full of pinned pages then just give it a light * scan then give up on it. */ -static void shrink_zones (struct zonelist *zonelist,struct scan_control *sc) +static void shrink_zones (struct zonelist *zonelist,struct scan_control *sc, +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);/* * If the number of buffer_heads in the machine exceeds the maximum
@@ -2560,15 +2579,20 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)for_each_zone_zonelist_nodemask (zone, z, zonelist,gfp_zone (sc->gfp_mask), sc->nodemask) { -enum zone_type classzone_idx; -if (!populated_zone (zone))continue ; - classzone_idx = requested_highidx; +/* +* Note that reclaim_idx does not change as it is the highest +* zone reclaimed from which for empty zones is a no-op but +* classzone_idx is used by shrink_node to test if the slabs +* should be shrunk on a given node. +*/ while (!populated_zone (zone->zone_pgdat->node_zones + - classzone_idx)) + classzone_idx)) { classzone_idx--; +continue ; + }/* * Take care memory controller reclaiming has small influence
@@ -2594,8 +2618,8 @@ static void 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 && -compaction_ready (zone, sc->order, requested_highidx)) { +zonelist_zone_idx (z) <= classzone_idx && +compaction_ready (zone, sc->order, classzone_idx)) { sc->compaction_ready = true;continue ; }
@@ -2615,7 +2639,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)/* need some check for avoid more shrink_zone() */ } -shrink_zone (zone, sc,zone_idx (zone) == classzone_idx); +shrink_node (zone->zone_pgdat, sc, classzone_idx); }/*
@@ -2647,6 +2671,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,int initial_priority = sc->priority;unsigned long total_scanned =0 ;unsigned long writeback_threshold; +enum zone_type classzone_idx = sc->reclaim_idx; retry:delayacct_freepages_start ();
@@ -2657,7 +2682,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,vmpressure_prio (sc->gfp_mask, sc->target_mem_cgroup, sc->priority); sc->nr_scanned =0 ; -shrink_zones (zonelist, sc); +shrink_zones (zonelist, sc, classzone_idx); total_scanned += sc->nr_scanned;if (sc->nr_reclaimed >= sc->nr_to_reclaim)
@@ -2841,6 +2866,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,struct scan_control sc = { .nr_to_reclaim =SWAP_CLUSTER_MAX , .gfp_mask = (gfp_mask =memalloc_noio_flags (gfp_mask)), + .reclaim_idx =gfp_zone (gfp_mask), .order = order, .nodemask = nodemask, .priority =DEF_PRIORITY ,
@@ -3112,7 +3138,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, classzone_idx);/* TODO: ANOMALY */ clear_bit (PGDAT_WRITEBACK , &pgdat->flags);
@@ -3161,6 +3187,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)unsigned long nr_soft_scanned;struct scan_control sc = { .gfp_mask =GFP_KERNEL , + .reclaim_idx =MAX_NR_ZONES -1 , .order = order, .priority =DEF_PRIORITY , .may_writepage = !laptop_mode,
@@ -3231,15 +3258,14 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx) 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 >=0 ; i--) {struct zone *zone = pgdat->node_zones + i;if (!populated_zone (zone))
@@ -3250,6 +3276,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)continue ; sc.nr_scanned =0 ; + sc.reclaim_idx = i; nr_soft_scanned =0 ;/*
@@ -3698,6 +3725,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) .may_writepage = !!(zone_reclaim_mode & RECLAIM_WRITE), .may_unmap = !!(zone_reclaim_mode & RECLAIM_UNMAP), .may_swap = 1, + .reclaim_idx = zone_idx(zone), };cond_resched ();
@@ -3717,7 +3745,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)); }while (sc.nr_reclaimed < nr_pages && --sc.priority >=0 ); }
Signature · 7 lines
2.6.4 -- 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>
Re: [PATCH 04/27] mm, vmscan: Begin reclaiming pages on a per-node basis
Quoted 11 lines · Mel Gorman
This patch makes reclaim decisions on a per-node basis. A reclaimer knows what zone is required by the allocation request and skips pages from higher zones. In many cases this will be ok because it's a
GFP_HIGHMEMrequest of some description. On 64-bit,ZONE_DMA32requests will cause some problems but 32-bit devices on 64-bit platforms are increasingly rare. Historically it would have been a major problem on 32-bit with big Highmem:Lowmem ratios but such configurations are also now rare and even where they exist, they are not encouraged. If it really becomes a problem, it'll manifest as very low reclaim efficiencies.Signed-off-by Mel Gorman <[email protected]>
[...]
Quoted 18 lines
mm/vmscan.c +2
-2@@ -2540,14 +2559,14 @@ static inline bool compaction_ready(struct zone *zone, int order, int classzone_* If a zone is deemed to be full of pinned pages then just give it a light * scan then give up on it. */ -static void shrink_zones (struct zonelist *zonelist,struct scan_control *sc) +static void shrink_zones (struct zonelist *zonelist,struct scan_control *sc, +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);/* * If the number of buffer_heads in the machine exceeds the maximum
mm/vmscan.c static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc) · line 2581
Quoted 3 lines
mm/vmscan.c +0
-0@@ -2560,15 +2579,20 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)for_each_zone_zonelist_nodemask (zone, z, zonelist,gfp_zone (sc->gfp_mask), sc->nodemask) {
Using sc->reclaim_idx could be faster/nicer here than gfp_zone()?
Although after "mm, vmscan: Update classzone_idx if buffer_heads_over_limit" there would need to be a variable for the highmem adjusted value - maybe reuse "requested_highidx"? Not important though.
Quoted 42 lines
mm/vmscan.c +12
-7-enum zone_type classzone_idx; -if (!populated_zone (zone))continue ; - classzone_idx = requested_highidx; +/* +* Note that reclaim_idx does not change as it is the highest +* zone reclaimed from which for empty zones is a no-op but +* classzone_idx is used by shrink_node to test if the slabs +* should be shrunk on a given node. +*/ while (!populated_zone (zone->zone_pgdat->node_zones + - classzone_idx)) + classzone_idx)) { classzone_idx--; +continue ; + }/* * Take care memory controller reclaiming has small influence @@ -2594,8 +2618,8 @@ static void 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 && -compaction_ready (zone, sc->order, requested_highidx)) { +zonelist_zone_idx (z) <= classzone_idx && +compaction_ready (zone, sc->order, classzone_idx)) { sc->compaction_ready = true;continue ; }@@ -2615,7 +2639,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)/* need some check for avoid more shrink_zone() */ } -shrink_zone (zone, sc,zone_idx (zone) == classzone_idx); +shrink_node (zone->zone_pgdat, sc, classzone_idx); }/*
mm/vmscan.c static unsigned long do_try_to_free_pages(struct zonelist *zonelist, · line 2674
Quoted 4 lines
mm/vmscan.c +1
-0@@ -2647,6 +2671,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,int initial_priority = sc->priority;unsigned long total_scanned =0 ;unsigned long writeback_threshold; +enum zone_type classzone_idx = sc->reclaim_idx;
Hmm, try_to_free_mem_cgroup_pages() seems to call this with sc->reclaim_idx not explicitly inirialized (e.g. 0). And shrink_all_memory() as well. I probably didn't check them in v6 and pointed out only try_to_free_pages() (which is now OK), sorry.
mm/vmscan.c static unsigned long do_try_to_free_pages(struct zonelist *zonelist, · line 2685
Quoted 9 lines
mm/vmscan.c +1
-1retry:delayacct_freepages_start ();@@ -2657,7 +2682,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,vmpressure_prio (sc->gfp_mask, sc->target_mem_cgroup, sc->priority); sc->nr_scanned =0 ; -shrink_zones (zonelist, sc); +shrink_zones (zonelist, sc, classzone_idx);
Looks like classzone_idx here is only used here to pass to shrink_zones() unchanged, which means it can just use it directly without a new param?
--
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>
Re: [PATCH 04/27] mm, vmscan: Begin reclaiming pages on a per-node basis
Quoted 47 lines · Vlastimil Babka
Quoted 11 lines · Mel Gorman
This patch makes reclaim decisions on a per-node basis. A reclaimer knows what zone is required by the allocation request and skips pages from higher zones. In many cases this will be ok because it's a
GFP_HIGHMEMrequest of some description. On 64-bit,ZONE_DMA32requests will cause some problems but 32-bit devices on 64-bit platforms are increasingly rare. Historically it would have been a major problem on 32-bit with big Highmem:Lowmem ratios but such configurations are also now rare and even where they exist, they are not encouraged. If it really becomes a problem, it'll manifest as very low reclaim efficiencies.Signed-off-by Mel Gorman <[email protected]>[...]
Quoted 18 lines
mm/vmscan.c +2
-2@@ -2540,14 +2559,14 @@ static inline bool compaction_ready(struct zone *zone, int order, int classzone_* If a zone is deemed to be full of pinned pages then just give it a light * scan then give up on it. */ -static void shrink_zones (struct zonelist *zonelist,struct scan_control *sc) +static void shrink_zones (struct zonelist *zonelist,struct scan_control *sc, +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);/* * If the number of buffer_heads in the machine exceeds the maximum mm/vmscan.c static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc) · line 2581
Quoted 3 lines
mm/vmscan.c +0
-0@@ -2560,15 +2579,20 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)for_each_zone_zonelist_nodemask (zone, z, zonelist,gfp_zone (sc->gfp_mask), sc->nodemask) {Using
sc->reclaim_idxcould be faster/nicer here thangfp_zone()? Although after "mm, vmscan: Updateclasszone_idxifbuffer_heads_over_limit" there would need to be a variable for the highmem adjusted value - maybe reuse "requested_highidx"? Not important though.Quoted 5 lines
mm/vmscan.c +0
-2-enum zone_type classzone_idx; -if (!populated_zone (zone))continue ;
Quoted 12 lines
mm/vmscan.c static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc) · line 2594
Quoted 12 lines
mm/vmscan.c +8
-2- classzone_idx = requested_highidx; +/* +* Note that reclaim_idx does not change as it is the highest +* zone reclaimed from which for empty zones is a no-op but +* classzone_idx is used by shrink_node to test if the slabs +* should be shrunk on a given node. +*/ while (!populated_zone (zone->zone_pgdat->node_zones + - classzone_idx)) + classzone_idx)) { classzone_idx--; +continue ;
Oh and Michal's comment on Patch 20 made me realize that my objection to v6 about possible underflow of sc->reclaim_idx and classzone_idx seems to still apply here for classzone_idx? Updated example: Normal zone allocation. A small node 0 without Normal zone will get us classzone_idx == dma32. Node 1 next in zonelist won't have dma/dma32 zones so we won't see node_zones + classzone_idx populated, and the while loop will lead to underflow of classzone_idx. I may be missing something, but I don't really see another way around it than resetting classzone_idx to sc->reclaim_idx before the while loop.
--
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>
Re: [PATCH 04/27] mm, vmscan: Begin reclaiming pages on a per-node basis
Quoted 5 lines · Vlastimil Babka
Quoted 5 lines
Quoted 5 lines
mm/vmscan.c +0
-2-enum zone_type classzone_idx; -if (!populated_zone(zone)) continue;
Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
mm/vmscan.c +3
-1- classzone_idx = requested_highidx; +/* +* Note that reclaim_idx does not change as it is the highest +* zone reclaimed from which for empty zones is a no-op but Quoted 8 lines
Review
Quoted 8 lines
mm/vmscan.c +3
-0+* classzone_idx is used by shrink_node to test if the slabs +* should be shrunk on a given node. +*/ while (!populated_zone(zone->zone_pgdat->node_zones +mm/vmscan.c +1
-1- classzone_idx)) + classzone_idx)) {classzone_idx--;(quoted diff) +1
-0+ continue;Oh and Michal's comment on Patch 20 made me realize that my objection to v6 about possible underflow of
sc->reclaim_idxandclasszone_idxseems to still apply here forclasszone_idx?
Potentially. The relevant code now looks like this
classzone_idx = sc->reclaim_idx;
while (!populated_zone(zone->zone_pgdat->node_zones +
classzone_idx))
classzone_idx--;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>
Michal Hocko
maintainerRe: [PATCH 04/27] mm, vmscan: Begin reclaiming pages on a per-node basis
Quoted 23 lines · Mel Gorman
Quoted 5 lines · Vlastimil Babka
Quoted 5 lines
Quoted 5 lines
mm/vmscan.c +0
-2-enum zone_type classzone_idx; -if (!populated_zone(zone)) continue;Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
mm/vmscan.c +3
-1- classzone_idx = requested_highidx; +/* +* Note that reclaim_idx does not change as it is the highest +* zone reclaimed from which for empty zones is a no-op but Quoted 8 lines
Review
Quoted 8 lines
mm/vmscan.c +3
-0+* classzone_idx is used by shrink_node to test if the slabs +* should be shrunk on a given node. +*/ while (!populated_zone(zone->zone_pgdat->node_zones +mm/vmscan.c +1
-1- classzone_idx)) + classzone_idx)) {classzone_idx--;(quoted diff) +1
-0+ continue;Oh and Michal's comment on Patch 20 made me realize that my objection to v6 about possible underflow of
sc->reclaim_idxandclasszone_idxseems to still apply here forclasszone_idx?
Quoted 6 lines
Potentially. The relevant code now looks like this
classzone_idx = sc->reclaim_idx; while (!populated_zone(zone->zone_pgdat->node_zones + classzone_idx)) classzone_idx--;
Yes that makes much more sense to me.
Signature · 8 lines
Michal Hocko 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>
Re: [PATCH 04/27] mm, vmscan: Begin reclaiming pages on a per-node basis
In reply to Vlastimil BabkaQuoted 11 lines · Vlastimil Babka
Quoted 11 lines
mm/vmscan.c +2
-1-static void shrink_zones (struct zonelist *zonelist,struct scan_control *sc) +static void shrink_zones (struct zonelist *zonelist,struct scan_control *sc, +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;mm/vmscan.c +0
-1-enum zone_type requested_highidx =gfp_zone (sc->gfp_mask);
Quoted 8 lines
mm/vmscan.c static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc) · line 2581
Quoted 6 lines
/* * If the number of buffer_heads in the machine exceeds the maximummm/vmscan.c +0
-0@@ -2560,15 +2579,20 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)for_each_zone_zonelist_nodemask (zone, z, zonelist,gfp_zone (sc->gfp_mask), sc->nodemask) {Using
sc->reclaim_idxcould be faster/nicer here thangfp_zone()?
Yes, then the reclaim_idx and classzone_idx needs to be updated if buffer_heads_over_limit in the check above but that is better anyway.
Quoted 4 lines
Although after "mm, vmscan: Update
classzone_idxifbuffer_heads_over_limit" there would need to be a variable for the highmem adjusted value - maybe reuse "requested_highidx"? Not important though.
I think it's ok in the buffer_heads_over_limit case to reclaim from more zones than requested. It may require another pass through do_try_to_free_pages if a low zone was not reclaimed and required by the caller but that's ok and expected if there are too many buffer_heads.
Quoted 40 lines
Quoted 40 lines
mm/vmscan.c +12
-7-enum zone_type classzone_idx; -if (!populated_zone (zone))continue ; - classzone_idx = requested_highidx; +/* +* Note that reclaim_idx does not change as it is the highest +* zone reclaimed from which for empty zones is a no-op but +* classzone_idx is used by shrink_node to test if the slabs +* should be shrunk on a given node. +*/ while (!populated_zone (zone->zone_pgdat->node_zones + - classzone_idx)) + classzone_idx)) { classzone_idx--; +continue ; + }/* * Take care memory controller reclaiming has small influence @@ -2594,8 +2618,8 @@ static void 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 && -compaction_ready (zone, sc->order, requested_highidx)) { +zonelist_zone_idx (z) <= classzone_idx && +compaction_ready (zone, sc->order, classzone_idx)) { sc->compaction_ready = true;continue ; }@@ -2615,7 +2639,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)/* need some check for avoid more shrink_zone() */ } -shrink_zone (zone, sc,zone_idx (zone) == classzone_idx); +shrink_node (zone->zone_pgdat, sc, classzone_idx); }
Quoted 12 lines
mm/vmscan.c static unsigned long do_try_to_free_pages(struct zonelist *zonelist, · line 2674
Quoted 6 lines
mm/vmscan.c +1
-0/* @@ -2647,6 +2671,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,int initial_priority = sc->priority;unsigned long total_scanned =0 ;unsigned long writeback_threshold; +enum zone_type classzone_idx = sc->reclaim_idx;Hmm,
try_to_free_mem_cgroup_pages()seems to call this withsc->reclaim_idxnot explicitly inirialized (e.g. 0). Andshrink_all_memory()as well. I probably didn't check them in v6 and pointed out onlytry_to_free_pages()(which is now OK), sorry.
That gets fixed in "mm, memcg: move memcg limit enforcement from zones to nodes" but I can move the hunk to this patch to make bisection a little easier.
Quoted 13 lines
mm/vmscan.c static unsigned long do_try_to_free_pages(struct zonelist *zonelist, · line 2685
Quoted 9 lines
retry:
delayacct_freepages_start();mm/vmscan.c +1
-1@@ -2657,7 +2682,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,vmpressure_prio (sc->gfp_mask, sc->target_mem_cgroup, sc->priority); sc->nr_scanned =0 ; -shrink_zones (zonelist, sc); +shrink_zones (zonelist, sc, classzone_idx);Looks like
classzone_idxhere is only used here to pass toshrink_zones()unchanged, which means it can just use it directly without a new param?
Yes
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>
PATCH 5/27 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
@@ -3201,11 +3201,8 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx) 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.6.4 -- 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/27 mm, vmscan: Make kswapd reclaim in terms of nodes
In reply to Mel GormanPatch "mm: vmscan: Begin reclaiming pages on a per-node basis" started thinking of reclaim in terms of nodes but kswapd is still 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 with multiple zones will have similar aging and reclaiming characteristics as every other node.
--- mm/vmscan.c | 292 +++++++++++++++++++++--------------------------------------- 1 file changed, 101 insertions(+), 191 deletions(-)
mm/vmscan.c +101 -191
@@ -2972,7 +2972,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;
@@ -2991,85 +2992,15 @@ static void age_active_anon(struct zone *zone, struct scan_control *sc) }while (memcg); } -static bool zone_balanced (struct zone *zone,int order,bool highorder, +static bool zone_balanced (struct zone *zone,int order,unsigned long balance_gap,int classzone_idx) {unsigned long mark =high_wmark_pages (zone) + balance_gap; -/* -* When checking from pgdat_balanced(), kswapd should stop and sleep -* when it reaches the high order-0 watermark and let kcompactd take -* over. Other callers such as wakeup_kswapd() want to determine the -* true high-order watermark. -*/ -if (IS_ENABLED (CONFIG_COMPACTION ) && !highorder) { - mark += (1UL << order); - order =0 ; - } -return zone_watermark_ok_safe (zone, order, mark, classzone_idx); }/* -* 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, false,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. *
@@ -3078,6 +3009,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;
@@ -3098,101 +3031,90 @@ 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 (!populated_zone (zone)) +continue ; + +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, +static bool kswapd_shrink_node (pg_data_t *pgdat,int classzone_idx,struct scan_control *sc) { -unsigned long balance_gap; -bool lowmem_pressure; -struct pglist_data *pgdat = zone->zone_pgdat; +struct zone *zone; +int z; -/* Reclaim above the high watermark. */ - sc->nr_to_reclaim =max (SWAP_CLUSTER_MAX ,high_wmark_pages (zone)); +/* Reclaim a number of pages proportional to the number of zones */ + sc->nr_to_reclaim =0 ; +for (z =0 ; z <= classzone_idx; z++) { + zone = pgdat->node_zones + z; +if (!populated_zone (zone)) +continue ; -/* -* 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->nr_to_reclaim +=max (high_wmark_pages (zone),SWAP_CLUSTER_MAX ); + }/* -* 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, sc->order, false, - balance_gap, classzone_idx)) -return true; - -shrink_node (zone->zone_pgdat, sc, classzone_idx); - -/* TODO: ANOMALY */ -clear_bit (PGDAT_WRITEBACK , &pgdat->flags); +shrink_node (pgdat, sc, classzone_idx);/* -* 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, sc->order, false,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; }/* -* For kswapd, balance_pgdat() will work across all this node's zones until -* they are all at high_wmark_pages(zone). -* -* Returns the highest zone idx kswapd was reclaiming at +* For kswapd, balance_pgdat() will reclaim pages across a node from zones +* that are eligible for use by the caller until at least one zone is +* balanced. * -* There is special handling here for zones which are full of pinned pages. -* This can happen if the pages are all mlocked, or if they are all used by -* device drivers (say, ZONE_DMA). Or if they are all in use by hugetlb. -* What we do is to detect the case where all pages in the zone have been -* scanned twice and there has been zero successful reclaim. Mark the zone as -* dead and from now on, only perform a short scan. Basically we're polling -* the zone for when the problem goes away. +* Returns the order kswapd finished reclaiming at. * * kswapd scans the zones in the highmem->normal->dma direction. It skips * zones which have free_pages > high_wmark_pages(zone), but once a zone is -* found to have free_pages <= high_wmark_pages(zone), we scan that zone and the -* lower zones regardless of the number of free pages in the lower zones. This -* interoperates with the page allocator fallback scheme to ensure that aging -* of pages is balanced across the zones. +* found to have free_pages <= high_wmark_pages(zone), any page is that zone +* or lower is eligible for reclaim until at least one usable zone is +* balanced. */ static int balance_pgdat (pg_data_t *pgdat,int order,int classzone_idx) {int i; -int end_zone =0 ;/* Inclusive. 0 = ZONE_DMA */ unsigned long nr_soft_reclaimed;unsigned long nr_soft_scanned; +struct zone *zone;struct scan_control sc = { .gfp_mask =GFP_KERNEL , - .reclaim_idx =MAX_NR_ZONES -1 , .order = order, .priority =DEF_PRIORITY , .may_writepage = !laptop_mode, .may_unmap =1 , .may_swap =1 , + .reclaim_idx = classzone_idx, };count_vm_event (PAGEOUTRUN );
@@ -3203,21 +3125,10 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)/* 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
@@ -3225,19 +3136,17 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)* it to relieve lowmem pressure. */ if (buffer_heads_over_limit &&is_highmem_idx (i)) { - end_zone = i; + classzone_idx = i;break ; } -if (!zone_balanced (zone, order, false,0 ,0 )) { - end_zone = i; +if (!zone_balanced (zone, order,0 ,0 )) { + classzone_idx = i;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);
@@ -3248,51 +3157,34 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx) goto out;/* +* Do some background aging of the anon list, to give +* pages a chance to be referenced before reclaiming. All +* pages are rotated regardless of classzone as this is +* about consistent aging. +*/ +age_active_anon (pgdat, &pgdat->node_zones[MAX_NR_ZONES -1 ], &sc); + +/* * If we're getting trouble reclaiming, start doing writepage * even in laptop mode. */ -if (sc.priority <DEF_PRIORITY -2 ) +if (sc.priority <DEF_PRIORITY -2 || !pgdat_reclaimable (pgdat)) 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, sc.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 >=0 ; 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 ; - sc.reclaim_idx = i; - - 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)) - raise_priority = false; - } +if (kswapd_shrink_node (pgdat, classzone_idx, &sc)) + raise_priority = false;/* * If the low watermark is met there is no need for processes
@@ -3308,20 +3200,37 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)break ;/* +* 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 (!populated_zone (zone)) +continue ; + +if (zone_balanced (zone, sc.order,0 , classzone_idx)) { +clear_bit (PGDAT_CONGESTED , &pgdat->flags); +clear_bit (PGDAT_DIRTY , &pgdat->flags); + goto out; + } + } + +/* * 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:/* -* Return the highest zone idx we were reclaiming at so -* prepare_kswapd_sleep() makes the same decisions as here. +* Return the order kswapd stopped reclaiming at as +* prepare_kswapd_sleep() takes it into account. If another caller +* entered the allocator slow path while kswapd was awake, order will +* remain at the higher level. */ -return end_zone; +return sc.order; } static void kswapd_try_to_sleep(pg_data_t *pgdat, int order,
@@ -3478,8 +3387,9 @@ static int kswapd(void *p)*/ if (!ret) {trace_mm_vmscan_kswapd_wake (pgdat->node_id, order); - balanced_classzone_idx =balance_pgdat (pgdat, order, - classzone_idx); + +/* return value ignored until next patch */ +balance_pgdat (pgdat, order, classzone_idx); } }
@@ -3509,7 +3419,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, true,0 ,0 )) +if (zone_balanced (zone, order,0 ,0 ))return ;trace_mm_vmscan_wakeup_kswapd (pgdat->node_id,zone_idx (zone), order);
Signature · 7 lines
2.6.4 -- 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/27 mm, vmscan: Remove balance gap
In reply to Mel GormanThe balance gap was introduced to apply equal pressure to all zones when reclaiming for a higher zone. With node-based LRU, the need for the balance gap is removed and the code is dead so remove it.
--- include/linux/swap.h | 9 --------- mm/vmscan.c | 19 ++++++++----------- 2 files changed, 8 insertions(+), 20 deletions(-)
include/linux/swap.h +0 -9
@@ -157,15 +157,6 @@ enum {#define SWAP_CLUSTER_MAX 32UL#define COMPACT_CLUSTER_MAX SWAP_CLUSTER_MAX -/* -* Ratio between zone->managed_pages and the "gap" that above the per-zone -* "high_wmark". While balancing nodes, We allow kswapd to shrink zones that -* do not meet the (high_wmark + gap) watermark, even which already met the -* high_wmark, in order to provide better per-zone lru behavior. We are ok to -* spend not more than 1% of the memory for this zone balancing "gap". -*/ -#define KSWAPD_ZONE_BALANCE_GAP_RATIO 100 -#define SWAP_MAP_MAX 0x3e/* Max duplication count, in first swap_map */ #define SWAP_MAP_BAD 0x3f/* Note pageblock is bad, in first swap_map */ #define SWAP_HAS_CACHE 0x40/* Flag page is cached, in first swap_map */
mm/vmscan.c +8 -11
@@ -2512,7 +2512,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc,*/ static inline bool compaction_ready (struct zone *zone,int order,int classzone_idx) { -unsigned long balance_gap, watermark; +unsigned long watermark;bool watermark_ok;/*
@@ -2521,9 +2521,7 @@ static inline bool compaction_ready(struct zone *zone, int order, int classzone_* there is a buffer of free pages available to give compaction * a reasonable chance of completing and allocating the page */ - balance_gap =min (low_wmark_pages (zone),DIV_ROUND_UP ( - zone->managed_pages,KSWAPD_ZONE_BALANCE_GAP_RATIO )); - watermark =high_wmark_pages (zone) + balance_gap + (2UL << order); + watermark =high_wmark_pages (zone) + (2UL << order); watermark_ok =zone_watermark_ok_safe (zone,0 , watermark, classzone_idx);/*
@@ -2992,10 +2990,9 @@ static void age_active_anon(struct pglist_data *pgdat, }while (memcg); } -static bool zone_balanced (struct zone *zone,int order, -unsigned long balance_gap,int classzone_idx) +static bool zone_balanced (struct zone *zone,int order,int classzone_idx) { -unsigned long mark =high_wmark_pages (zone) + balance_gap; +unsigned long mark =high_wmark_pages (zone);return zone_watermark_ok_safe (zone, order, mark, classzone_idx); }
@@ -3037,7 +3034,7 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, long remaining,if (!populated_zone (zone))continue ; -if (zone_balanced (zone, order,0 , classzone_idx)) +if (zone_balanced (zone, order, classzone_idx))return true; }
@@ -3140,7 +3137,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)break ; } -if (!zone_balanced (zone, order,0 ,0 )) { +if (!zone_balanced (zone, order,0 )) { classzone_idx = i;break ; }else {
@@ -3208,7 +3205,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)if (!populated_zone (zone))continue ; -if (zone_balanced (zone, sc.order,0 , classzone_idx)) { +if (zone_balanced (zone, sc.order, classzone_idx)) {clear_bit (PGDAT_CONGESTED , &pgdat->flags);clear_bit (PGDAT_DIRTY , &pgdat->flags); goto out;
@@ -3419,7 +3416,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 ))return ;trace_mm_vmscan_wakeup_kswapd (pgdat->node_id,zone_idx (zone), order);
Signature · 7 lines
2.6.4 -- 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/27 mm, vmscan: Simplify the logic deciding whether kswapd sleeps
In reply to Mel Gormankswapd goes through some complex steps trying to figure out if it should stay awake based on the classzone_idx and the requested order. It is unnecessarily complex and passes in an invalid classzone_idx to balance_pgdat(). What matters most of all is whether a larger order has been requsted and whether kswapd successfully reclaimed at the previous order. This patch irons out the logic to check just that and the end result is less headache inducing.
--- include/linux/mmzone.h | 5 ++- mm/memory_hotplug.c | 5 ++- mm/page_alloc.c | 2 +- mm/vmscan.c | 102 ++++++++++++++++++++++++++----------------------- 4 files changed, 62 insertions(+), 52 deletions(-)
include/linux/mmzone.h +3 -2
@@ -665,8 +665,9 @@ typedef struct pglist_data {wait_queue_head_t pfmemalloc_wait;struct task_struct *kswapd;/* Protected by mem_hotplug_begin/end() */ -int kswapd_max_order; -enum zone_type classzone_idx; +int kswapd_order; +enum zone_type kswapd_classzone_idx; +#ifdef CONFIG_COMPACTION int kcompactd_max_order;enum zone_type kcompactd_classzone_idx;
mm/memory_hotplug.c +3 -2
@@ -1209,9 +1209,10 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)arch_refresh_nodedata (nid, pgdat); }else { -/* Reset the nr_zones and classzone_idx to 0 before reuse */ +/* Reset the nr_zones, order and classzone_idx before reuse */ pgdat->nr_zones =0 ; - pgdat->classzone_idx =0 ; + pgdat->kswapd_order =0 ; + pgdat->kswapd_classzone_idx =0 ; }/* we can use NODE_DATA(nid) from here */
mm/page_alloc.c +1 -1
@@ -6027,7 +6027,7 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size,unsigned long end_pfn =0 ;/* pg_data_t should be reset to zero when it's allocated */ -WARN_ON (pgdat->nr_zones || pgdat->classzone_idx); +WARN_ON (pgdat->nr_zones || pgdat->kswapd_classzone_idx);reset_deferred_meminit (pgdat); pgdat->node_id = nid;
mm/vmscan.c +55 -47
167 lines not on this page · raw message
Signature · 7 lines
2.6.4 -- 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>
Re: [PATCH 08/27] mm, vmscan: Simplify the logic deciding whether kswapd sleeps
Quoted 10 lines · Mel Gorman
kswapd goes through some complex steps trying to figure out if it should stay awake based on the
classzone_idxand the requested order. It is unnecessarily complex and passes in an invalidclasszone_idxtobalance_pgdat(). What matters most of all is whether a larger order has been requsted and whether kswapd successfully reclaimed at the previous order. This patch irons out the logic to check just that and the end result is less headache inducing.Signed-off-by Mel Gorman <[email protected]>Acked-by Johannes Weiner <[email protected]>
I'm just not entirely convinced that the direct full sleep bypass is worth the added complexity. I can even imagine it being counter productive in some situations. But it's not a big issue.
--
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/27 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 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
mm/vmscan.c +11 -9
@@ -2546,14 +2546,6 @@ static inline bool compaction_ready(struct zone *zone, int order, int classzone_* 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. */
@@ -2565,6 +2557,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc,unsigned long nr_soft_reclaimed;unsigned long nr_soft_scanned;gfp_t orig_mask; +pg_data_t *last_pgdat =NULL ;/* * If the number of buffer_heads in the machine exceeds the maximum
@@ -2589,10 +2582,19 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc,while (!populated_zone (zone->zone_pgdat->node_zones + classzone_idx)) { classzone_idx--; -continue ; }/* +* 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; + +/* * Take care memory controller reclaiming has small influence * to global LRU. */
Signature · 7 lines
2.6.4 -- 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/27 mm, vmscan: Remove duplicate logic clearing node congestion and dirty state
In reply to Mel GormanReclaim may stall if there is too much dirty or congested data on a node. This was previously based on zone flags and the logic for clearing the flags is in two places. As congestion/dirty tracking is now tracked on a per-node basis, we can remove some duplicate logic.
--- mm/vmscan.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
mm/vmscan.c +12 -12
@@ -2996,7 +2996,17 @@ static bool zone_balanced(struct zone *zone, int order, int classzone_idx) {unsigned long mark =high_wmark_pages (zone); -return zone_watermark_ok_safe (zone, order, mark, classzone_idx); +if (!zone_watermark_ok_safe (zone, order, mark, classzone_idx)) +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); + +return true; }/*
@@ -3142,13 +3152,6 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)if (!zone_balanced (zone, order,0 )) { classzone_idx = 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); } }
@@ -3207,11 +3210,8 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)if (!populated_zone (zone))continue ; -if (zone_balanced (zone, sc.order, classzone_idx)) { -clear_bit (PGDAT_CONGESTED , &pgdat->flags); -clear_bit (PGDAT_DIRTY , &pgdat->flags); +if (zone_balanced (zone, sc.order, classzone_idx)) goto out; - } }/*
Signature · 7 lines
2.6.4 -- 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/27 mm: vmscan: Do not reclaim from kswapd if there is any eligible zone
In reply to Mel Gormankswapd scans from highest to lowest for a zone that requires balancing. This was necessary when reclaim was per-zone to fairly age pages on lower zones. Now that we are reclaiming on a per-node basis, any eligible zone can be used and pages will still be aged fairly. This patch avoids reclaiming excessively unless buffer_heads are over the limit and it's necessary to reclaim from a higher zone than requested by the waker of kswapd to relieve low memory pressure.
--- mm/vmscan.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)
mm/vmscan.c +19 -13
@@ -3132,24 +3132,30 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx) sc.nr_reclaimed =0 ; -/* Scan from the highest requested zone to dma */ +/* +* If the number of buffer_heads in the machine exceeds the +* maximum allowed level and this node has a highmem zone, +* force kswapd to reclaim from it to relieve lowmem pressure. +*/ +if (buffer_heads_over_limit) { +for (i =MAX_NR_ZONES -1 ; i >=0 ; i--) { + zone = pgdat->node_zones + i; +if (!populated_zone (zone)) +continue ; + +if (is_highmem_idx (i)) + classzone_idx = i; +break ; + } + } + +/* Only reclaim if there are no eligible zones */ for (i = classzone_idx; i >=0 ; i--) { zone = pgdat->node_zones + i;if (!populated_zone (zone))continue ; -/* -* If the number of buffer_heads in the machine -* exceeds the maximum allowed level and this node -* has a highmem zone, force kswapd to reclaim from -* it to relieve lowmem pressure. -*/ -if (buffer_heads_over_limit &&is_highmem_idx (i)) { - classzone_idx = i; -break ; - } - -if (!zone_balanced (zone, order,0 )) { +if (!zone_balanced (zone, sc.order, classzone_idx)) { classzone_idx = i;break ; }
Signature · 7 lines
2.6.4 -- 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/27 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 | 58 ++++++++++++++++++++++++++-------------------- mm/workingset.c | 6 ++--- 7 files changed, 54 insertions(+), 44 deletions(-)
include/linux/memcontrol.h +5 -4
@@ -306,7 +306,8 @@ void mem_cgroup_uncharge_list(struct list_head *page_list);void mem_cgroup_migrate (struct page *oldpage,struct page *newpage); -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 task_in_mem_cgroup (struct task_struct *task,struct mem_cgroup *memcg);
@@ -573,10 +574,10 @@ static inline void mem_cgroup_migrate(struct page *old, struct page *new) { } -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
@@ -737,9 +737,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
@@ -316,7 +316,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
@@ -944,22 +944,23 @@ static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg) iter = mem_cgroup_iter(NULL, iter, NULL))/** -* 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; }
@@ -1474,8 +1475,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
@@ -5897,6 +5897,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat)#endif pgdat_page_ext_init (pgdat);spin_lock_init (&pgdat->lru_lock); +lruvec_init (node_lruvec (pgdat));for (j =0 ; j <MAX_NR_ZONES ; j++) {struct zone *zone = pgdat->node_zones + j;
@@ -5959,7 +5960,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 +33 -25
157 lines not on this page · raw message
mm/workingset.c +3 -3
@@ -218,7 +218,7 @@ void *workingset_eviction(struct address_space *mapping, struct page *page)VM_BUG_ON_PAGE (page_count (page), page);VM_BUG_ON_PAGE (!PageLocked (page), page); - lruvec =mem_cgroup_zone_lruvec (zone, memcg); + lruvec =mem_cgroup_lruvec (zone->zone_pgdat, zone, memcg); eviction =atomic_long_inc_return (&lruvec->inactive_age);return pack_shadow (memcgid, zone, eviction); }
@@ -267,7 +267,7 @@ bool workingset_refault(void *shadow)rcu_read_unlock ();return false; } - lruvec =mem_cgroup_zone_lruvec (zone, memcg); + lruvec =mem_cgroup_lruvec (zone->zone_pgdat, zone, memcg); refault =atomic_long_read (&lruvec->inactive_age); active_file =lruvec_lru_size (lruvec,LRU_ACTIVE_FILE );rcu_read_unlock ();
@@ -317,7 +317,7 @@ void workingset_activation(struct page *page)*/ if (!mem_cgroup_disabled () && !page_memcg (page)) goto out; - lruvec =mem_cgroup_zone_lruvec (page_zone (page),page_memcg (page)); + lruvec =mem_cgroup_lruvec (page_pgdat (page),page_zone (page),page_memcg (page));atomic_long_inc (&lruvec->inactive_age); out:unlock_page_memcg (page);
Signature · 7 lines
2.6.4 -- 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>
Re: [PATCH 12/27] mm, vmscan: Make shrink_node decisions more node-centric
Quoted 8 lines · Mel Gorman
Earlier 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.Signed-off-by Mel Gorman <[email protected]>
Quoted 344 lines
--- 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 | 58 ++++++++++++++++++++++++++-------------------- mm/workingset.c | 6 ++--- 7 files changed, 54 insertions(+), 44 deletions(-)include/linux/memcontrol.h +5
-4@@ -306,7 +306,8 @@ void mem_cgroup_uncharge_list(struct list_head *page_list);void mem_cgroup_migrate (struct page *oldpage,struct page *newpage); -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 task_in_mem_cgroup (struct task_struct *task,struct mem_cgroup *memcg);@@ -573,10 +574,10 @@ static inline void mem_cgroup_migrate(struct page *old, struct page *new) { } -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@@ -737,9 +737,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@@ -316,7 +316,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@@ -944,22 +944,23 @@ static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg) iter = mem_cgroup_iter(NULL, iter, NULL))/** -* 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; }@@ -1474,8 +1475,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@@ -5897,6 +5897,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat)#endif pgdat_page_ext_init (pgdat);spin_lock_init (&pgdat->lru_lock); +lruvec_init (node_lruvec (pgdat));for (j =0 ; j <MAX_NR_ZONES ; j++) {struct zone *zone = pgdat->node_zones + j;@@ -5959,7 +5960,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 +33
-25@@ -2220,10 +2220,11 @@ static inline void init_tlb_ubc(void)/* * This is a basic per-zone page freer. Used by both kswapd and direct reclaim. */ -static void shrink_zone_memcg (struct zone *zone,struct mem_cgroup *memcg, +static void shrink_node_memcg (struct pglist_data *pgdat,struct mem_cgroup *memcg,struct scan_control *sc,unsigned long *lru_pages) { -struct lruvec *lruvec =mem_cgroup_zone_lruvec (zone, memcg); +struct zone *zone = &pgdat->node_zones[sc->reclaim_idx]; +struct lruvec *lruvec =mem_cgroup_lruvec (pgdat, zone, memcg);unsigned long nr[NR_LRU_LISTS ];unsigned long targets[NR_LRU_LISTS ];unsigned long nr_to_scan;@@ -2356,13 +2357,14 @@ static bool in_reclaim_compaction(struct scan_control *sc)* calls try_to_compact_zone() that it will have enough free pages to succeed. * It will give up earlier than that if there is difficulty reclaiming pages. */ -static inline bool should_continue_reclaim (struct zone *zone, +static inline bool should_continue_reclaim (struct pglist_data *pgdat,unsigned long nr_reclaimed,unsigned long nr_scanned,struct scan_control *sc) {unsigned long pages_for_compaction;unsigned long inactive_lru_pages; +int z;/* If not in reclaim/compaction mode, stop */ if (!in_reclaim_compaction (sc))@@ -2396,21 +2398,27 @@ static inline bool should_continue_reclaim(struct zone *zone,* inactive lists are large enough, continue reclaiming */ pages_for_compaction = (2UL << sc->order); - inactive_lru_pages =node_page_state (zone->zone_pgdat,NR_INACTIVE_FILE ); + inactive_lru_pages =node_page_state (pgdat,NR_INACTIVE_FILE );if (get_nr_swap_pages () >0 ) - inactive_lru_pages +=node_page_state (zone->zone_pgdat,NR_INACTIVE_ANON ); + inactive_lru_pages +=node_page_state (pgdat,NR_INACTIVE_ANON );if (sc->nr_reclaimed < pages_for_compaction && inactive_lru_pages > pages_for_compaction)return true;/* If compaction would go ahead or the allocation would succeed, stop */ -switch (compaction_suitable (zone, sc->order,0 ,0 )) { -case COMPACT_PARTIAL : -case COMPACT_CONTINUE : -return false; -default : -return true; +for (z =0 ; z <= sc->reclaim_idx; z++) { +struct zone *zone = &pgdat->node_zones[z]; + +switch (compaction_suitable (zone, sc->order,0 , sc->reclaim_idx)) { +case COMPACT_PARTIAL : +case COMPACT_CONTINUE : +return false; +default : +/* check next zone */ + ; + } } +return true; } static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc,@@ -2419,15 +2427,14 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc,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; struct mem_cgroup_reclaim_cookie reclaim = { - .zone = zone, + .zone = &pgdat->node_zones[classzone_idx], .priority = sc->priority, }; - unsigned long zone_lru_pages = 0; + unsigned long node_lru_pages = 0; struct mem_cgroup *memcg; nr_reclaimed = sc->nr_reclaimed;@@ -2448,11 +2455,11 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc, reclaimed = sc->nr_reclaimed; scanned = sc->nr_scanned; -shrink_zone_memcg (zone, memcg, sc, &lru_pages); - zone_lru_pages += lru_pages; +shrink_node_memcg (pgdat, memcg, sc, &lru_pages); + node_lru_pages += lru_pages;if (!global_reclaim (sc) && sc->reclaim_idx == classzone_idx) -shrink_slab (sc->gfp_mask,zone_to_nid (zone), +shrink_slab (sc->gfp_mask, pgdat->node_id, memcg, sc->nr_scanned - scanned, lru_pages);@@ -2464,7 +2471,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc,/* * Direct reclaim and kswapd have to scan all memory * cgroups to fulfill the overall scan target for the -* zone. +* node. * * Limit reclaim, on the other hand, only cares about * nr_to_reclaim pages to be reclaimed and it will @@ -2483,9 +2490,9 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc,* the eligible LRU pages were scanned. */ if (global_reclaim (sc) && sc->reclaim_idx == classzone_idx) -shrink_slab (sc->gfp_mask,zone_to_nid (zone),NULL , +shrink_slab (sc->gfp_mask, pgdat->node_id,NULL , sc->nr_scanned - nr_scanned, - zone_lru_pages); + node_lru_pages);if (reclaim_state) { sc->nr_reclaimed += reclaim_state->reclaimed_slab;@@ -2500,7 +2507,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc,if (sc->nr_reclaimed - nr_reclaimed) reclaimable = true; - }while (should_continue_reclaim (zone, sc->nr_reclaimed - nr_reclaimed, + }while (should_continue_reclaim (pgdat, sc->nr_reclaimed - nr_reclaimed, sc->nr_scanned - nr_scanned, sc));return reclaimable;@@ -2896,7 +2903,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,#ifdef CONFIG_MEMCG -unsigned long mem_cgroup_shrink_node_zone (struct mem_cgroup *memcg, +unsigned long mem_cgroup_shrink_node (struct mem_cgroup *memcg,gfp_t gfp_mask,bool noswap,struct zone *zone,unsigned long *nr_scanned)@@ -2906,6 +2913,7 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *memcg, .target_mem_cgroup = memcg, .may_writepage = !laptop_mode, .may_unmap = 1, + .reclaim_idx = zone_idx(zone), .may_swap = !noswap, };unsigned long lru_pages;@@ -2920,11 +2928,11 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *memcg,/* * NOTE: Although we can get the priority field, using it * here is not a good idea, since it limits the pages we can scan. -* if we don't reclaim here, the shrink_zone from balance_pgdat +* if we don't reclaim here, the shrink_node from balance_pgdat * will pick up pages from other mem cgroup's as well. We hack * the priority and make it zero. */ -shrink_zone_memcg (zone, memcg, &sc, &lru_pages); +shrink_node_memcg (zone->zone_pgdat, memcg, &sc, &lru_pages);trace_mm_vmscan_memcg_softlimit_reclaim_end (sc.nr_reclaimed);@@ -2982,7 +2990,7 @@ static void age_active_anon(struct pglist_data *pgdat, memcg =mem_cgroup_iter (NULL ,NULL ,NULL ); do { - struct lruvec *lruvec = mem_cgroup_zone_lruvec(zone, memcg); + struct lruvec *lruvec = mem_cgroup_lruvec(pgdat, zone, memcg); if (inactive_list_is_low(lruvec, false)) shrink_active_list(SWAP_CLUSTER_MAX, lruvec,mm/workingset.c +3
-3@@ -218,7 +218,7 @@ void *workingset_eviction(struct address_space *mapping, struct page *page)VM_BUG_ON_PAGE (page_count (page), page);VM_BUG_ON_PAGE (!PageLocked (page), page); - lruvec =mem_cgroup_zone_lruvec (zone, memcg); + lruvec =mem_cgroup_lruvec (zone->zone_pgdat, zone, memcg); eviction =atomic_long_inc_return (&lruvec->inactive_age);return pack_shadow (memcgid, zone, eviction); }@@ -267,7 +267,7 @@ bool workingset_refault(void *shadow)rcu_read_unlock ();return false; } - lruvec =mem_cgroup_zone_lruvec (zone, memcg); + lruvec =mem_cgroup_lruvec (zone->zone_pgdat, zone, memcg); refault =atomic_long_read (&lruvec->inactive_age); active_file =lruvec_lru_size (lruvec,LRU_ACTIVE_FILE );rcu_read_unlock ();@@ -317,7 +317,7 @@ void workingset_activation(struct page *page)*/ if (!mem_cgroup_disabled () && !page_memcg (page)) goto out; - lruvec =mem_cgroup_zone_lruvec (page_zone (page),page_memcg (page)); + lruvec =mem_cgroup_lruvec (page_pgdat (page),page_zone (page),page_memcg (page));atomic_long_inc (&lruvec->inactive_age); out:unlock_page_memcg (page);Signature · 7 lines
2.6.4 -- 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>
Signature · 8 lines
Michal Hocko 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>
Re: [PATCH 12/27] mm, vmscan: Make shrink_node decisions more node-centric
In reply to Mel GormanQuoted 8 lines · Mel Gorman
Earlier 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.Signed-off-by Mel Gorman <[email protected]>
--
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/27 mm, memcg: Move memcg limit enforcement from zones to nodes
In reply to Mel GormanMemcg was broken by the move of all LRUs to nodes because it is tracking limits on a per-zone basis while receiving reclaim requests on a per-node basis. This patch moves limit enforcement to the nodes. Technically, all the variable names should also change but people are already familiar by the meaning of "mz" even if "mn" would be a more appropriate name now.
--- include/linux/memcontrol.h | 21 ++--- include/linux/swap.h | 2 +- mm/memcontrol.c | 210 ++++++++++++++++++++------------------------- mm/vmscan.c | 22 ++--- mm/workingset.c | 6 +- 5 files changed, 114 insertions(+), 147 deletions(-)
include/linux/memcontrol.h +8 -13
@@ -60,7 +60,7 @@ enum mem_cgroup_stat_index { };struct mem_cgroup_reclaim_cookie { -struct zone *zone; +pg_data_t *pgdat;int priority;unsigned int generation; };
@@ -113,7 +113,7 @@ struct mem_cgroup_reclaim_iter {/* * per-zone information in memory controller. */ -struct mem_cgroup_per_zone { +struct mem_cgroup_per_node {struct lruvec lruvec;unsigned long lru_size[NR_LRU_LISTS ];
@@ -127,10 +127,6 @@ struct mem_cgroup_per_zone {/* use container_of */ }; -struct mem_cgroup_per_node { -struct mem_cgroup_per_zone zoneinfo[MAX_NR_ZONES ]; -}; -struct mem_cgroup_threshold {struct eventfd_ctx *eventfd;unsigned long threshold;
@@ -306,8 +302,7 @@ void mem_cgroup_uncharge_list(struct list_head *page_list);void mem_cgroup_migrate (struct page *oldpage,struct page *newpage); -struct lruvec *mem_cgroup_lruvec (struct pglist_data *,struct zone *zone, -struct mem_cgroup *); +struct lruvec *mem_cgroup_lruvec (struct pglist_data *,struct mem_cgroup *);struct lruvec *mem_cgroup_page_lruvec (struct page *,struct pglist_data *);bool task_in_mem_cgroup (struct task_struct *task,struct mem_cgroup *memcg);
@@ -410,9 +405,9 @@ unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,static inline unsigned long mem_cgroup_get_lru_size (struct lruvec *lruvec,enum lru_list lru) { -struct mem_cgroup_per_zone *mz; +struct mem_cgroup_per_node *mz; - mz = container_of(lruvec, struct mem_cgroup_per_zone, lruvec); + mz = container_of(lruvec, struct mem_cgroup_per_node, lruvec);return mz->lru_size[lru]; }
@@ -483,7 +478,7 @@ static inline void mem_cgroup_dec_page_stat(struct page *page,mem_cgroup_update_page_stat (page, idx,-1 ); } -unsigned long mem_cgroup_soft_limit_reclaim (struct zone *zone,int order, +unsigned long mem_cgroup_soft_limit_reclaim (pg_data_t *pgdat,int order,gfp_t gfp_mask,unsigned long *total_scanned);
@@ -575,7 +570,7 @@ static inline void mem_cgroup_migrate(struct page *old, struct page *new) }static inline struct lruvec *mem_cgroup_lruvec (struct pglist_data *pgdat, -struct zone *zone,struct mem_cgroup *memcg) +struct mem_cgroup *memcg) {return node_lruvec (pgdat); }
@@ -687,7 +682,7 @@ static inline void mem_cgroup_dec_page_stat(struct page *page, }static inline -unsigned long mem_cgroup_soft_limit_reclaim (struct zone *zone,int order, +unsigned long mem_cgroup_soft_limit_reclaim (pg_data_t *pgdat,int order,gfp_t gfp_mask,unsigned long *total_scanned) {
include/linux/swap.h +1 -1
@@ -318,7 +318,7 @@ extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, bool may_swap);extern unsigned long mem_cgroup_shrink_node (struct mem_cgroup *mem,gfp_t gfp_mask,bool noswap, -struct zone *zone, +pg_data_t *pgdat,unsigned long *nr_scanned);extern unsigned long shrink_all_memory (unsigned long nr_pages);extern int vm_swappiness;
mm/memcontrol.c +91 -119
475 lines not on this page · raw message
mm/vmscan.c +11 -11
@@ -2223,8 +2223,7 @@ static inline void init_tlb_ubc(void)static void shrink_node_memcg (struct pglist_data *pgdat,struct mem_cgroup *memcg,struct scan_control *sc,unsigned long *lru_pages) { -struct zone *zone = &pgdat->node_zones[sc->reclaim_idx]; -struct lruvec *lruvec =mem_cgroup_lruvec (pgdat, zone, memcg); +struct lruvec *lruvec =mem_cgroup_lruvec (pgdat, memcg);unsigned long nr[NR_LRU_LISTS ];unsigned long targets[NR_LRU_LISTS ];unsigned long nr_to_scan;
@@ -2431,7 +2430,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc, do { struct mem_cgroup *root = sc->target_mem_cgroup; struct mem_cgroup_reclaim_cookie reclaim = { - .zone = &pgdat->node_zones[classzone_idx], + .pgdat = pgdat, .priority = sc->priority, }; unsigned long node_lru_pages = 0;
@@ -2638,7 +2637,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc,* and balancing, not for a memcg's limit. */ nr_soft_scanned =0 ; - nr_soft_reclaimed =mem_cgroup_soft_limit_reclaim (zone, + nr_soft_reclaimed =mem_cgroup_soft_limit_reclaim (zone->zone_pgdat, sc->order, sc->gfp_mask, &nr_soft_scanned); sc->nr_reclaimed += nr_soft_reclaimed;
@@ -2905,7 +2904,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,unsigned long mem_cgroup_shrink_node (struct mem_cgroup *memcg,gfp_t gfp_mask,bool noswap, -struct zone *zone, +pg_data_t *pgdat,unsigned long *nr_scanned) {struct scan_control sc = {
@@ -2913,7 +2912,7 @@ unsigned long mem_cgroup_shrink_node(struct mem_cgroup *memcg, .target_mem_cgroup = memcg, .may_writepage = !laptop_mode, .may_unmap = 1, - .reclaim_idx = zone_idx(zone), + .reclaim_idx = MAX_NR_ZONES - 1, .may_swap = !noswap, };unsigned long lru_pages;
@@ -2932,7 +2931,7 @@ unsigned long mem_cgroup_shrink_node(struct mem_cgroup *memcg,* will pick up pages from other mem cgroup's as well. We hack * the priority and make it zero. */ -shrink_node_memcg (zone->zone_pgdat, memcg, &sc, &lru_pages); +shrink_node_memcg (pgdat, memcg, &sc, &lru_pages);trace_mm_vmscan_memcg_softlimit_reclaim_end (sc.nr_reclaimed);
@@ -2952,6 +2951,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, .nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX), .gfp_mask = (gfp_mask &GFP_RECLAIM_MASK ) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK), + .reclaim_idx = MAX_NR_ZONES - 1, .target_mem_cgroup = memcg, .priority = DEF_PRIORITY, .may_writepage = !laptop_mode,
@@ -2981,7 +2981,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,#endif static void age_active_anon (struct pglist_data *pgdat, -struct zone *zone,struct scan_control *sc) +struct scan_control *sc) {struct mem_cgroup *memcg;
@@ -2990,7 +2990,7 @@ static void age_active_anon(struct pglist_data *pgdat, memcg =mem_cgroup_iter (NULL ,NULL ,NULL ); do { - struct lruvec *lruvec = mem_cgroup_lruvec(pgdat, zone, memcg); + struct lruvec *lruvec = mem_cgroup_lruvec(pgdat, memcg); if (inactive_list_is_low(lruvec, false)) shrink_active_list(SWAP_CLUSTER_MAX, lruvec,
@@ -3178,7 +3178,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)* pages are rotated regardless of classzone as this is * about consistent aging. */ -age_active_anon (pgdat, &pgdat->node_zones[MAX_NR_ZONES -1 ], &sc); +age_active_anon (pgdat, &sc);/* * If we're getting trouble reclaiming, start doing writepage
@@ -3190,7 +3190,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)/* 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, sc.order, + nr_soft_reclaimed =mem_cgroup_soft_limit_reclaim (pgdat, sc.order, sc.gfp_mask, &nr_soft_scanned); sc.nr_reclaimed += nr_soft_reclaimed;
mm/workingset.c +3 -3
@@ -218,7 +218,7 @@ void *workingset_eviction(struct address_space *mapping, struct page *page)VM_BUG_ON_PAGE (page_count (page), page);VM_BUG_ON_PAGE (!PageLocked (page), page); - lruvec =mem_cgroup_lruvec (zone->zone_pgdat, zone, memcg); + lruvec =mem_cgroup_lruvec (zone->zone_pgdat, memcg); eviction =atomic_long_inc_return (&lruvec->inactive_age);return pack_shadow (memcgid, zone, eviction); }
@@ -267,7 +267,7 @@ bool workingset_refault(void *shadow)rcu_read_unlock ();return false; } - lruvec =mem_cgroup_lruvec (zone->zone_pgdat, zone, memcg); + lruvec =mem_cgroup_lruvec (zone->zone_pgdat, memcg); refault =atomic_long_read (&lruvec->inactive_age); active_file =lruvec_lru_size (lruvec,LRU_ACTIVE_FILE );rcu_read_unlock ();
@@ -317,7 +317,7 @@ void workingset_activation(struct page *page)*/ if (!mem_cgroup_disabled () && !page_memcg (page)) goto out; - lruvec =mem_cgroup_lruvec (page_pgdat (page),page_zone (page),page_memcg (page)); + lruvec =mem_cgroup_lruvec (page_pgdat (page),page_memcg (page));atomic_long_inc (&lruvec->inactive_age); out:unlock_page_memcg (page);
Signature · 7 lines
2.6.4 -- 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>
Re: [PATCH 13/27] mm, memcg: Move memcg limit enforcement from zones to nodes
Quoted 3 lines · Mel Gorman
Memcg was broken by the move of all LRUs to nodes because it is tracking limits on a per-zone basis while receiving reclaim requests on a per-node basis.
This might be a bit misleading/confusing. First of all the limit is tracked per memcg not zones/nodes. What you are talking about is tracking soft limit excess and that was really tracked per zone. Then I do not think the zones->nodes LRUs should lead to any noticeable differences. All we care about is to reclaim some memory to get down to the soft limit.
Quoted 3 lines
This patch moves limit enforcement to the nodes. Technically, all the variable names should also change but people are already familiar by the meaning of "mz" even if "mn" would be a more appropriate name now.
I wouldn't bother with those.
Quoted 1 line
Signed-off-by Mel Gorman <[email protected]>
This simplifies the code so it is definitely welcome! I would appreciate a more precise changelog.
Quoted 757 lines
--- include/linux/memcontrol.h | 21 ++--- include/linux/swap.h | 2 +- mm/memcontrol.c | 210 ++++++++++++++++++++------------------------- mm/vmscan.c | 22 ++--- mm/workingset.c | 6 +- 5 files changed, 114 insertions(+), 147 deletions(-)include/linux/memcontrol.h +8
-13@@ -60,7 +60,7 @@ enum mem_cgroup_stat_index { };struct mem_cgroup_reclaim_cookie { -struct zone *zone; +pg_data_t *pgdat;int priority;unsigned int generation; };@@ -113,7 +113,7 @@ struct mem_cgroup_reclaim_iter {/* * per-zone information in memory controller. */ -struct mem_cgroup_per_zone { +struct mem_cgroup_per_node {struct lruvec lruvec;unsigned long lru_size[NR_LRU_LISTS ];@@ -127,10 +127,6 @@ struct mem_cgroup_per_zone {/* use container_of */ }; -struct mem_cgroup_per_node { -struct mem_cgroup_per_zone zoneinfo[MAX_NR_ZONES ]; -}; -struct mem_cgroup_threshold {struct eventfd_ctx *eventfd;unsigned long threshold;@@ -306,8 +302,7 @@ void mem_cgroup_uncharge_list(struct list_head *page_list);void mem_cgroup_migrate (struct page *oldpage,struct page *newpage); -struct lruvec *mem_cgroup_lruvec (struct pglist_data *,struct zone *zone, -struct mem_cgroup *); +struct lruvec *mem_cgroup_lruvec (struct pglist_data *,struct mem_cgroup *);struct lruvec *mem_cgroup_page_lruvec (struct page *,struct pglist_data *);bool task_in_mem_cgroup (struct task_struct *task,struct mem_cgroup *memcg);@@ -410,9 +405,9 @@ unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,static inline unsigned long mem_cgroup_get_lru_size (struct lruvec *lruvec,enum lru_list lru) { -struct mem_cgroup_per_zone *mz; +struct mem_cgroup_per_node *mz; - mz = container_of(lruvec, struct mem_cgroup_per_zone, lruvec); + mz = container_of(lruvec, struct mem_cgroup_per_node, lruvec);return mz->lru_size[lru]; }@@ -483,7 +478,7 @@ static inline void mem_cgroup_dec_page_stat(struct page *page,mem_cgroup_update_page_stat (page, idx,-1 ); } -unsigned long mem_cgroup_soft_limit_reclaim (struct zone *zone,int order, +unsigned long mem_cgroup_soft_limit_reclaim (pg_data_t *pgdat,int order,gfp_t gfp_mask,unsigned long *total_scanned);@@ -575,7 +570,7 @@ static inline void mem_cgroup_migrate(struct page *old, struct page *new) }static inline struct lruvec *mem_cgroup_lruvec (struct pglist_data *pgdat, -struct zone *zone,struct mem_cgroup *memcg) +struct mem_cgroup *memcg) {return node_lruvec (pgdat); }@@ -687,7 +682,7 @@ static inline void mem_cgroup_dec_page_stat(struct page *page, }static inline -unsigned long mem_cgroup_soft_limit_reclaim (struct zone *zone,int order, +unsigned long mem_cgroup_soft_limit_reclaim (pg_data_t *pgdat,int order,gfp_t gfp_mask,unsigned long *total_scanned) {include/linux/swap.h +1
-1@@ -318,7 +318,7 @@ extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, bool may_swap);extern unsigned long mem_cgroup_shrink_node (struct mem_cgroup *mem,gfp_t gfp_mask,bool noswap, -struct zone *zone, +pg_data_t *pgdat,unsigned long *nr_scanned);extern unsigned long shrink_all_memory (unsigned long nr_pages);extern int vm_swappiness;mm/memcontrol.c +91
-119@@ -132,15 +132,11 @@ static const char * const mem_cgroup_lru_names[] = {* their hierarchy representation */ -struct mem_cgroup_tree_per_zone { +struct mem_cgroup_tree_per_node {struct rb_root rb_root;spinlock_t lock; }; -struct mem_cgroup_tree_per_node { -struct mem_cgroup_tree_per_zone rb_tree_per_zone[MAX_NR_ZONES ]; -}; -struct mem_cgroup_tree {struct mem_cgroup_tree_per_node *rb_tree_per_node[MAX_NUMNODES ]; };@@ -323,13 +319,10 @@ EXPORT_SYMBOL(memcg_kmem_enabled_key);#endif /* !CONFIG_SLOB */ -static struct mem_cgroup_per_zone * -mem_cgroup_zone_zoneinfo (struct mem_cgroup *memcg,struct zone *zone) +static struct mem_cgroup_per_node * +mem_cgroup_nodeinfo (struct mem_cgroup *memcg,int nid) { -int nid =zone_to_nid (zone); -int zid =zone_idx (zone); - -return &memcg->nodeinfo[nid]->zoneinfo[zid]; +return memcg->nodeinfo[nid]; }/** @@ -383,37 +376,35 @@ ino_t page_cgroup_ino(struct page *page)return ino; } -static struct mem_cgroup_per_zone * -mem_cgroup_page_zoneinfo (struct mem_cgroup *memcg,struct page *page) +static struct mem_cgroup_per_node * +mem_cgroup_page_nodeinfo (struct mem_cgroup *memcg,struct page *page) {int nid =page_to_nid (page); -int zid =page_zonenum (page); -return &memcg->nodeinfo[nid]->zoneinfo[zid]; +return memcg->nodeinfo[nid]; } -static struct mem_cgroup_tree_per_zone * -soft_limit_tree_node_zone (int nid,int zid) +static struct mem_cgroup_tree_per_node * +soft_limit_tree_node (int nid) { -return &soft_limit_tree.rb_tree_per_node[nid]->rb_tree_per_zone[zid]; +return soft_limit_tree.rb_tree_per_node[nid]; } -static struct mem_cgroup_tree_per_zone * +static struct mem_cgroup_tree_per_node *soft_limit_tree_from_page (struct page *page) {int nid =page_to_nid (page); -int zid =page_zonenum (page); -return &soft_limit_tree.rb_tree_per_node[nid]->rb_tree_per_zone[zid]; +return soft_limit_tree.rb_tree_per_node[nid]; } -static void __mem_cgroup_insert_exceeded (struct mem_cgroup_per_zone *mz, -struct mem_cgroup_tree_per_zone *mctz, +static void __mem_cgroup_insert_exceeded (struct mem_cgroup_per_node *mz, +struct mem_cgroup_tree_per_node *mctz,unsigned long new_usage_in_excess) {struct rb_node **p = &mctz->rb_root.rb_node;struct rb_node *parent =NULL ; -struct mem_cgroup_per_zone *mz_node; +struct mem_cgroup_per_node *mz_node;if (mz->on_tree)return ;@@ -423,7 +414,7 @@ static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_zone *mz,return ;while (*p) { parent = *p; - mz_node = rb_entry(parent, struct mem_cgroup_per_zone, + mz_node = rb_entry(parent, struct mem_cgroup_per_node, tree_node);if (mz->usage_in_excess < mz_node->usage_in_excess) p = &(*p)->rb_left;@@ -439,8 +430,8 @@ static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_zone *mz, mz->on_tree = true; } -static void __mem_cgroup_remove_exceeded (struct mem_cgroup_per_zone *mz, -struct mem_cgroup_tree_per_zone *mctz) +static void __mem_cgroup_remove_exceeded (struct mem_cgroup_per_node *mz, +struct mem_cgroup_tree_per_node *mctz) {if (!mz->on_tree)return ;@@ -448,8 +439,8 @@ static void __mem_cgroup_remove_exceeded(struct mem_cgroup_per_zone *mz, mz->on_tree = false; } -static void mem_cgroup_remove_exceeded (struct mem_cgroup_per_zone *mz, -struct mem_cgroup_tree_per_zone *mctz) +static void mem_cgroup_remove_exceeded (struct mem_cgroup_per_node *mz, +struct mem_cgroup_tree_per_node *mctz) {unsigned long flags;@@ -473,8 +464,8 @@ static unsigned long soft_limit_excess(struct mem_cgroup *memcg)static void mem_cgroup_update_tree (struct mem_cgroup *memcg,struct page *page) {unsigned long excess; -struct mem_cgroup_per_zone *mz; -struct mem_cgroup_tree_per_zone *mctz; +struct mem_cgroup_per_node *mz; +struct mem_cgroup_tree_per_node *mctz; mctz =soft_limit_tree_from_page (page);/* @@ -482,7 +473,7 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page)* because their event counter is not touched. */ for (; memcg; memcg =parent_mem_cgroup (memcg)) { - mz =mem_cgroup_page_zoneinfo (memcg, page); + mz =mem_cgroup_page_nodeinfo (memcg, page); excess =soft_limit_excess (memcg);/* * We have to update the tree if mz is on RB-tree or @@ -507,24 +498,22 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page)static void mem_cgroup_remove_from_trees (struct mem_cgroup *memcg) { -struct mem_cgroup_tree_per_zone *mctz; -struct mem_cgroup_per_zone *mz; -int nid, zid; +struct mem_cgroup_tree_per_node *mctz; +struct mem_cgroup_per_node *mz; +int nid;for_each_node (nid) { -for (zid =0 ; zid <MAX_NR_ZONES ; zid++) { - mz = &memcg->nodeinfo[nid]->zoneinfo[zid]; - mctz =soft_limit_tree_node_zone (nid, zid); -mem_cgroup_remove_exceeded (mz, mctz); - } + mz =mem_cgroup_nodeinfo (memcg, nid); + mctz =soft_limit_tree_node (nid); +mem_cgroup_remove_exceeded (mz, mctz); } } -static struct mem_cgroup_per_zone * -__mem_cgroup_largest_soft_limit_node (struct mem_cgroup_tree_per_zone *mctz) +static struct mem_cgroup_per_node * +__mem_cgroup_largest_soft_limit_node (struct mem_cgroup_tree_per_node *mctz) {struct rb_node *rightmost =NULL ; -struct mem_cgroup_per_zone *mz; +struct mem_cgroup_per_node *mz; retry: mz =NULL ;@@ -532,7 +521,7 @@ __mem_cgroup_largest_soft_limit_node(struct mem_cgroup_tree_per_zone *mctz)if (!rightmost) goto done;/* Nothing to reclaim from */ - mz = rb_entry(rightmost, struct mem_cgroup_per_zone, tree_node); + mz = rb_entry(rightmost, struct mem_cgroup_per_node, tree_node);/* * Remove the node now but someone else can add it back, * we will to add it back at the end of reclaim to its correct @@ -546,10 +535,10 @@ __mem_cgroup_largest_soft_limit_node(struct mem_cgroup_tree_per_zone *mctz)return mz; } -static struct mem_cgroup_per_zone * -mem_cgroup_largest_soft_limit_node (struct mem_cgroup_tree_per_zone *mctz) +static struct mem_cgroup_per_node * +mem_cgroup_largest_soft_limit_node (struct mem_cgroup_tree_per_node *mctz) { -struct mem_cgroup_per_zone *mz; +struct mem_cgroup_per_node *mz;spin_lock_irq (&mctz->lock); mz =__mem_cgroup_largest_soft_limit_node (mctz);@@ -643,20 +632,16 @@ unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg, int nid, unsigned int lru_mask) {unsigned long nr =0 ; -int zid; +struct mem_cgroup_per_node *mz; +enum lru_list lru;VM_BUG_ON ((unsigned )nid >= nr_node_ids); -for (zid =0 ; zid <MAX_NR_ZONES ; zid++) { -struct mem_cgroup_per_zone *mz; -enum lru_list lru; - -for_each_lru (lru) { -if (!(BIT (lru) & lru_mask)) -continue ; - mz = &memcg->nodeinfo[nid]->zoneinfo[zid]; - nr += mz->lru_size[lru]; - } +for_each_lru (lru) { +if (!(BIT (lru) & lru_mask)) +continue ; + mz =mem_cgroup_nodeinfo (memcg, nid); + nr += mz->lru_size[lru]; }return nr; }@@ -809,9 +794,9 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,rcu_read_lock ();if (reclaim) { -struct mem_cgroup_per_zone *mz; +struct mem_cgroup_per_node *mz; - mz =mem_cgroup_zone_zoneinfo (root, reclaim->zone); + mz =mem_cgroup_nodeinfo (root, reclaim->pgdat->node_id); iter = &mz->iter[reclaim->priority];if (prev && reclaim->generation != iter->generation)@@ -910,19 +895,17 @@ static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg) {struct mem_cgroup *memcg = dead_memcg;struct mem_cgroup_reclaim_iter *iter; -struct mem_cgroup_per_zone *mz; -int nid, zid; +struct mem_cgroup_per_node *mz; +int nid;int i;while ((memcg =parent_mem_cgroup (memcg))) {for_each_node (nid) { -for (zid =0 ; zid <MAX_NR_ZONES ; zid++) { - mz = &memcg->nodeinfo[nid]->zoneinfo[zid]; -for (i =0 ; i <=DEF_PRIORITY ; i++) { - iter = &mz->iter[i]; -cmpxchg (&iter->position, - dead_memcg,NULL ); - } + mz =mem_cgroup_nodeinfo (memcg, nid); +for (i =0 ; i <=DEF_PRIORITY ; i++) { + iter = &mz->iter[i]; +cmpxchg (&iter->position, + dead_memcg,NULL ); } } }@@ -946,7 +929,6 @@ static void invalidate_reclaim_iterators(struct mem_cgroup *dead_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 a given @node or a given @@ -954,9 +936,9 @@ static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg)* is disabled. */ struct lruvec *mem_cgroup_lruvec (struct pglist_data *pgdat, -struct zone *zone,struct mem_cgroup *memcg) +struct mem_cgroup *memcg) { -struct mem_cgroup_per_zone *mz; +struct mem_cgroup_per_node *mz;struct lruvec *lruvec;if (mem_cgroup_disabled ()) {@@ -964,7 +946,7 @@ struct lruvec *mem_cgroup_lruvec(struct pglist_data *pgdat, goto out; } - mz =mem_cgroup_zone_zoneinfo (memcg, zone); + mz =mem_cgroup_nodeinfo (memcg, pgdat->node_id); lruvec = &mz->lruvec; out:/* @@ -972,8 +954,8 @@ struct lruvec *mem_cgroup_lruvec(struct pglist_data *pgdat,* we have to be prepared to initialize lruvec->zone here; * and if offlined then reonlined, we need to reinitialize it. */ -if (unlikely (lruvec->pgdat != zone->zone_pgdat)) - lruvec->pgdat = zone->zone_pgdat; +if (unlikely (lruvec->pgdat != pgdat)) + lruvec->pgdat = pgdat;return lruvec; }@@ -988,7 +970,7 @@ struct lruvec *mem_cgroup_lruvec(struct pglist_data *pgdat,*/ struct lruvec *mem_cgroup_page_lruvec (struct page *page,struct pglist_data *pgdat) { -struct mem_cgroup_per_zone *mz; +struct mem_cgroup_per_node *mz;struct mem_cgroup *memcg;struct lruvec *lruvec;@@ -1005,7 +987,7 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct pglist_data *pgdif (!memcg) memcg = root_mem_cgroup; - mz =mem_cgroup_page_zoneinfo (memcg, page); + mz =mem_cgroup_page_nodeinfo (memcg, page); lruvec = &mz->lruvec; out:/* @@ -1032,7 +1014,7 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct pglist_data *pgdvoid mem_cgroup_update_lru_size (struct lruvec *lruvec,enum lru_list lru,enum zone_type zid,int nr_pages) { -struct mem_cgroup_per_zone *mz; +struct mem_cgroup_per_node *mz;unsigned long *lru_size;long size;bool empty;@@ -1042,7 +1024,7 @@ void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru,if (mem_cgroup_disabled ())return ; - mz = container_of(lruvec, struct mem_cgroup_per_zone, lruvec); + mz = container_of(lruvec, struct mem_cgroup_per_node, lruvec); lru_size = mz->lru_size + lru; empty =list_empty (lruvec->lists + lru);@@ -1435,7 +1417,7 @@ int mem_cgroup_select_victim_node(struct mem_cgroup *memcg)#endif static int mem_cgroup_soft_reclaim (struct mem_cgroup *root_memcg, -struct zone *zone, +pg_data_t *pgdat,gfp_t gfp_mask,unsigned long *total_scanned) {@@ -1445,7 +1427,7 @@ static int mem_cgroup_soft_reclaim(struct mem_cgroup *root_memcg,unsigned long excess;unsigned long nr_scanned;struct mem_cgroup_reclaim_cookie reclaim = { - .zone = zone, + .pgdat = pgdat, .priority =0 , };@@ -1476,7 +1458,7 @@ static int mem_cgroup_soft_reclaim(struct mem_cgroup *root_memcg,continue ; } total +=mem_cgroup_shrink_node (victim, gfp_mask, false, - zone, &nr_scanned); + pgdat, &nr_scanned); *total_scanned += nr_scanned;if (!soft_limit_excess (root_memcg))break ;@@ -2603,22 +2585,22 @@ static int mem_cgroup_resize_memsw_limit(struct mem_cgroup *memcg,return ret; } -unsigned long mem_cgroup_soft_limit_reclaim (struct zone *zone,int order, +unsigned long mem_cgroup_soft_limit_reclaim (pg_data_t *pgdat,int order,gfp_t gfp_mask,unsigned long *total_scanned) {unsigned long nr_reclaimed =0 ; -struct mem_cgroup_per_zone *mz, *next_mz =NULL ; +struct mem_cgroup_per_node *mz, *next_mz =NULL ;unsigned long reclaimed;int loop =0 ; -struct mem_cgroup_tree_per_zone *mctz; +struct mem_cgroup_tree_per_node *mctz;unsigned long excess;unsigned long nr_scanned;if (order >0 )return 0 ; - mctz =soft_limit_tree_node_zone (zone_to_nid (zone),zone_idx (zone)); + mctz =soft_limit_tree_node (pgdat->node_id);/* * This loop can run a while, specially if mem_cgroup's continuously * keep exceeding their soft limit and putting the system under @@ -2633,7 +2615,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,break ; nr_scanned =0 ; - reclaimed =mem_cgroup_soft_reclaim (mz->memcg, zone, + reclaimed =mem_cgroup_soft_reclaim (mz->memcg, pgdat, gfp_mask, &nr_scanned); nr_reclaimed += reclaimed; *total_scanned += nr_scanned;@@ -3254,22 +3236,21 @@ static int memcg_stat_show(struct seq_file *m, void *v)#ifdef CONFIG_DEBUG_VM { -int nid, zid; -struct mem_cgroup_per_zone *mz; +pg_data_t *pgdat; +struct mem_cgroup_per_node *mz;struct zone_reclaim_stat *rstat;unsigned long recent_rotated[2 ] = {0 ,0 };unsigned long recent_scanned[2 ] = {0 ,0 }; -for_each_online_node (nid) -for (zid =0 ; zid <MAX_NR_ZONES ; zid++) { - mz = &memcg->nodeinfo[nid]->zoneinfo[zid]; - rstat = &mz->lruvec.reclaim_stat; +for_each_online_pgdat (pgdat) { + mz =mem_cgroup_nodeinfo (memcg, pgdat->node_id); + rstat = &mz->lruvec.reclaim_stat; - recent_rotated[0 ] += rstat->recent_rotated[0 ]; - recent_rotated[1 ] += rstat->recent_rotated[1 ]; - recent_scanned[0 ] += rstat->recent_scanned[0 ]; - recent_scanned[1 ] += rstat->recent_scanned[1 ]; - } + recent_rotated[0 ] += rstat->recent_rotated[0 ]; + recent_rotated[1 ] += rstat->recent_rotated[1 ]; + recent_scanned[0 ] += rstat->recent_scanned[0 ]; + recent_scanned[1 ] += rstat->recent_scanned[1 ]; + }seq_printf (m,"recent_rotated_anon %lu\n" , recent_rotated[0 ]);seq_printf (m,"recent_rotated_file %lu\n" , recent_rotated[1 ]);seq_printf (m,"recent_scanned_anon %lu\n" , recent_scanned[0 ]);@@ -4095,11 +4076,10 @@ static struct cftype mem_cgroup_legacy_files[] = { { }, /* terminate */ }; -static int alloc_mem_cgroup_per_zone_info (struct mem_cgroup *memcg,int node) +static int alloc_mem_cgroup_per_node_info (struct mem_cgroup *memcg,int node) {struct mem_cgroup_per_node *pn; -struct mem_cgroup_per_zone *mz; -int zone, tmp = node; +int tmp = node;/* * This routine is called against possible nodes. * But it's BUG to call kmalloc() against offline node. @@ -4114,18 +4094,16 @@ static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node)if (!pn)return 1 ; -for (zone =0 ; zone <MAX_NR_ZONES ; zone++) { - mz = &pn->zoneinfo[zone]; -lruvec_init (&mz->lruvec); - mz->usage_in_excess =0 ; - mz->on_tree = false; - mz->memcg = memcg; - } +lruvec_init (&pn->lruvec); + pn->usage_in_excess =0 ; + pn->on_tree = false; + pn->memcg = memcg; + memcg->nodeinfo[node] = pn;return 0 ; } -static void free_mem_cgroup_per_zone_info (struct mem_cgroup *memcg,int node) +static void free_mem_cgroup_per_node_info (struct mem_cgroup *memcg,int node) {kfree (memcg->nodeinfo[node]); }@@ -4136,7 +4114,7 @@ static void mem_cgroup_free(struct mem_cgroup *memcg)memcg_wb_domain_exit (memcg);for_each_node (node) -free_mem_cgroup_per_zone_info (memcg, node); +free_mem_cgroup_per_node_info (memcg, node);free_percpu (memcg->stat);kfree (memcg); }@@ -4159,7 +4137,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void) goto fail;for_each_node (node) -if (alloc_mem_cgroup_per_zone_info (memcg, node)) +if (alloc_mem_cgroup_per_node_info (memcg, node)) goto fail;if (memcg_wb_domain_init (memcg,GFP_KERNEL ))@@ -5757,18 +5735,12 @@ static int __init mem_cgroup_init(void)for_each_node (node) {struct mem_cgroup_tree_per_node *rtpn; -int zone; rtpn =kzalloc_node (sizeof (*rtpn),GFP_KERNEL ,node_online (node) ? node :NUMA_NO_NODE ); -for (zone =0 ; zone <MAX_NR_ZONES ; zone++) { -struct mem_cgroup_tree_per_zone *rtpz; - - rtpz = &rtpn->rb_tree_per_zone[zone]; - rtpz->rb_root =RB_ROOT ; -spin_lock_init (&rtpz->lock); - } + rtpn->rb_root =RB_ROOT ; +spin_lock_init (&rtpn->lock); soft_limit_tree.rb_tree_per_node[node] = rtpn; }mm/vmscan.c +11
-11@@ -2223,8 +2223,7 @@ static inline void init_tlb_ubc(void)static void shrink_node_memcg (struct pglist_data *pgdat,struct mem_cgroup *memcg,struct scan_control *sc,unsigned long *lru_pages) { -struct zone *zone = &pgdat->node_zones[sc->reclaim_idx]; -struct lruvec *lruvec =mem_cgroup_lruvec (pgdat, zone, memcg); +struct lruvec *lruvec =mem_cgroup_lruvec (pgdat, memcg);unsigned long nr[NR_LRU_LISTS ];unsigned long targets[NR_LRU_LISTS ];unsigned long nr_to_scan;@@ -2431,7 +2430,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc, do { struct mem_cgroup *root = sc->target_mem_cgroup; struct mem_cgroup_reclaim_cookie reclaim = { - .zone = &pgdat->node_zones[classzone_idx], + .pgdat = pgdat, .priority = sc->priority, }; unsigned long node_lru_pages = 0;@@ -2638,7 +2637,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc,* and balancing, not for a memcg's limit. */ nr_soft_scanned =0 ; - nr_soft_reclaimed =mem_cgroup_soft_limit_reclaim (zone, + nr_soft_reclaimed =mem_cgroup_soft_limit_reclaim (zone->zone_pgdat, sc->order, sc->gfp_mask, &nr_soft_scanned); sc->nr_reclaimed += nr_soft_reclaimed;@@ -2905,7 +2904,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,unsigned long mem_cgroup_shrink_node (struct mem_cgroup *memcg,gfp_t gfp_mask,bool noswap, -struct zone *zone, +pg_data_t *pgdat,unsigned long *nr_scanned) {struct scan_control sc = {@@ -2913,7 +2912,7 @@ unsigned long mem_cgroup_shrink_node(struct mem_cgroup *memcg, .target_mem_cgroup = memcg, .may_writepage = !laptop_mode, .may_unmap = 1, - .reclaim_idx = zone_idx(zone), + .reclaim_idx = MAX_NR_ZONES - 1, .may_swap = !noswap, };unsigned long lru_pages;@@ -2932,7 +2931,7 @@ unsigned long mem_cgroup_shrink_node(struct mem_cgroup *memcg,* will pick up pages from other mem cgroup's as well. We hack * the priority and make it zero. */ -shrink_node_memcg (zone->zone_pgdat, memcg, &sc, &lru_pages); +shrink_node_memcg (pgdat, memcg, &sc, &lru_pages);trace_mm_vmscan_memcg_softlimit_reclaim_end (sc.nr_reclaimed);@@ -2952,6 +2951,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, .nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX), .gfp_mask = (gfp_mask &GFP_RECLAIM_MASK ) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK), + .reclaim_idx = MAX_NR_ZONES - 1, .target_mem_cgroup = memcg, .priority = DEF_PRIORITY, .may_writepage = !laptop_mode,@@ -2981,7 +2981,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,#endif static void age_active_anon (struct pglist_data *pgdat, -struct zone *zone,struct scan_control *sc) +struct scan_control *sc) {struct mem_cgroup *memcg;@@ -2990,7 +2990,7 @@ static void age_active_anon(struct pglist_data *pgdat, memcg =mem_cgroup_iter (NULL ,NULL ,NULL ); do { - struct lruvec *lruvec = mem_cgroup_lruvec(pgdat, zone, memcg); + struct lruvec *lruvec = mem_cgroup_lruvec(pgdat, memcg); if (inactive_list_is_low(lruvec, false)) shrink_active_list(SWAP_CLUSTER_MAX, lruvec,@@ -3178,7 +3178,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)* pages are rotated regardless of classzone as this is * about consistent aging. */ -age_active_anon (pgdat, &pgdat->node_zones[MAX_NR_ZONES -1 ], &sc); +age_active_anon (pgdat, &sc);/* * If we're getting trouble reclaiming, start doing writepage @@ -3190,7 +3190,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)/* 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, sc.order, + nr_soft_reclaimed =mem_cgroup_soft_limit_reclaim (pgdat, sc.order, sc.gfp_mask, &nr_soft_scanned); sc.nr_reclaimed += nr_soft_reclaimed;mm/workingset.c +3
-3@@ -218,7 +218,7 @@ void *workingset_eviction(struct address_space *mapping, struct page *page)VM_BUG_ON_PAGE (page_count (page), page);VM_BUG_ON_PAGE (!PageLocked (page), page); - lruvec =mem_cgroup_lruvec (zone->zone_pgdat, zone, memcg); + lruvec =mem_cgroup_lruvec (zone->zone_pgdat, memcg); eviction =atomic_long_inc_return (&lruvec->inactive_age);return pack_shadow (memcgid, zone, eviction); }@@ -267,7 +267,7 @@ bool workingset_refault(void *shadow)rcu_read_unlock ();return false; } - lruvec =mem_cgroup_lruvec (zone->zone_pgdat, zone, memcg); + lruvec =mem_cgroup_lruvec (zone->zone_pgdat, memcg); refault =atomic_long_read (&lruvec->inactive_age); active_file =lruvec_lru_size (lruvec,LRU_ACTIVE_FILE );rcu_read_unlock ();@@ -317,7 +317,7 @@ void workingset_activation(struct page *page)*/ if (!mem_cgroup_disabled () && !page_memcg (page)) goto out; - lruvec =mem_cgroup_lruvec (page_pgdat (page),page_zone (page),page_memcg (page)); + lruvec =mem_cgroup_lruvec (page_pgdat (page),page_memcg (page));atomic_long_inc (&lruvec->inactive_age); out:unlock_page_memcg (page);Signature · 7 lines
2.6.4 -- 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>
Signature · 8 lines
Michal Hocko 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>
PATCH 14/27 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 +++--- include/linux/vmstat.h | 1 - mm/vmstat.c | 20 +++----------------- mm/workingset.c | 43 ++++++++++++++++++++----------------------- 4 files changed, 26 insertions(+), 44 deletions(-)
include/linux/mmzone.h +3 -3
@@ -145,9 +145,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 };
@@ -162,6 +159,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 };
include/linux/vmstat.h +0 -1
@@ -233,7 +233,6 @@ void mod_node_page_state(struct pglist_data *, enum node_stat_item, long);void inc_node_page_state (struct page *,enum node_stat_item );void dec_node_page_state (struct page *,enum node_stat_item ); -extern void inc_zone_state (struct zone *,enum zone_stat_item );extern void inc_node_state (struct pglist_data *,enum node_stat_item );extern void __inc_zone_state (struct zone *,enum zone_stat_item );extern void __inc_node_state (struct pglist_data *,enum node_stat_item );
mm/vmstat.c +3 -17
@@ -445,11 +445,6 @@ void mod_zone_page_state(struct zone *zone, enum zone_stat_item item, }EXPORT_SYMBOL (mod_zone_page_state); -void inc_zone_state (struct zone *zone,enum zone_stat_item item) -{ -mod_zone_state (zone, item,1 ,1 ); -} -void inc_zone_page_state (struct page *page,enum zone_stat_item item) {mod_zone_state (page_zone (page), item,1 ,1 );
@@ -538,15 +533,6 @@ void mod_zone_page_state(struct zone *zone, enum zone_stat_item item, }EXPORT_SYMBOL (mod_zone_page_state); -void inc_zone_state (struct zone *zone,enum zone_stat_item item) -{ -unsigned long flags; - -local_irq_save (flags); -__inc_zone_state (zone, item); -local_irq_restore (flags); -} -void inc_zone_page_state (struct page *page,enum zone_stat_item item) {unsigned long flags;
@@ -966,9 +952,6 @@ const char * const vmstat_text[] = {"numa_local" ,"numa_other" , #endif -"workingset_refault" , -"workingset_activate" , -"workingset_nodereclaim" ,"nr_anon_transparent_hugepages" , "nr_free_cma",
@@ -981,6 +964,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 +20 -23
135 lines not on this page · raw message
Signature · 7 lines
2.6.4 -- 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/27 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 | 94 ++++++++++++++++++++++++----------------------- mm/page_alloc.c | 26 ++++++------- 4 files changed, 67 insertions(+), 67 deletions(-)
include/linux/mmzone.h +6 -6
@@ -361,12 +361,6 @@ struct zone {struct pglist_data *zone_pgdat;struct per_cpu_pageset __percpu *pageset; -/* -* This is a per-zone reserve of pages that are not available -* to userspace allocations. -*/ -unsigned long totalreserve_pages; -#ifndef CONFIG_SPARSEMEM /* * Flags for a pageblock_nr_pages block. See pageblock-flags.h.
@@ -684,6 +678,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 are not available +* to userspace allocations. +*/ +unsigned long totalreserve_pages; +/* Write-intensive fields used from the page allocator */ ZONE_PADDING (_pad1_) spinlock_t lru_lock;
include/linux/writeback.h +1 -1
@@ -320,7 +320,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);int wb_domain_init (struct wb_domain *dom,gfp_t gfp);#ifdef CONFIG_CGROUP_WRITEBACK void wb_domain_exit (struct wb_domain *dom);
mm/page-writeback.c +49 -45
146 lines not on this page · raw message
mm/page_alloc.c +11 -15
@@ -2917,31 +2917,24 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, }/* * When allocating a page cache page for writing, we -* want to get it from a zone that is within its dirty -* limit, such that no single zone holds more than its +* want to get it from a node that is within its dirty +* limit, such that no single node holds more than its * proportional share of globally allowed dirty pages. -* The dirty limits take into account the zone's +* The dirty limits take into account the node's * lowmem reserves and high watermark so that kswapd * should be able to balance it without having to * write pages from its LRU list. * -* This may look like it could increase pressure on -* lower zones by failing allocations in higher zones -* before they are full. But the pages that do spill -* over are limited as the lower zones are protected -* by this very same mechanism. It should not become -* a practical burden to them. -* * XXX: For now, allow allocations to potentially -* exceed the per-zone dirty limit in the slowpath +* exceed the per-node dirty limit in the slowpath * (spread_dirty_pages unset) before going into reclaim, * which is important when on a NUMA setup the allowed -* zones are together not big enough to reach the +* nodes are together not big enough to reach the * global limit. The proper fix for these situations -* will require awareness of zones in the +* will require awareness of nodes in the * dirty-throttling and the flusher threads. */ -if (ac->spread_dirty_pages && !zone_dirty_ok (zone)) +if (ac->spread_dirty_pages && !node_dirty_ok (zone->zone_pgdat))continue ; mark = zone->watermark[alloc_flags &ALLOC_WMARK_MASK ];
@@ -6692,6 +6685,9 @@ static void calculate_totalreserve_pages(void)enum zone_type i, j;for_each_online_pgdat (pgdat) { + + pgdat->totalreserve_pages =0 ; +for (i =0 ; i <MAX_NR_ZONES ; i++) {struct zone *zone = pgdat->node_zones + i;long max =0 ;
@@ -6708,7 +6704,7 @@ static void calculate_totalreserve_pages(void)if (max > zone->managed_pages) max = zone->managed_pages; - zone->totalreserve_pages = max; + pgdat->totalreserve_pages += max; reserve_pages += max; }
Signature · 7 lines
2.6.4 -- 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>
Re: [PATCH 15/27] mm, page_alloc: Consider dirtyable memory in terms of nodes
Quoted 2 lines · Mel Gorman
Historically dirty pages were spread among zones but now that LRUs are per-node it is more appropriate to consider dirty pages in a node.
I think this should deserve a note that a behavior for 32b highmem systems will change and could lead to early write throttling and observable stalls as a result because highmem_dirtyable_memory will always return totalhigh_pages regardless of how much is free resp. on LRUs so we can overestimate it.
Highmem is usually used for LRU pages but there are other allocations which can use it (e.g. vmalloc). I understand how this is both an inherent problem of 32b with a larger high:low ratio and why it is hard to at least pretend we can cope with it with node based approach but we should at least document it.
I workaround would be to enable highmem_dirtyable_memory which can lead to premature OOM killer for some workloads AFAIR.
Quoted 3 lines
Signed-off-by Mel Gorman <[email protected]>Signed-off-by Johannes Weiner <[email protected]>Acked-by Vlastimil Babka <[email protected]>
The patch looks ok otherwise to me.
Quoted 274 lines
--- include/linux/mmzone.h | 12 +++--- include/linux/writeback.h | 2 +- mm/page-writeback.c | 94 ++++++++++++++++++++++++----------------------- mm/page_alloc.c | 26 ++++++------- 4 files changed, 67 insertions(+), 67 deletions(-)include/linux/mmzone.h +6
-6@@ -361,12 +361,6 @@ struct zone {struct pglist_data *zone_pgdat;struct per_cpu_pageset __percpu *pageset; -/* -* This is a per-zone reserve of pages that are not available -* to userspace allocations. -*/ -unsigned long totalreserve_pages; -#ifndef CONFIG_SPARSEMEM /* * Flags for a pageblock_nr_pages block. See pageblock-flags.h. @@ -684,6 +678,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 are not available +* to userspace allocations. +*/ +unsigned long totalreserve_pages; +/* Write-intensive fields used from the page allocator */ ZONE_PADDING (_pad1_) spinlock_t lru_lock;include/linux/writeback.h +1
-1@@ -320,7 +320,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);int wb_domain_init (struct wb_domain *dom,gfp_t gfp);#ifdef CONFIG_CGROUP_WRITEBACK void wb_domain_exit (struct wb_domain *dom);mm/page-writeback.c +49
-45@@ -267,26 +267,35 @@ static void wb_min_max_ratio(struct bdi_writeback *wb,*/ /** -* zone_dirtyable_memory - number of dirtyable pages in a zone -* @zone: the zone +* node_dirtyable_memory - number of dirtyable pages in a node +* @pgdat: the node * -* Returns the zone's number of pages potentially available for dirty -* page cache. This is the base value for the per-zone dirty limits. +* Returns the node's number of pages potentially available for dirty +* page cache. This is the base value for the per-node dirty limits. */ -static unsigned long zone_dirtyable_memory (struct zone *zone) +static unsigned long node_dirtyable_memory (struct pglist_data *pgdat) { -unsigned long nr_pages; +unsigned long nr_pages =0 ; +int z; + +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_FREE_PAGES ); + } - nr_pages =zone_page_state (zone,NR_FREE_PAGES );/* * Pages reserved for the kernel should not be considered * dirtyable, to prevent a situation where reclaim has to * clean pages in order to balance the zones. */ - nr_pages -=min (nr_pages, zone->totalreserve_pages); + nr_pages -=min (nr_pages, pgdat->totalreserve_pages); - nr_pages +=node_page_state (zone->zone_pgdat,NR_INACTIVE_FILE ); - nr_pages +=node_page_state (zone->zone_pgdat,NR_ACTIVE_FILE ); + nr_pages +=node_page_state (pgdat,NR_INACTIVE_FILE ); + nr_pages +=node_page_state (pgdat,NR_ACTIVE_FILE );return nr_pages; }@@ -294,29 +303,13 @@ static unsigned long zone_dirtyable_memory(struct zone *zone)static unsigned long highmem_dirtyable_memory (unsigned long total) {#ifdef CONFIG_HIGHMEM -int node;unsigned long x =0 ; -int i; - -for_each_node_state (node,N_HIGH_MEMORY ) { -for (i =0 ; i <MAX_NR_ZONES ; i++) { -struct zone *z = &NODE_DATA (node)->node_zones[i]; -if (is_highmem (z)) - x +=zone_dirtyable_memory (z); - } - }/* -* Unreclaimable memory (kernel memory or anonymous memory -* without swap) can bring down the dirtyable pages below -* the zone's dirty balance reserve and the above calculation -* will underflow. However we still want to add in nodes -* which are below threshold (negative values) to get a more -* accurate calculation but make sure that the total never -* underflows. +* LRU lists are per-node so there is no fast and accurate means of +* calculating dirtyable memory in the highmem zone. */ -if ((long )x <0 ) - x =0 ; + x = totalhigh_pages;/* * Make sure that the number of highmem pages is never larger @@ -445,23 +438,23 @@ void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty) }/** -* zone_dirty_limit - maximum number of dirty pages allowed in a zone -* @zone: the zone +* node_dirty_limit - maximum number of dirty pages allowed in a node +* @pgdat: the node * -* Returns the maximum number of dirty pages allowed in a zone, based -* on the zone's dirtyable memory. +* Returns the maximum number of dirty pages allowed in a node, based +* on the node's dirtyable memory. */ -static unsigned long zone_dirty_limit (struct zone *zone) +static unsigned long node_dirty_limit (struct pglist_data *pgdat) { -unsigned long zone_memory =zone_dirtyable_memory (zone); +unsigned long node_memory =node_dirtyable_memory (pgdat);struct task_struct *tsk = current;unsigned long dirty;if (vm_dirty_bytes) dirty =DIV_ROUND_UP (vm_dirty_bytes,PAGE_SIZE ) * - zone_memory /global_dirtyable_memory (); + node_memory /global_dirtyable_memory ();else - dirty = vm_dirty_ratio * zone_memory /100 ; + dirty = vm_dirty_ratio * node_memory /100 ;if (tsk->flags &PF_LESS_THROTTLE ||rt_task (tsk)) dirty += dirty /4 ;@@ -470,19 +463,30 @@ static unsigned long zone_dirty_limit(struct zone *zone) }/** -* zone_dirty_ok - tells whether a zone is within its dirty limits -* @zone: the zone to check +* node_dirty_ok - tells whether a node is within its dirty limits +* @pgdat: the node to check * -* Returns %true when the dirty pages in @zone are within the zone's +* Returns %true when the dirty pages in @pgdat are within the node's * dirty limit, %false if the limit is exceeded. */ -bool zone_dirty_ok (struct zone *zone) +bool node_dirty_ok (struct pglist_data *pgdat) { -unsigned long limit =zone_dirty_limit (zone); +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 ); + } -return zone_page_state (zone,NR_FILE_DIRTY ) + -zone_page_state (zone,NR_UNSTABLE_NFS ) + -zone_page_state (zone,NR_WRITEBACK ) <= limit; +return nr_pages <= limit; } int dirty_background_ratio_handler(struct ctl_table *table, int write,mm/page_alloc.c +11
-15@@ -2917,31 +2917,24 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, }/* * When allocating a page cache page for writing, we -* want to get it from a zone that is within its dirty -* limit, such that no single zone holds more than its +* want to get it from a node that is within its dirty +* limit, such that no single node holds more than its * proportional share of globally allowed dirty pages. -* The dirty limits take into account the zone's +* The dirty limits take into account the node's * lowmem reserves and high watermark so that kswapd * should be able to balance it without having to * write pages from its LRU list. * -* This may look like it could increase pressure on -* lower zones by failing allocations in higher zones -* before they are full. But the pages that do spill -* over are limited as the lower zones are protected -* by this very same mechanism. It should not become -* a practical burden to them. -* * XXX: For now, allow allocations to potentially -* exceed the per-zone dirty limit in the slowpath +* exceed the per-node dirty limit in the slowpath * (spread_dirty_pages unset) before going into reclaim, * which is important when on a NUMA setup the allowed -* zones are together not big enough to reach the +* nodes are together not big enough to reach the * global limit. The proper fix for these situations -* will require awareness of zones in the +* will require awareness of nodes in the * dirty-throttling and the flusher threads. */ -if (ac->spread_dirty_pages && !zone_dirty_ok (zone)) +if (ac->spread_dirty_pages && !node_dirty_ok (zone->zone_pgdat))continue ; mark = zone->watermark[alloc_flags &ALLOC_WMARK_MASK ];@@ -6692,6 +6685,9 @@ static void calculate_totalreserve_pages(void)enum zone_type i, j;for_each_online_pgdat (pgdat) { + + pgdat->totalreserve_pages =0 ; +for (i =0 ; i <MAX_NR_ZONES ; i++) {struct zone *zone = pgdat->node_zones + i;long max =0 ;@@ -6708,7 +6704,7 @@ static void calculate_totalreserve_pages(void)if (max > zone->managed_pages) max = zone->managed_pages; - zone->totalreserve_pages = max; + pgdat->totalreserve_pages += max; reserve_pages += max; }Signature · 7 lines
2.6.4 -- 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>
Signature · 8 lines
Michal Hocko 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>
Michal Hocko
maintainerRe: [PATCH 15/27] mm, page_alloc: Consider dirtyable memory in terms of nodes
Quoted 18 lines · Michal Hocko
Quoted 2 lines · Mel Gorman
Historically dirty pages were spread among zones but now that LRUs are per-node it is more appropriate to consider dirty pages in a node.
I think this should deserve a note that a behavior for 32b highmem systems will change and could lead to early write throttling and observable stalls as a result because
highmem_dirtyable_memorywill always returntotalhigh_pagesregardless of how much is free resp. on LRUs so we can overestimate it.Highmem is usually used for LRU pages but there are other allocations which can use it (e.g. vmalloc). I understand how this is both an inherent problem of 32b with a larger high:low ratio and why it is hard to at least pretend we can cope with it with node based approach but we should at least document it.
I workaround would be to enable
highmem_dirtyable_memorywhich can lead to premature OOM killer for some workloads AFAIR.
[...]
Quoted 11 lines
Quoted 11 lines
static unsigned long
highmem_dirtyable_memory(unsigned long total){
#ifdefCONFIG_HIGHMEMmm/page-writeback.c +0
-6-int node;unsigned long x =0 ; -int i; - -for_each_node_state (node,N_HIGH_MEMORY ) { -for (i =0 ; i <MAX_NR_ZONES ; i++) { -struct zone *z = &NODE_DATA (node)->node_zones[i];
Quoted 4 lines
mm/page-writeback.c static unsigned long zone_dirtyable_memory(struct zone *zone) · line 308
Quoted 4 lines
mm/page-writeback.c +0
-4-if (is_highmem (z)) - x +=zone_dirtyable_memory (z); - } - }
Hmm, I have just noticed that we have NR_ZONE_LRU_ANON resp. NR_ZONE_LRU_FILE so we can estimate the amount of highmem contribution to the global counters by the following or similar:
for_each_node_state(node, N_HIGH_MEMORY) {
for (i = 0; i < MAX_NR_ZONES; i++) {
struct zone *z = &NODE_DATA(node)->node_zones[i];
if (!is_highmem(z))
continue;
x += zone_page_state(z, NR_FREE_PAGES) + zone_page_state(z, NR_ZONE_LRU_FILE) - high_wmark_pages(zone);
}high wmark reduction would be to emulate the reserve. What do you think?
Signature · 8 lines
Michal Hocko 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>
Re: [PATCH 15/27] mm, page_alloc: Consider dirtyable memory in terms of nodes
Quoted 38 lines · Michal Hocko
Quoted 7 lines
which can use it (e.g. vmalloc). I understand how this is both an inherent problem of 32b with a larger high:low ratio and why it is hard to at least pretend we can cope with it with node based approach but we should at least document it.
I workaround would be to enable
highmem_dirtyable_memorywhich can lead to premature OOM killer for some workloads AFAIR.[...]
Quoted 11 lines
Quoted 11 lines
static unsigned long
highmem_dirtyable_memory(unsigned long total){
#ifdefCONFIG_HIGHMEMmm/page-writeback.c +0
-6-int node;unsigned long x =0 ; -int i; - -for_each_node_state (node,N_HIGH_MEMORY ) { -for (i =0 ; i <MAX_NR_ZONES ; i++) { -struct zone *z = &NODE_DATA (node)->node_zones[i];Quoted 4 lines
mm/page-writeback.c static unsigned long zone_dirtyable_memory(struct zone *zone) · line 308
Quoted 4 lines
mm/page-writeback.c +0
-4-if (is_highmem (z)) - x +=zone_dirtyable_memory (z); - } - }Hmm, I have just noticed that we have
NR_ZONE_LRU_ANONresp.NR_ZONE_LRU_FILEso we can estimate the amount of highmem contribution to the global counters by the following or similar:for_each_node_state(node, N_HIGH_MEMORY) { for (i = 0; i < MAX_NR_ZONES; i++) { struct zone *z = &NODE_DATA(node)->node_zones[i]; if (!is_highmem(z)) continue; x += zone_page_state(z, NR_FREE_PAGES) + zone_page_state(z, NR_ZONE_LRU_FILE) - high_wmark_pages(zone); }
Quoted 1 line
high wmark reduction would be to emulate the reserve. What do you think?
Agreed with minor modifications. Went with this
for_each_node_state(node, N_HIGH_MEMORY) {
for (i = ZONE_NORMAL + 1; i < MAX_NR_ZONES; i++) {
struct zone *z;
if (!is_highmem_idx(z))
continue;
z = &NODE_DATA(node)->node_zones[i];
x += zone_page_state(z, NR_FREE_PAGES) +
zone_page_state(z, NR_ZONE_LRU_FILE) -
high_wmark_pages(zone);
}
}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>
Michal Hocko
maintainerRe: [PATCH 15/27] mm, page_alloc: Consider dirtyable memory in terms of nodes
Quoted 43 lines · Mel Gorman
Quoted 38 lines · Michal Hocko
Quoted 7 lines
which can use it (e.g. vmalloc). I understand how this is both an inherent problem of 32b with a larger high:low ratio and why it is hard to at least pretend we can cope with it with node based approach but we should at least document it.
I workaround would be to enable
highmem_dirtyable_memorywhich can lead to premature OOM killer for some workloads AFAIR.[...]
Quoted 11 lines
Quoted 11 lines
static unsigned long
highmem_dirtyable_memory(unsigned long total){
#ifdefCONFIG_HIGHMEMmm/page-writeback.c +0
-6-int node;unsigned long x =0 ; -int i; - -for_each_node_state (node,N_HIGH_MEMORY ) { -for (i =0 ; i <MAX_NR_ZONES ; i++) { -struct zone *z = &NODE_DATA (node)->node_zones[i];Quoted 4 lines
mm/page-writeback.c static unsigned long zone_dirtyable_memory(struct zone *zone) · line 308
Quoted 4 lines
mm/page-writeback.c +0
-4-if (is_highmem (z)) - x +=zone_dirtyable_memory (z); - } - }Hmm, I have just noticed that we have
NR_ZONE_LRU_ANONresp.NR_ZONE_LRU_FILEso we can estimate the amount of highmem contribution to the global counters by the following or similar:for_each_node_state(node, N_HIGH_MEMORY) { for (i = 0; i < MAX_NR_ZONES; i++) { struct zone *z = &NODE_DATA(node)->node_zones[i]; if (!is_highmem(z)) continue; x += zone_page_state(z, NR_FREE_PAGES) + zone_page_state(z, NR_ZONE_LRU_FILE) - high_wmark_pages(zone); }Quoted 1 line
high wmark reduction would be to emulate the reserve. What do you think?
Agreed with minor modifications. Went with this
Quoted 11 lines
for_each_node_state(node, N_HIGH_MEMORY) {
for (i = ZONE_NORMAL + 1; i < MAX_NR_ZONES; i++) {
struct zone *z;
if (!is_highmem_idx(z))
continue;
z = &NODE_DATA(node)->node_zones[i];
x += zone_page_state(z, NR_FREE_PAGES) +
zone_page_state(z, NR_ZONE_LRU_FILE) -
high_wmark_pages(zone);I guess you will still need an underflow protection. Because both free + lru pages might be below high wmark.
dirtyable += zone_page_state(z, NR_FREE_PAGES) + zone_page_state(z, NR_ZONE_LRU_FILE); if (dirtyable > high_wmark_pages(zone) dirtyable -= high_wmark_pages(zone); x += dirtyable;
Signature · 8 lines
Michal Hocko 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>
PATCH 16/27 mm: Move page mapped accounting to the node
In reply to Mel GormanReclaim makes decisions based on the number of pages that are mapped but it's mixing node and zone information. Account NR_FILE_MAPPED and NR_ANON_PAGES 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
@@ -138,8 +138,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
@@ -115,9 +115,6 @@ enum zone_stat_item {NR_ZONE_LRU_ANON =NR_ZONE_LRU_BASE ,NR_ZONE_LRU_FILE ,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,
@@ -162,6 +159,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
@@ -4314,7 +4314,7 @@ void show_free_areas(unsigned int filter)global_page_state (NR_UNSTABLE_NFS ),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),
@@ -4331,6 +4331,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,
@@ -4341,6 +4342,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"); }
@@ -4365,7 +4367,6 @@ void show_free_areas(unsigned int filter)" mlocked:%lukB" " dirty:%lukB" " writeback:%lukB" -" mapped:%lukB" " shmem:%lukB" " slab_reclaimable:%lukB" " slab_unreclaimable:%lukB"
@@ -4389,7 +4390,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
@@ -1219,7 +1219,7 @@ void do_page_add_anon_rmap(struct page *page,__inc_zone_page_state (page,NR_ANON_TRANSPARENT_HUGEPAGES ); } -__mod_zone_page_state (page_zone (page),NR_ANON_PAGES , nr); +__mod_node_page_state (page_pgdat (page),NR_ANON_PAGES , nr); }if (unlikely (PageKsm (page)))return ;
@@ -1263,7 +1263,7 @@ void page_add_new_anon_rmap(struct page *page,/* increment count (starts at -1) */ atomic_set (&page->_mapcount,0 ); } -__mod_zone_page_state (page_zone (page),NR_ANON_PAGES , nr); +__mod_node_page_state (page_pgdat (page),NR_ANON_PAGES , nr);__page_set_anon_rmap (page, vma, address,1 ); }
@@ -1277,7 +1277,7 @@ void page_add_file_rmap(struct page *page) {lock_page_memcg (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 (page,MEM_CGROUP_STAT_FILE_MAPPED ); }unlock_page_memcg (page);
@@ -1303,7 +1303,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 (page,MEM_CGROUP_STAT_FILE_MAPPED );if (unlikely (PageMlocked (page)))
@@ -1345,7 +1345,7 @@ static void page_remove_anon_compound_rmap(struct page *page)clear_page_mlock (page);if (nr) { -__mod_zone_page_state (page_zone (page),NR_ANON_PAGES , -nr); +__mod_node_page_state (page_pgdat (page),NR_ANON_PAGES , -nr);deferred_split_huge_page (page); } }
@@ -1377,7 +1377,7 @@ void page_remove_rmap(struct page *page, bool compound)* 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_ANON_PAGES ); +__dec_node_page_state (page,NR_ANON_PAGES );if (unlikely (PageMlocked (page)))clear_page_mlock (page);
mm/vmscan.c +1 -1
@@ -3596,7 +3596,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
@@ -924,8 +924,6 @@ const char * const vmstat_text[] = {"nr_zone_anon_lru" ,"nr_zone_file_lru" ,"nr_mlock" , -"nr_anon_pages" , -"nr_mapped" ,"nr_file_pages" ,"nr_dirty" , "nr_writeback",
@@ -967,6 +965,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.6.4 -- 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>
Andrew Morton
maintainerRe: [PATCH 16/27] mm: Move page mapped accounting to the node
Quoted 3 lines · On Tue, 21 Jun 2016 15:15:55 +0100 Mel Gorman <[email protected]>…
Reclaim makes decisions based on the number of pages that are mapped but it's mixing node and zone information. Account
NR_FILE_MAPPEDandNR_ANON_PAGESpages on the node.
<wading through rejects>
Boy, the difference between
__mod_zone_page_state(page_zone(page), ...
and
__mod_node_page_state(page_pgdat(page), ...
is looking subtle. When and why to use one versus the other. I'm not seeing any explanation of this in there but haven't yet looked hard.
--
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>
Re: [PATCH 16/27] mm: Move page mapped accounting to the node
Quoted 10 lines · Andrew Morton
Quoted 3 lines · On Tue, 21 Jun 2016 15:15:55 +0100 Mel Gorman <[email protected]>…
Reclaim makes decisions based on the number of pages that are mapped but it's mixing node and zone information. Account
NR_FILE_MAPPEDandNR_ANON_PAGESpages on the node.<wading through rejects>
Boy, the difference between
Quoted 9 lines
__mod_zone_page_state(page_zone(page), ...and
__mod_node_page_state(page_pgdat(page), ...is looking subtle. When and why to use one versus the other. I'm not seeing any explanation of this in there but haven't yet looked hard.
I'm not sure I see the problem. One applies for zone stats and the other is for node. Granted, care is needed to use the correct one or a random stat is updated instead of the one intended.
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>
Re: [PATCH 16/27] mm: Move page mapped accounting to the node
In reply to Mel GormanQuoted 3 lines · Mel Gorman
Reclaim makes decisions based on the number of pages that are mapped but it's mixing node and zone information. Account
NR_FILE_MAPPEDandNR_ANON_PAGESpages on the node.
So we will lose this stat in /proc/zoneinfo, but I am not really sure we should bother much. I suspect we really want to introduce /proc/nodeinfo and deprecate the first one. I didn't get to such a patch and maybe it is not a part of the series, but I think we should eventually do it.
Quoted 2 lines
Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[email protected]>
Quoted 224 lines
--- 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@@ -138,8 +138,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@@ -115,9 +115,6 @@ enum zone_stat_item {NR_ZONE_LRU_ANON =NR_ZONE_LRU_BASE ,NR_ZONE_LRU_FILE ,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,@@ -162,6 +159,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@@ -4314,7 +4314,7 @@ void show_free_areas(unsigned int filter)global_page_state (NR_UNSTABLE_NFS ),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),@@ -4331,6 +4331,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,@@ -4341,6 +4342,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"); }@@ -4365,7 +4367,6 @@ void show_free_areas(unsigned int filter)" mlocked:%lukB" " dirty:%lukB" " writeback:%lukB" -" mapped:%lukB" " shmem:%lukB" " slab_reclaimable:%lukB" " slab_unreclaimable:%lukB" @@ -4389,7 +4390,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@@ -1219,7 +1219,7 @@ void do_page_add_anon_rmap(struct page *page,__inc_zone_page_state (page,NR_ANON_TRANSPARENT_HUGEPAGES ); } -__mod_zone_page_state (page_zone (page),NR_ANON_PAGES , nr); +__mod_node_page_state (page_pgdat (page),NR_ANON_PAGES , nr); }if (unlikely (PageKsm (page)))return ;@@ -1263,7 +1263,7 @@ void page_add_new_anon_rmap(struct page *page,/* increment count (starts at -1) */ atomic_set (&page->_mapcount,0 ); } -__mod_zone_page_state (page_zone (page),NR_ANON_PAGES , nr); +__mod_node_page_state (page_pgdat (page),NR_ANON_PAGES , nr);__page_set_anon_rmap (page, vma, address,1 ); }@@ -1277,7 +1277,7 @@ void page_add_file_rmap(struct page *page) {lock_page_memcg (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 (page,MEM_CGROUP_STAT_FILE_MAPPED ); }unlock_page_memcg (page);@@ -1303,7 +1303,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 (page,MEM_CGROUP_STAT_FILE_MAPPED );if (unlikely (PageMlocked (page)))@@ -1345,7 +1345,7 @@ static void page_remove_anon_compound_rmap(struct page *page)clear_page_mlock (page);if (nr) { -__mod_zone_page_state (page_zone (page),NR_ANON_PAGES , -nr); +__mod_node_page_state (page_pgdat (page),NR_ANON_PAGES , -nr);deferred_split_huge_page (page); } }@@ -1377,7 +1377,7 @@ void page_remove_rmap(struct page *page, bool compound)* 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_ANON_PAGES ); +__dec_node_page_state (page,NR_ANON_PAGES );if (unlikely (PageMlocked (page)))clear_page_mlock (page);mm/vmscan.c +1
-1@@ -3596,7 +3596,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@@ -924,8 +924,6 @@ const char * const vmstat_text[] = {"nr_zone_anon_lru" ,"nr_zone_file_lru" ,"nr_mlock" , -"nr_anon_pages" , -"nr_mapped" ,"nr_file_pages" ,"nr_dirty" , "nr_writeback",@@ -967,6 +965,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.6.4 -- 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>
Signature · 8 lines
Michal Hocko 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>
PATCH 17/27 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.
--- drivers/base/node.c | 2 +- fs/proc/meminfo.c | 2 +- include/linux/mmzone.h | 2 +- mm/migrate.c | 2 +- mm/rmap.c | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-)
drivers/base/node.c +1 -1
@@ -120,7 +120,7 @@ static ssize_t node_read_meminfo(struct device *dev, 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_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,
fs/proc/meminfo.c +1 -1
@@ -138,7 +138,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
@@ -159,7 +159,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
@@ -501,7 +501,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. */ if (newzone != oldzone) {
mm/rmap.c +4 -4
@@ -1219,7 +1219,7 @@ void do_page_add_anon_rmap(struct page *page,__inc_zone_page_state (page,NR_ANON_TRANSPARENT_HUGEPAGES ); } -__mod_node_page_state (page_pgdat (page),NR_ANON_PAGES , nr); +__mod_node_page_state (page_pgdat (page),NR_ANON_MAPPED , nr); }if (unlikely (PageKsm (page)))return ;
@@ -1263,7 +1263,7 @@ void page_add_new_anon_rmap(struct page *page,/* increment count (starts at -1) */ atomic_set (&page->_mapcount,0 ); } -__mod_node_page_state (page_pgdat (page),NR_ANON_PAGES , nr); +__mod_node_page_state (page_pgdat (page),NR_ANON_MAPPED , nr);__page_set_anon_rmap (page, vma, address,1 ); }
@@ -1345,7 +1345,7 @@ static void page_remove_anon_compound_rmap(struct page *page)clear_page_mlock (page);if (nr) { -__mod_node_page_state (page_pgdat (page),NR_ANON_PAGES , -nr); +__mod_node_page_state (page_pgdat (page),NR_ANON_MAPPED , -nr);deferred_split_huge_page (page); } }
@@ -1377,7 +1377,7 @@ void page_remove_rmap(struct page *page, bool compound)* these counters are not modified in interrupt context, and * pte lock(a spinlock) is held, which implies preemption disabled. */ -__dec_node_page_state (page,NR_ANON_PAGES ); +__dec_node_page_state (page,NR_ANON_MAPPED );if (unlikely (PageMlocked (page)))clear_page_mlock (page);
Signature · 7 lines
2.6.4 -- 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>
Re: [PATCH 17/27] mm: Rename NR_ANON_PAGES to NR_ANON_MAPPED
Quoted 7 lines · Mel Gorman
NR_FILE_PAGESis the number of file pages.NR_FILE_MAPPEDis the number of mapped file pages.NR_ANON_PAGESis the number of mapped anon pages.This is unhelpful naming as it's easy to confuse
NR_FILE_MAPPEDandNR_ANON_PAGESfor mapped pages. This patch renamesNR_ANON_PAGESso we have
Quoted 6 lines
NR_FILE_PAGESis the number of file pages.NR_FILE_MAPPEDis the number of mapped file pages.NR_ANON_MAPPEDis the number of mapped anon pages.Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[email protected]>
Quoted 108 lines
--- drivers/base/node.c | 2 +- fs/proc/meminfo.c | 2 +- include/linux/mmzone.h | 2 +- mm/migrate.c | 2 +- mm/rmap.c | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-)drivers/base/node.c +1
-1@@ -120,7 +120,7 @@ static ssize_t node_read_meminfo(struct device *dev, 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_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,fs/proc/meminfo.c +1
-1@@ -138,7 +138,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@@ -159,7 +159,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@@ -501,7 +501,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. */ if (newzone != oldzone) {mm/rmap.c +4
-4@@ -1219,7 +1219,7 @@ void do_page_add_anon_rmap(struct page *page,__inc_zone_page_state (page,NR_ANON_TRANSPARENT_HUGEPAGES ); } -__mod_node_page_state (page_pgdat (page),NR_ANON_PAGES , nr); +__mod_node_page_state (page_pgdat (page),NR_ANON_MAPPED , nr); }if (unlikely (PageKsm (page)))return ;@@ -1263,7 +1263,7 @@ void page_add_new_anon_rmap(struct page *page,/* increment count (starts at -1) */ atomic_set (&page->_mapcount,0 ); } -__mod_node_page_state (page_pgdat (page),NR_ANON_PAGES , nr); +__mod_node_page_state (page_pgdat (page),NR_ANON_MAPPED , nr);__page_set_anon_rmap (page, vma, address,1 ); }@@ -1345,7 +1345,7 @@ static void page_remove_anon_compound_rmap(struct page *page)clear_page_mlock (page);if (nr) { -__mod_node_page_state (page_pgdat (page),NR_ANON_PAGES , -nr); +__mod_node_page_state (page_pgdat (page),NR_ANON_MAPPED , -nr);deferred_split_huge_page (page); } }@@ -1377,7 +1377,7 @@ void page_remove_rmap(struct page *page, bool compound)* these counters are not modified in interrupt context, and * pte lock(a spinlock) is held, which implies preemption disabled. */ -__dec_node_page_state (page,NR_ANON_PAGES ); +__dec_node_page_state (page,NR_ANON_MAPPED );if (unlikely (PageMlocked (page)))clear_page_mlock (page);Signature · 7 lines
2.6.4 -- 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>
Signature · 8 lines
Michal Hocko 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>
PATCH 18/27 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 | 10 ++++---- drivers/staging/android/lowmemorykiller.c | 4 +-- fs/fs-writeback.c | 4 +-- 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 | 10 ++++---- mm/migrate.c | 12 ++++----- mm/page-writeback.c | 42 +++++++++++++------------------ mm/page_alloc.c | 34 ++++++++++++------------- mm/shmem.c | 12 ++++----- mm/swap_state.c | 4 +-- mm/util.c | 4 +-- mm/vmscan.c | 16 ++++++------ mm/vmstat.c | 12 ++++----- 20 files changed, 103 insertions(+), 111 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 +5 -5
@@ -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_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
@@ -91,8 +91,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 +2 -2
@@ -1771,8 +1771,8 @@ static struct wb_writeback_work *get_next_work_item(struct bdi_writeback *wb)*/ 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
@@ -1452,7 +1452,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_wb_stat (&bdi->wb,WB_WRITEBACK ); -dec_zone_page_state (req->pages[i],NR_WRITEBACK_TEMP ); +dec_node_page_state (req->pages[i],NR_WRITEBACK_TEMP );wb_writeout_inc (&bdi->wb); }wake_up (&fi->page_waitq);
@@ -1642,7 +1642,7 @@ static int fuse_writepage_locked(struct page *page) req->inode = inode;inc_wb_stat (&inode_to_bdi (inode)->wb,WB_WRITEBACK ); -inc_zone_page_state (tmp_page,NR_WRITEBACK_TEMP ); +inc_node_page_state (tmp_page,NR_WRITEBACK_TEMP );spin_lock (&fc->lock);list_add (&req->writepages_entry, &fi->writepages);
@@ -1756,7 +1756,7 @@ static bool fuse_writepage_in_flight(struct fuse_req *new_req,spin_unlock (&fc->lock);dec_wb_stat (&bdi->wb,WB_WRITEBACK ); -dec_zone_page_state (page,NR_WRITEBACK_TEMP ); +dec_node_page_state (page,NR_WRITEBACK_TEMP );wb_writeout_inc (&bdi->wb);fuse_writepage_free (fc, new_req);fuse_request_free (new_req);
@@ -1855,7 +1855,7 @@ static int fuse_writepages_fill(struct page *page, req->page_descs[req->num_pages].length =PAGE_SIZE ;inc_wb_stat (&inode_to_bdi (inode)->wb,WB_WRITEBACK ); -inc_zone_page_state (tmp_page,NR_WRITEBACK_TEMP ); +inc_node_page_state (tmp_page,NR_WRITEBACK_TEMP ); err =0 ;if (is_writeback &&fuse_writepage_in_flight (req, page)) {
fs/nfs/internal.h +1 -1
@@ -653,7 +653,7 @@ void nfs_mark_page_unstable(struct page *page, struct nfs_commit_info *cinfo)if (!cinfo->dreq) {struct inode *inode =page_file_mapping (page)->host; -inc_zone_page_state (page,NR_UNSTABLE_NFS ); +inc_node_page_state (page,NR_UNSTABLE_NFS );inc_wb_stat (&inode_to_bdi (inode)->wb,WB_RECLAIMABLE );__mark_inode_dirty (inode,I_DIRTY_DATASYNC ); }
fs/nfs/write.c +1 -1
@@ -887,7 +887,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_wb_stat (&inode_to_bdi (page_file_mapping (page)->host)->wb,WB_RECLAIMABLE ); }
fs/proc/meminfo.c +5 -5
@@ -40,7 +40,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 ;
@@ -136,8 +136,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),
@@ -150,9 +150,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
@@ -115,20 +115,14 @@ enum zone_stat_item {NR_ZONE_LRU_ANON =NR_ZONE_LRU_BASE ,NR_ZONE_LRU_FILE ,NR_MLOCK ,/* mlock()ed pages found and moved off LRU */ -NR_FILE_PAGES , -NR_FILE_DIRTY , -NR_WRITEBACK ,NR_SLAB_RECLAIMABLE ,NR_SLAB_UNRECLAIMABLE ,NR_PAGETABLE ,/* used for pagetables */ NR_KERNEL_STACK ,/* Second 128 byte cacheline */ -NR_UNSTABLE_NFS ,/* NFS unstable pages */ NR_BOUNCE ,NR_VMSCAN_WRITE ,NR_VMSCAN_IMMEDIATE ,/* Prioritise for reclaim when writeback ends */ -NR_WRITEBACK_TEMP ,/* Writeback using temporary buffers */ -NR_SHMEM ,/* shmem pages (included tmpfs/GEM pages) */ NR_DIRTIED ,/* page dirtyings since bootup */ NR_WRITTEN ,/* page writings since bootup */ #if IS_ENABLED(CONFIG_ZSMALLOC)
@@ -162,6 +156,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
@@ -412,9 +412,9 @@ TRACE_EVENT(global_dirty_state, ),TP_fast_assign ( - __entry->nr_dirty = global_page_state(NR_FILE_DIRTY); - __entry->nr_writeback =global_page_state (NR_WRITEBACK ); - __entry->nr_unstable =global_page_state (NR_UNSTABLE_NFS ); + __entry->nr_dirty = global_node_page_state(NR_FILE_DIRTY); + __entry->nr_writeback =global_node_page_state (NR_WRITEBACK ); + __entry->nr_unstable =global_node_page_state (NR_UNSTABLE_NFS ); __entry->nr_dirtied =global_page_state (NR_DIRTIED ); __entry->nr_written =global_page_state (NR_WRITTEN ); __entry->background_thresh = background_thresh;
mm/filemap.c +5 -5
@@ -209,9 +209,9 @@ void __delete_from_page_cache(struct page *page, void *shadow)/* hugetlb pages do not participate in page cache accounting. */ if (!PageHuge (page)) -__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 );/* * At this point page must be either written or cleaned by truncate.
@@ -549,9 +549,9 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)* hugetlb pages do not participate in page cache accounting. */ if (!PageHuge (new)) -__inc_zone_page_state (new,NR_FILE_PAGES ); +__inc_node_page_state (new,NR_FILE_PAGES );if (PageSwapBacked (new)) -__inc_zone_page_state (new,NR_SHMEM ); +__inc_node_page_state (new,NR_SHMEM );spin_unlock_irqrestore (&mapping->tree_lock, flags);mem_cgroup_migrate (old, new);radix_tree_preload_end ();
@@ -658,7 +658,7 @@ static int __add_to_page_cache_locked(struct page *page,/* hugetlb pages do not participate in page cache accounting. */ if (!huge) -__inc_zone_page_state (page,NR_FILE_PAGES ); +__inc_node_page_state (page,NR_FILE_PAGES );spin_unlock_irq (&mapping->tree_lock);if (!huge)mem_cgroup_commit_charge (page, memcg, false, false);
mm/migrate.c +6 -6
@@ -505,15 +505,15 @@ int migrate_page_move_mapping(struct address_space *mapping,* are mapped to swap space. */ if (newzone != oldzone) { -__dec_zone_state (oldzone,NR_FILE_PAGES ); -__inc_zone_state (newzone,NR_FILE_PAGES ); +__dec_node_state (oldzone->zone_pgdat,NR_FILE_PAGES ); +__inc_node_state (newzone->zone_pgdat,NR_FILE_PAGES );if (PageSwapBacked (page) && !PageSwapCache (page)) { -__dec_zone_state (oldzone,NR_SHMEM ); -__inc_zone_state (newzone,NR_SHMEM ); +__dec_node_state (oldzone->zone_pgdat,NR_SHMEM ); +__inc_node_state (newzone->zone_pgdat,NR_SHMEM ); }if (dirty &&mapping_cap_account_dirty (mapping)) { -__dec_zone_state (oldzone,NR_FILE_DIRTY ); -__inc_zone_state (newzone,NR_FILE_DIRTY ); +__dec_node_state (oldzone->zone_pgdat,NR_FILE_DIRTY ); +__inc_node_state (newzone->zone_pgdat,NR_FILE_DIRTY ); } }local_irq_enable ();
mm/page-writeback.c +17 -25
106 lines not on this page · raw message
mm/page_alloc.c +17 -17
@@ -4180,7 +4180,7 @@ EXPORT_SYMBOL_GPL(si_mem_available);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;
@@ -4202,7 +4202,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 for (zone_type =0 ; zone_type <MAX_NR_ZONES ; zone_type++) {
@@ -4309,13 +4309,13 @@ 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_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_PAGES),
@@ -4332,6 +4332,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,
@@ -4343,6 +4348,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"); }
@@ -4365,19 +4375,14 @@ 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_pcp:%lukB" " local_pcp:%ukB" " free_cma:%lukB" -" writeback_tmp:%lukB" " node_pages_scanned:%lu" "\n" , zone->name,
@@ -4388,20 +4393,15 @@ 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 (free_pcp),K (this_cpu_read (zone->pageset->pcp.count)),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++)
@@ -4444,7 +4444,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
@@ -312,8 +312,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 ;
@@ -335,8 +335,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);put_page (page);BUG_ON (error);
@@ -1084,8 +1084,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/util.c +2 -2
@@ -522,7 +522,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
@@ -530,7 +530,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/vmscan.c +8 -8
@@ -3594,11 +3594,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
@@ -3617,17 +3617,17 @@ static unsigned long zone_pagecache_reclaimable(struct zone *zone)/* * If RECLAIM_UNMAP is set, then all file pages are considered * potentially reclaimable. Otherwise, we have to worry about -* pages like swapcache and zone_unmapped_file_pages() provides +* pages like swapcache and node_unmapped_file_pages() provides * a better estimate */ if (zone_reclaim_mode &RECLAIM_UNMAP ) - nr_pagecache_reclaimable =zone_page_state (zone,NR_FILE_PAGES ); + nr_pagecache_reclaimable =node_page_state (zone->zone_pgdat,NR_FILE_PAGES );else - nr_pagecache_reclaimable =zone_unmapped_file_pages (zone); + nr_pagecache_reclaimable =node_unmapped_file_pages (zone->zone_pgdat);/* If we can't clean pages, remove dirty pages from consideration */ if (!(zone_reclaim_mode &RECLAIM_WRITE )) - delta +=zone_page_state (zone,NR_FILE_DIRTY ); + delta +=node_page_state (zone->zone_pgdat,NR_FILE_DIRTY );/* Watch for any possible underflows due to delta */ if (unlikely (delta > nr_pagecache_reclaimable))
mm/vmstat.c +6 -6
@@ -924,19 +924,13 @@ const char * const vmstat_text[] = {"nr_zone_anon_lru" ,"nr_zone_file_lru" ,"nr_mlock" , -"nr_file_pages" , -"nr_dirty" , -"nr_writeback" ,"nr_slab_reclaimable" ,"nr_slab_unreclaimable" ,"nr_page_table_pages" ,"nr_kernel_stack" , -"nr_unstable" ,"nr_bounce" ,"nr_vmscan_write" ,"nr_vmscan_immediate_reclaim" , -"nr_writeback_temp" , -"nr_shmem" ,"nr_dirtied" ,"nr_written" , #if IS_ENABLED(CONFIG_ZSMALLOC)
@@ -967,6 +961,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.6.4 -- 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>
Re: [PATCH 18/27] mm: Move most file-based accounting to the node
Quoted 4 lines · Mel Gorman
There are now a number of accounting oddities such as mapped file pages being accounted for on the node while the total number of file pages are accounted on the zone. This can be coped with to some extent but it's confusing so this patch moves the relevant file-based accounted.
Same concern about the zoneinfo as for the other patch, but other than that no issues spotted.
Quoted 2 lines
Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[email protected]>
Quoted 741 lines
--- arch/s390/appldata/appldata_mem.c | 2 +- arch/tile/mm/pgtable.c | 8 +++--- drivers/base/node.c | 10 ++++---- drivers/staging/android/lowmemorykiller.c | 4 +-- fs/fs-writeback.c | 4 +-- 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 | 10 ++++---- mm/migrate.c | 12 ++++----- mm/page-writeback.c | 42 +++++++++++++------------------ mm/page_alloc.c | 34 ++++++++++++------------- mm/shmem.c | 12 ++++----- mm/swap_state.c | 4 +-- mm/util.c | 4 +-- mm/vmscan.c | 16 ++++++------ mm/vmstat.c | 12 ++++----- 20 files changed, 103 insertions(+), 111 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 +5
-5@@ -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_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@@ -91,8 +91,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 +2
-2@@ -1771,8 +1771,8 @@ static struct wb_writeback_work *get_next_work_item(struct bdi_writeback *wb)*/ 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@@ -1452,7 +1452,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_wb_stat (&bdi->wb,WB_WRITEBACK ); -dec_zone_page_state (req->pages[i],NR_WRITEBACK_TEMP ); +dec_node_page_state (req->pages[i],NR_WRITEBACK_TEMP );wb_writeout_inc (&bdi->wb); }wake_up (&fi->page_waitq);@@ -1642,7 +1642,7 @@ static int fuse_writepage_locked(struct page *page) req->inode = inode;inc_wb_stat (&inode_to_bdi (inode)->wb,WB_WRITEBACK ); -inc_zone_page_state (tmp_page,NR_WRITEBACK_TEMP ); +inc_node_page_state (tmp_page,NR_WRITEBACK_TEMP );spin_lock (&fc->lock);list_add (&req->writepages_entry, &fi->writepages);@@ -1756,7 +1756,7 @@ static bool fuse_writepage_in_flight(struct fuse_req *new_req,spin_unlock (&fc->lock);dec_wb_stat (&bdi->wb,WB_WRITEBACK ); -dec_zone_page_state (page,NR_WRITEBACK_TEMP ); +dec_node_page_state (page,NR_WRITEBACK_TEMP );wb_writeout_inc (&bdi->wb);fuse_writepage_free (fc, new_req);fuse_request_free (new_req);@@ -1855,7 +1855,7 @@ static int fuse_writepages_fill(struct page *page, req->page_descs[req->num_pages].length =PAGE_SIZE ;inc_wb_stat (&inode_to_bdi (inode)->wb,WB_WRITEBACK ); -inc_zone_page_state (tmp_page,NR_WRITEBACK_TEMP ); +inc_node_page_state (tmp_page,NR_WRITEBACK_TEMP ); err =0 ;if (is_writeback &&fuse_writepage_in_flight (req, page)) {fs/nfs/internal.h +1
-1@@ -653,7 +653,7 @@ void nfs_mark_page_unstable(struct page *page, struct nfs_commit_info *cinfo)if (!cinfo->dreq) {struct inode *inode =page_file_mapping (page)->host; -inc_zone_page_state (page,NR_UNSTABLE_NFS ); +inc_node_page_state (page,NR_UNSTABLE_NFS );inc_wb_stat (&inode_to_bdi (inode)->wb,WB_RECLAIMABLE );__mark_inode_dirty (inode,I_DIRTY_DATASYNC ); }fs/nfs/write.c +1
-1@@ -887,7 +887,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_wb_stat (&inode_to_bdi (page_file_mapping (page)->host)->wb,WB_RECLAIMABLE ); }fs/proc/meminfo.c +5
-5@@ -40,7 +40,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 ;@@ -136,8 +136,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),@@ -150,9 +150,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@@ -115,20 +115,14 @@ enum zone_stat_item {NR_ZONE_LRU_ANON =NR_ZONE_LRU_BASE ,NR_ZONE_LRU_FILE ,NR_MLOCK ,/* mlock()ed pages found and moved off LRU */ -NR_FILE_PAGES , -NR_FILE_DIRTY , -NR_WRITEBACK ,NR_SLAB_RECLAIMABLE ,NR_SLAB_UNRECLAIMABLE ,NR_PAGETABLE ,/* used for pagetables */ NR_KERNEL_STACK ,/* Second 128 byte cacheline */ -NR_UNSTABLE_NFS ,/* NFS unstable pages */ NR_BOUNCE ,NR_VMSCAN_WRITE ,NR_VMSCAN_IMMEDIATE ,/* Prioritise for reclaim when writeback ends */ -NR_WRITEBACK_TEMP ,/* Writeback using temporary buffers */ -NR_SHMEM ,/* shmem pages (included tmpfs/GEM pages) */ NR_DIRTIED ,/* page dirtyings since bootup */ NR_WRITTEN ,/* page writings since bootup */ #if IS_ENABLED(CONFIG_ZSMALLOC)@@ -162,6 +156,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@@ -412,9 +412,9 @@ TRACE_EVENT(global_dirty_state, ),TP_fast_assign ( - __entry->nr_dirty = global_page_state(NR_FILE_DIRTY); - __entry->nr_writeback =global_page_state (NR_WRITEBACK ); - __entry->nr_unstable =global_page_state (NR_UNSTABLE_NFS ); + __entry->nr_dirty = global_node_page_state(NR_FILE_DIRTY); + __entry->nr_writeback =global_node_page_state (NR_WRITEBACK ); + __entry->nr_unstable =global_node_page_state (NR_UNSTABLE_NFS ); __entry->nr_dirtied =global_page_state (NR_DIRTIED ); __entry->nr_written =global_page_state (NR_WRITTEN ); __entry->background_thresh = background_thresh;mm/filemap.c +5
-5@@ -209,9 +209,9 @@ void __delete_from_page_cache(struct page *page, void *shadow)/* hugetlb pages do not participate in page cache accounting. */ if (!PageHuge (page)) -__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 );/* * At this point page must be either written or cleaned by truncate. @@ -549,9 +549,9 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)* hugetlb pages do not participate in page cache accounting. */ if (!PageHuge (new)) -__inc_zone_page_state (new,NR_FILE_PAGES ); +__inc_node_page_state (new,NR_FILE_PAGES );if (PageSwapBacked (new)) -__inc_zone_page_state (new,NR_SHMEM ); +__inc_node_page_state (new,NR_SHMEM );spin_unlock_irqrestore (&mapping->tree_lock, flags);mem_cgroup_migrate (old, new);radix_tree_preload_end ();@@ -658,7 +658,7 @@ static int __add_to_page_cache_locked(struct page *page,/* hugetlb pages do not participate in page cache accounting. */ if (!huge) -__inc_zone_page_state (page,NR_FILE_PAGES ); +__inc_node_page_state (page,NR_FILE_PAGES );spin_unlock_irq (&mapping->tree_lock);if (!huge)mem_cgroup_commit_charge (page, memcg, false, false);mm/migrate.c +6
-6@@ -505,15 +505,15 @@ int migrate_page_move_mapping(struct address_space *mapping,* are mapped to swap space. */ if (newzone != oldzone) { -__dec_zone_state (oldzone,NR_FILE_PAGES ); -__inc_zone_state (newzone,NR_FILE_PAGES ); +__dec_node_state (oldzone->zone_pgdat,NR_FILE_PAGES ); +__inc_node_state (newzone->zone_pgdat,NR_FILE_PAGES );if (PageSwapBacked (page) && !PageSwapCache (page)) { -__dec_zone_state (oldzone,NR_SHMEM ); -__inc_zone_state (newzone,NR_SHMEM ); +__dec_node_state (oldzone->zone_pgdat,NR_SHMEM ); +__inc_node_state (newzone->zone_pgdat,NR_SHMEM ); }if (dirty &&mapping_cap_account_dirty (mapping)) { -__dec_zone_state (oldzone,NR_FILE_DIRTY ); -__inc_zone_state (newzone,NR_FILE_DIRTY ); +__dec_node_state (oldzone->zone_pgdat,NR_FILE_DIRTY ); +__inc_node_state (newzone->zone_pgdat,NR_FILE_DIRTY ); } }local_irq_enable ();mm/page-writeback.c +17
-25@@ -471,20 +471,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; }@@ -1574,10 +1566,10 @@ 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_reclaimable =global_node_page_state (NR_FILE_DIRTY ) + +global_node_page_state (NR_UNSTABLE_NFS ); gdtc->avail =global_dirtyable_memory (); - gdtc->dirty = nr_reclaimable +global_page_state (NR_WRITEBACK ); + gdtc->dirty = nr_reclaimable +global_node_page_state (NR_WRITEBACK );domain_dirty_limits (gdtc);@@ -1914,8 +1906,8 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb)* as we're trying to decide whether to put more under writeback. */ gdtc->avail =global_dirtyable_memory (); - gdtc->dirty =global_page_state (NR_FILE_DIRTY ) + -global_page_state (NR_UNSTABLE_NFS ); + gdtc->dirty =global_node_page_state (NR_FILE_DIRTY ) + +global_node_page_state (NR_UNSTABLE_NFS );domain_dirty_limits (gdtc);if (gdtc->dirty > gdtc->bg_thresh)@@ -1959,8 +1951,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 );@@ -1988,8 +1980,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 );struct bdi_writeback *wb;/* @@ -2440,7 +2432,7 @@ void account_page_dirtied(struct page *page, struct address_space *mapping) wb =inode_to_wb (inode);mem_cgroup_inc_page_stat (page,MEM_CGROUP_STAT_DIRTY ); -__inc_zone_page_state (page,NR_FILE_DIRTY ); +__inc_node_page_state (page,NR_FILE_DIRTY );__inc_zone_page_state (page,NR_DIRTIED );__inc_wb_stat (wb,WB_RECLAIMABLE );__inc_wb_stat (wb,WB_DIRTIED );@@ -2461,7 +2453,7 @@ void account_page_cleaned(struct page *page, struct address_space *mapping, {if (mapping_cap_account_dirty (mapping)) {mem_cgroup_dec_page_stat (page,MEM_CGROUP_STAT_DIRTY ); -dec_zone_page_state (page,NR_FILE_DIRTY ); +dec_node_page_state (page,NR_FILE_DIRTY );dec_wb_stat (wb,WB_RECLAIMABLE );task_io_account_cancelled_write (PAGE_SIZE ); }@@ -2716,7 +2708,7 @@ int clear_page_dirty_for_io(struct page *page) wb =unlocked_inode_to_wb_begin (inode, &locked);if (TestClearPageDirty (page)) {mem_cgroup_dec_page_stat (page,MEM_CGROUP_STAT_DIRTY ); -dec_zone_page_state (page,NR_FILE_DIRTY ); +dec_node_page_state (page,NR_FILE_DIRTY );dec_wb_stat (wb,WB_RECLAIMABLE ); ret =1 ; }@@ -2757,7 +2749,7 @@ int test_clear_page_writeback(struct page *page) }if (ret) {mem_cgroup_dec_page_stat (page,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 ); }unlock_page_memcg (page);@@ -2798,7 +2790,7 @@ int __test_set_page_writeback(struct page *page, bool keep_write) }if (!ret) {mem_cgroup_inc_page_stat (page,MEM_CGROUP_STAT_WRITEBACK ); -inc_zone_page_state (page,NR_WRITEBACK ); +inc_node_page_state (page,NR_WRITEBACK ); }unlock_page_memcg (page);return ret;mm/page_alloc.c +17
-17@@ -4180,7 +4180,7 @@ EXPORT_SYMBOL_GPL(si_mem_available);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;@@ -4202,7 +4202,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 for (zone_type =0 ; zone_type <MAX_NR_ZONES ; zone_type++) {@@ -4309,13 +4309,13 @@ 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_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_PAGES),@@ -4332,6 +4332,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,@@ -4343,6 +4348,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"); }@@ -4365,19 +4375,14 @@ 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_pcp:%lukB" " local_pcp:%ukB" " free_cma:%lukB" -" writeback_tmp:%lukB" " node_pages_scanned:%lu" "\n" , zone->name,@@ -4388,20 +4393,15 @@ 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 (free_pcp),K (this_cpu_read (zone->pageset->pcp.count)),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++)@@ -4444,7 +4444,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@@ -312,8 +312,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 ;@@ -335,8 +335,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);put_page (page);BUG_ON (error);@@ -1084,8 +1084,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/util.c +2
-2@@ -522,7 +522,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 @@ -530,7 +530,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/vmscan.c +8
-8@@ -3594,11 +3594,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 @@ -3617,17 +3617,17 @@ static unsigned long zone_pagecache_reclaimable(struct zone *zone)/* * If RECLAIM_UNMAP is set, then all file pages are considered * potentially reclaimable. Otherwise, we have to worry about -* pages like swapcache and zone_unmapped_file_pages() provides +* pages like swapcache and node_unmapped_file_pages() provides * a better estimate */ if (zone_reclaim_mode &RECLAIM_UNMAP ) - nr_pagecache_reclaimable =zone_page_state (zone,NR_FILE_PAGES ); + nr_pagecache_reclaimable =node_page_state (zone->zone_pgdat,NR_FILE_PAGES );else - nr_pagecache_reclaimable =zone_unmapped_file_pages (zone); + nr_pagecache_reclaimable =node_unmapped_file_pages (zone->zone_pgdat);/* If we can't clean pages, remove dirty pages from consideration */ if (!(zone_reclaim_mode &RECLAIM_WRITE )) - delta +=zone_page_state (zone,NR_FILE_DIRTY ); + delta +=node_page_state (zone->zone_pgdat,NR_FILE_DIRTY );/* Watch for any possible underflows due to delta */ if (unlikely (delta > nr_pagecache_reclaimable))mm/vmstat.c +6
-6@@ -924,19 +924,13 @@ const char * const vmstat_text[] = {"nr_zone_anon_lru" ,"nr_zone_file_lru" ,"nr_mlock" , -"nr_file_pages" , -"nr_dirty" , -"nr_writeback" ,"nr_slab_reclaimable" ,"nr_slab_unreclaimable" ,"nr_page_table_pages" ,"nr_kernel_stack" , -"nr_unstable" ,"nr_bounce" ,"nr_vmscan_write" ,"nr_vmscan_immediate_reclaim" , -"nr_writeback_temp" , -"nr_shmem" ,"nr_dirtied" ,"nr_written" , #if IS_ENABLED(CONFIG_ZSMALLOC)@@ -967,6 +961,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.6.4 -- 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>
Signature · 8 lines
Michal Hocko 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>
PATCH 19/27 mm: Move vmscan writes and file write accounting to the node
In reply to Mel GormanAs reclaim is now node-based, it follows that page write activity due to page reclaim should also be accounted for on the node. For consistency, also account page writes and page dirtying on a per-node basis.
After this patch, there are a few remaining zone counters that may appear strange but are fine. NUMA stats are still per-zone as this is a user-space interface that tools consume. NR_MLOCK, NR_SLAB_*, NR_PAGETABLE, NR_KERNEL_STACK and NR_BOUNCE are all allocations that potentially pin low memory and cannot trivially be reclaimed on demand. This information is still useful for debugging a page allocation failure warning.
--- include/linux/mmzone.h | 8 ++++---- include/trace/events/writeback.h | 4 ++-- mm/page-writeback.c | 6 +++--- mm/vmscan.c | 4 ++-- mm/vmstat.c | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-)
include/linux/mmzone.h +4 -4
@@ -121,10 +121,6 @@ enum zone_stat_item {NR_KERNEL_STACK ,/* Second 128 byte cacheline */ NR_BOUNCE , -NR_VMSCAN_WRITE , -NR_VMSCAN_IMMEDIATE ,/* Prioritise for reclaim when writeback ends */ -NR_DIRTIED ,/* page dirtyings since bootup */ -NR_WRITTEN ,/* page writings since bootup */ #if IS_ENABLED(CONFIG_ZSMALLOC) NR_ZSPAGES, /* allocated in zsmalloc */ #endif
@@ -162,6 +158,10 @@ enum node_stat_item {NR_WRITEBACK_TEMP ,/* Writeback using temporary buffers */ NR_SHMEM ,/* shmem pages (included tmpfs/GEM pages) */ NR_UNSTABLE_NFS ,/* NFS unstable pages */ +NR_VMSCAN_WRITE , +NR_VMSCAN_IMMEDIATE ,/* Prioritise for reclaim when writeback ends */ +NR_DIRTIED ,/* page dirtyings since bootup */ +NR_WRITTEN ,/* page writings since bootup */ NR_VM_NODE_STAT_ITEMS };
include/trace/events/writeback.h +2 -2
@@ -415,8 +415,8 @@ TRACE_EVENT(global_dirty_state, __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->nr_dirtied =global_node_page_state (NR_DIRTIED ); + __entry->nr_written =global_node_page_state (NR_WRITTEN ); __entry->background_thresh = background_thresh; __entry->dirty_thresh = dirty_thresh; __entry->dirty_limit = global_wb_domain.dirty_limit;
mm/page-writeback.c +3 -3
@@ -2433,7 +2433,7 @@ void account_page_dirtied(struct page *page, struct address_space *mapping)mem_cgroup_inc_page_stat (page,MEM_CGROUP_STAT_DIRTY );__inc_node_page_state (page,NR_FILE_DIRTY ); -__inc_zone_page_state (page,NR_DIRTIED ); +__inc_node_page_state (page,NR_DIRTIED );__inc_wb_stat (wb,WB_RECLAIMABLE );__inc_wb_stat (wb,WB_DIRTIED );task_io_account_write (PAGE_SIZE );
@@ -2521,7 +2521,7 @@ void account_page_redirty(struct page *page) wb =unlocked_inode_to_wb_begin (inode, &locked); current->nr_dirtied--; -dec_zone_page_state (page,NR_DIRTIED ); +dec_node_page_state (page,NR_DIRTIED );dec_wb_stat (wb,WB_DIRTIED );unlocked_inode_to_wb_end (inode, locked); }
@@ -2750,7 +2750,7 @@ int test_clear_page_writeback(struct page *page)if (ret) {mem_cgroup_dec_page_stat (page,MEM_CGROUP_STAT_WRITEBACK );dec_node_page_state (page,NR_WRITEBACK ); -inc_zone_page_state (page,NR_WRITTEN ); +inc_node_page_state (page,NR_WRITTEN ); }unlock_page_memcg (page);return ret;
mm/vmscan.c +2 -2
@@ -612,7 +612,7 @@ static pageout_t pageout(struct page *page, struct address_space *mapping,ClearPageReclaim (page); }trace_mm_vmscan_writepage (page); -inc_zone_page_state (page,NR_VMSCAN_WRITE ); +inc_node_page_state (page,NR_VMSCAN_WRITE );return PAGE_SUCCESS ; }
@@ -1111,7 +1111,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,* except we already have the page isolated * and know it's dirty */ -inc_zone_page_state (page,NR_VMSCAN_IMMEDIATE ); +inc_node_page_state (page,NR_VMSCAN_IMMEDIATE );SetPageReclaim (page); goto keep_locked;
mm/vmstat.c +4 -4
@@ -929,10 +929,6 @@ const char * const vmstat_text[] = {"nr_page_table_pages" ,"nr_kernel_stack" ,"nr_bounce" , -"nr_vmscan_write" , -"nr_vmscan_immediate_reclaim" , -"nr_dirtied" , -"nr_written" , #if IS_ENABLED(CONFIG_ZSMALLOC) "nr_zspages", #endif
@@ -967,6 +963,10 @@ const char * const vmstat_text[] = {"nr_writeback_temp" ,"nr_shmem" ,"nr_unstable" , +"nr_vmscan_write" , +"nr_vmscan_immediate_reclaim" , +"nr_dirtied" , +"nr_written" ,/* enum writeback_stat_item counters */ "nr_dirty_threshold",
Signature · 7 lines
2.6.4 -- 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>
Re: [PATCH 19/27] mm: Move vmscan writes and file write accounting to the node
Quoted 11 lines · Mel Gorman
As reclaim is now node-based, it follows that page write activity due to page reclaim should also be accounted for on the node. For consistency, also account page writes and page dirtying on a per-node basis.
After this patch, there are a few remaining zone counters that may appear strange but are fine. NUMA stats are still per-zone as this is a user-space interface that tools consume.
NR_MLOCK, NR_SLAB_*,NR_PAGETABLE,NR_KERNEL_STACKandNR_BOUNCEare all allocations that potentially pin low memory and cannot trivially be reclaimed on demand. This information is still useful for debugging a page allocation failure warning.
As I've said in other patch. I think we will need to provide /proc/nodeinfo to fill the gap.
Quoted 2 lines
Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[email protected]>
Quoted 136 lines
--- include/linux/mmzone.h | 8 ++++---- include/trace/events/writeback.h | 4 ++-- mm/page-writeback.c | 6 +++--- mm/vmscan.c | 4 ++-- mm/vmstat.c | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-)include/linux/mmzone.h +4
-4@@ -121,10 +121,6 @@ enum zone_stat_item {NR_KERNEL_STACK ,/* Second 128 byte cacheline */ NR_BOUNCE , -NR_VMSCAN_WRITE , -NR_VMSCAN_IMMEDIATE ,/* Prioritise for reclaim when writeback ends */ -NR_DIRTIED ,/* page dirtyings since bootup */ -NR_WRITTEN ,/* page writings since bootup */ #if IS_ENABLED(CONFIG_ZSMALLOC) NR_ZSPAGES, /* allocated in zsmalloc */ #endif@@ -162,6 +158,10 @@ enum node_stat_item {NR_WRITEBACK_TEMP ,/* Writeback using temporary buffers */ NR_SHMEM ,/* shmem pages (included tmpfs/GEM pages) */ NR_UNSTABLE_NFS ,/* NFS unstable pages */ +NR_VMSCAN_WRITE , +NR_VMSCAN_IMMEDIATE ,/* Prioritise for reclaim when writeback ends */ +NR_DIRTIED ,/* page dirtyings since bootup */ +NR_WRITTEN ,/* page writings since bootup */ NR_VM_NODE_STAT_ITEMS };include/trace/events/writeback.h +2
-2@@ -415,8 +415,8 @@ TRACE_EVENT(global_dirty_state, __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->nr_dirtied =global_node_page_state (NR_DIRTIED ); + __entry->nr_written =global_node_page_state (NR_WRITTEN ); __entry->background_thresh = background_thresh; __entry->dirty_thresh = dirty_thresh; __entry->dirty_limit = global_wb_domain.dirty_limit;mm/page-writeback.c +3
-3@@ -2433,7 +2433,7 @@ void account_page_dirtied(struct page *page, struct address_space *mapping)mem_cgroup_inc_page_stat (page,MEM_CGROUP_STAT_DIRTY );__inc_node_page_state (page,NR_FILE_DIRTY ); -__inc_zone_page_state (page,NR_DIRTIED ); +__inc_node_page_state (page,NR_DIRTIED );__inc_wb_stat (wb,WB_RECLAIMABLE );__inc_wb_stat (wb,WB_DIRTIED );task_io_account_write (PAGE_SIZE );@@ -2521,7 +2521,7 @@ void account_page_redirty(struct page *page) wb =unlocked_inode_to_wb_begin (inode, &locked); current->nr_dirtied--; -dec_zone_page_state (page,NR_DIRTIED ); +dec_node_page_state (page,NR_DIRTIED );dec_wb_stat (wb,WB_DIRTIED );unlocked_inode_to_wb_end (inode, locked); }@@ -2750,7 +2750,7 @@ int test_clear_page_writeback(struct page *page)if (ret) {mem_cgroup_dec_page_stat (page,MEM_CGROUP_STAT_WRITEBACK );dec_node_page_state (page,NR_WRITEBACK ); -inc_zone_page_state (page,NR_WRITTEN ); +inc_node_page_state (page,NR_WRITTEN ); }unlock_page_memcg (page);return ret;mm/vmscan.c +2
-2@@ -612,7 +612,7 @@ static pageout_t pageout(struct page *page, struct address_space *mapping,ClearPageReclaim (page); }trace_mm_vmscan_writepage (page); -inc_zone_page_state (page,NR_VMSCAN_WRITE ); +inc_node_page_state (page,NR_VMSCAN_WRITE );return PAGE_SUCCESS ; }@@ -1111,7 +1111,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,* except we already have the page isolated * and know it's dirty */ -inc_zone_page_state (page,NR_VMSCAN_IMMEDIATE ); +inc_node_page_state (page,NR_VMSCAN_IMMEDIATE );SetPageReclaim (page); goto keep_locked;mm/vmstat.c +4
-4@@ -929,10 +929,6 @@ const char * const vmstat_text[] = {"nr_page_table_pages" ,"nr_kernel_stack" ,"nr_bounce" , -"nr_vmscan_write" , -"nr_vmscan_immediate_reclaim" , -"nr_dirtied" , -"nr_written" , #if IS_ENABLED(CONFIG_ZSMALLOC) "nr_zspages", #endif@@ -967,6 +963,10 @@ const char * const vmstat_text[] = {"nr_writeback_temp" ,"nr_shmem" ,"nr_unstable" , +"nr_vmscan_write" , +"nr_vmscan_immediate_reclaim" , +"nr_dirtied" , +"nr_written" ,/* enum writeback_stat_item counters */ "nr_dirty_threshold",Signature · 7 lines
2.6.4 -- 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>
Signature · 8 lines
Michal Hocko 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>
Re: [PATCH 19/27] mm: Move vmscan writes and file write accounting to the node
Quoted 13 lines · Michal Hocko
Quoted 11 lines · Mel Gorman
As reclaim is now node-based, it follows that page write activity due to page reclaim should also be accounted for on the node. For consistency, also account page writes and page dirtying on a per-node basis.
After this patch, there are a few remaining zone counters that may appear strange but are fine. NUMA stats are still per-zone as this is a user-space interface that tools consume.
NR_MLOCK, NR_SLAB_*,NR_PAGETABLE,NR_KERNEL_STACKandNR_BOUNCEare all allocations that potentially pin low memory and cannot trivially be reclaimed on demand. This information is still useful for debugging a page allocation failure warning.
Quoted 3 lines
As I've said in other patch. I think we will need to provide
/proc/nodeinfoto fill the gap.
I added a patch on top that prints the node stats in zoneinfo but only once for the first populated zone in a node. Doing this or creating a new file are both potentially surprising but extending zoneinfo means there is a greater chance that a user will spot the change.
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>
Re: [PATCH 19/27] mm: Move vmscan writes and file write accounting to the node
Quoted 14 lines · Mel Gorman
Quoted 13 lines · Michal Hocko
Quoted 11 lines · Mel Gorman
As reclaim is now node-based, it follows that page write activity due to page reclaim should also be accounted for on the node. For consistency, also account page writes and page dirtying on a per-node basis.
After this patch, there are a few remaining zone counters that may appear strange but are fine. NUMA stats are still per-zone as this is a user-space interface that tools consume.
NR_MLOCK, NR_SLAB_*,NR_PAGETABLE,NR_KERNEL_STACKandNR_BOUNCEare all allocations that potentially pin low memory and cannot trivially be reclaimed on demand. This information is still useful for debugging a page allocation failure warning.
Quoted 8 lines
Quoted 3 lines
As I've said in other patch. I think we will need to provide
/proc/nodeinfoto fill the gap.I added a patch on top that prints the node stats in zoneinfo but only once for the first populated zone in a node. Doing this or creating a new file are both potentially surprising but extending zoneinfo means there is a greater chance that a user will spot the change.
BTW, there should already be /sys/devices/system/node/nodeX/vmstat providing the per-node stats, right?
Changing zoneinfo so that some zones have some stats that others don't seems to me like it can break some scripts...
--
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>
Re: [PATCH 19/27] mm: Move vmscan writes and file write accounting to the node
Quoted 24 lines · Vlastimil Babka
Quoted 14 lines · Mel Gorman
Quoted 13 lines · Michal Hocko
Quoted 11 lines · Mel Gorman
As reclaim is now node-based, it follows that page write activity due to page reclaim should also be accounted for on the node. For consistency, also account page writes and page dirtying on a per-node basis.
After this patch, there are a few remaining zone counters that may appear strange but are fine. NUMA stats are still per-zone as this is a user-space interface that tools consume.
NR_MLOCK, NR_SLAB_*,NR_PAGETABLE,NR_KERNEL_STACKandNR_BOUNCEare all allocations that potentially pin low memory and cannot trivially be reclaimed on demand. This information is still useful for debugging a page allocation failure warning.Quoted 8 lines
Quoted 3 lines
As I've said in other patch. I think we will need to provide
/proc/nodeinfoto fill the gap.I added a patch on top that prints the node stats in zoneinfo but only once for the first populated zone in a node. Doing this or creating a new file are both potentially surprising but extending zoneinfo means there is a greater chance that a user will spot the change.
Quoted 6 lines
BTW, there should already be
/sys/devices/system/node/nodeX/vmstatproviding the per-node stats, right?Changing zoneinfo so that some zones have some stats that others don't seems to me like it can break some scripts...
I suspect a lot of scripts that read zoneinfo just blindly record it. Similarly, there is no guarantee that a smart script knows to look in the per-node vmstat files either. This is a question of "wait see what breaks".
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>
PATCH 20/27 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
@@ -2571,8 +2571,10 @@ static void 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,gfp_zone (sc->gfp_mask), sc->nodemask) {
Signature · 7 lines
2.6.4 -- 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>
Michal Hocko
maintainerRe: [PATCH 20/27] mm, vmscan: Update classzone_idx if buffer_heads_over_limit
Quoted 17 lines · Mel Gorman
If buffer heads are over the limit then the direct reclaim
gfp_maskis promoted to__GFP_HIGHMEMso that lowmem is indirectly freed. With node-based reclaim, it is also required that theclasszone_idxbe updated or the pages will be skipped.Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[email protected]>--- mm/vmscan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)mm/vmscan.c +0
-0@@ -2571,8 +2571,10 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc,* highmem pages could be pinning lowmem pages storing buffer_heads
mm/vmscan.c static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc, · line 2580
Quoted 10 lines
mm/vmscan.c +3
-1*/ 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,gfp_zone (sc->gfp_mask), sc->nodemask) {
The code that follows that however does update classzone_idx
/*
* Note that reclaim_idx does not change as it is the highest
* zone reclaimed from which for empty zones is a no-op but
* classzone_idx is used by shrink_node to test if the slabs
* should be shrunk on a given node.
*/
while (!populated_zone(zone->zone_pgdat->node_zones +
classzone_idx)) {
classzone_idx--;
}so if we start with a zone which doesn't have the highmem zone we will not see highmems of other zone AFAIU. I guess this would be unlikely because highmem systems will be UMA in most cases but the code looks a bit confusing.
Signature · 2 lines
Michal Hocko SUSE Labs
PATCH 21/27 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 if the zonelist is ordered by node because there is no cheap way of tracking what nodes have already been visited. For zone-ordering, each node should be checked only once.
--- mm/page_alloc.c | 8 ++++++-- mm/vmscan.c | 13 +++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-)
mm/page_alloc.c +6 -2
@@ -3372,10 +3372,14 @@ static void wake_all_kswapds(unsigned int order, const struct alloc_context *ac) {struct zoneref *z;struct zone *zone; +pg_data_t *last_pgdat =NULL ;for_each_zone_zonelist_nodemask (zone, z, ac->zonelist, - ac->high_zoneidx, ac->nodemask) -wakeup_kswapd (zone, order,ac_classzone_idx (ac)); + ac->high_zoneidx, ac->nodemask) { +if (last_pgdat != zone->zone_pgdat) +wakeup_kswapd (zone, order,ac_classzone_idx (ac)); + last_pgdat = zone->zone_pgdat; + } } static inline unsigned int
mm/vmscan.c +11 -2
@@ -3429,6 +3429,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;if (!populated_zone (zone))return ;
@@ -3442,8 +3443,16 @@ void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx) pgdat->kswapd_order =max (pgdat->kswapd_order, order);if (!waitqueue_active (&pgdat->kswapd_wait))return ; -if (zone_balanced (zone, order,0 )) -return ; + +/* Only wake kswapd if all zones are unbalanced */ +for (z =0 ; z <= classzone_idx; z++) { + zone = pgdat->node_zones + z; +if (!populated_zone (zone)) +continue ; + +if (zone_balanced (zone, order, classzone_idx)) +return ; + }trace_mm_vmscan_wakeup_kswapd (pgdat->node_id,zone_idx (zone), order);wake_up_interruptible (&pgdat->kswapd_wait);
Signature · 7 lines
2.6.4 -- 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>
Re: [PATCH 21/27] mm, vmscan: Only wakeup kswapd once per node for the requested classzone
Quoted 10 lines · Mel Gorman
kswapd 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 if the zonelist is ordered by node because there is no cheap way of tracking what nodes have already been visited. For zone-ordering, each node should be checked only once.
Signed-off-by Mel Gorman <[email protected]>
--
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/27 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. It is possible that a node will be reclaimed multiple times if it has multiple zones but this is unavoidable without caching all nodes traversed so far. The documentation and interface to userspace is the same from a configuration perspective and will will be similar in behaviour 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 | 24 ++++++++++----- mm/vmscan.c | 77 ++++++++++++++++++++++++------------------------ 8 files changed, 77 insertions(+), 69 deletions(-)
include/linux/mmzone.h +9 -9
@@ -369,14 +369,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;
@@ -521,7 +513,6 @@ struct zone { }____cacheline_internodealigned_in_smp ;enum zone_flags { -ZONE_RECLAIM_LOCKED ,/* prevents concurrent reclaim */ ZONE_FAIR_DEPLETED ,/* fair zone policy batch depleted */ };
@@ -536,6 +527,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)
@@ -684,6 +676,14 @@ typedef struct pglist_data {*/ unsigned long totalreserve_pages; +#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
@@ -326,13 +326,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
@@ -54,7 +54,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
@@ -1508,8 +1508,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
@@ -2220,10 +2220,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
@@ -435,10 +435,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 +16 -8
@@ -2947,16 +2947,16 @@ 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 (zone_reclaim_mode ==0 || +if (node_reclaim_mode ==0 || !zone_allows_reclaim (ac->preferred_zoneref->zone, zone))continue ; - ret =zone_reclaim (zone, gfp_mask, order); + 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 :
@@ -5944,9 +5944,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;
@@ -6923,6 +6923,7 @@ int watermark_scale_factor_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;
@@ -6930,8 +6931,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 ; }
@@ -6939,6 +6943,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;
@@ -6946,8 +6951,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.6.4 -- 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/27 mm, vmscan: Add classzone information to tracepoints
In reply to Mel GormanThis is convenient when tracking down why the skip count is high because it'll show what classzone kswapd woke up at and what zones are being isolated.
--- include/trace/events/vmscan.h | 51 ++++++++++++++++++++++++++----------------- mm/vmscan.c | 14 +++++++----- 2 files changed, 40 insertions(+), 25 deletions(-)
include/trace/events/vmscan.h +31 -20
@@ -55,21 +55,23 @@ TRACE_EVENT(mm_vmscan_kswapd_sleep,TRACE_EVENT (mm_vmscan_kswapd_wake, - TP_PROTO(int nid, int order), + TP_PROTO(int nid, int zid, int order), -TP_ARGS (nid, order), +TP_ARGS (nid, zid, order),TP_STRUCT__entry ( __field( int, nid ) + __field( int, zid )__field ( int, order ) ),TP_fast_assign ( __entry->nid = nid; + __entry->zid = zid; __entry->order = order; ), -TP_printk ("nid=%d order=%d" , __entry->nid, __entry->order) +TP_printk ("nid=%d zid=%d order=%d" , __entry->nid, __entry->zid, __entry->order) ); TRACE_EVENT(mm_vmscan_wakeup_kswapd,
@@ -98,47 +100,50 @@ TRACE_EVENT(mm_vmscan_wakeup_kswapd,DECLARE_EVENT_CLASS (mm_vmscan_direct_reclaim_begin_template, - TP_PROTO(int order, int may_writepage, gfp_t gfp_flags), + TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx), -TP_ARGS (order, may_writepage, gfp_flags), +TP_ARGS (order, may_writepage, gfp_flags, classzone_idx),TP_STRUCT__entry ( __field( int, order ) __field( int, may_writepage ) __field( gfp_t, gfp_flags ) +__field ( int, classzone_idx ) ),TP_fast_assign ( __entry->order = order; __entry->may_writepage = may_writepage; __entry->gfp_flags = gfp_flags; + __entry->classzone_idx = classzone_idx; ), -TP_printk ("order=%d may_writepage=%d gfp_flags=%s" , +TP_printk ("order=%d may_writepage=%d gfp_flags=%s classzone_idx=%d" , __entry->order, __entry->may_writepage, -show_gfp_flags (__entry->gfp_flags)) +show_gfp_flags (__entry->gfp_flags), + __entry->classzone_idx) );DEFINE_EVENT (mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin, - TP_PROTO(int order, int may_writepage, gfp_t gfp_flags), + TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx), -TP_ARGS (order, may_writepage, gfp_flags) +TP_ARGS (order, may_writepage, gfp_flags, classzone_idx) );DEFINE_EVENT (mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin, - TP_PROTO(int order, int may_writepage, gfp_t gfp_flags), + TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx), -TP_ARGS (order, may_writepage, gfp_flags) +TP_ARGS (order, may_writepage, gfp_flags, classzone_idx) );DEFINE_EVENT (mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin, - TP_PROTO(int order, int may_writepage, gfp_t gfp_flags), + TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx), -TP_ARGS (order, may_writepage, gfp_flags) +TP_ARGS (order, may_writepage, gfp_flags, classzone_idx) ); DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,
@@ -266,16 +271,18 @@ TRACE_EVENT(mm_shrink_slab_end, DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template, - TP_PROTO(int order, + TP_PROTO(int classzone_idx, + int order, unsigned long nr_requested, unsigned long nr_scanned, unsigned long nr_taken, isolate_mode_t isolate_mode, int file), - TP_ARGS(order, nr_requested, nr_scanned, nr_taken, isolate_mode, file), + TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_taken, isolate_mode, file), TP_STRUCT__entry( + __field(int, classzone_idx) __field(int, order) __field(unsigned long, nr_requested) __field(unsigned long, nr_scanned)
@@ -285,6 +292,7 @@ DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template, ), TP_fast_assign( + __entry->classzone_idx = classzone_idx; __entry->order = order; __entry->nr_requested = nr_requested; __entry->nr_scanned = nr_scanned;
@@ -293,8 +301,9 @@ DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template, __entry->file = file; ), - TP_printk("isolate_mode=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu file=%d", + TP_printk("isolate_mode=%d classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu file=%d", __entry->isolate_mode, + __entry->classzone_idx, __entry->order, __entry->nr_requested, __entry->nr_scanned,
@@ -304,27 +313,29 @@ DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template,DEFINE_EVENT (mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate, - TP_PROTO(int order, + TP_PROTO(int classzone_idx, + int order, unsigned long nr_requested, unsigned long nr_scanned, unsigned long nr_taken, isolate_mode_t isolate_mode, int file), -TP_ARGS (order, nr_requested, nr_scanned, nr_taken, isolate_mode, file) +TP_ARGS (classzone_idx, order, nr_requested, nr_scanned, nr_taken, isolate_mode, file) );DEFINE_EVENT (mm_vmscan_lru_isolate_template, mm_vmscan_memcg_isolate, - TP_PROTO(int order, + TP_PROTO(int classzone_idx, + int order, unsigned long nr_requested, unsigned long nr_scanned, unsigned long nr_taken, isolate_mode_t isolate_mode, int file), -TP_ARGS (order, nr_requested, nr_scanned, nr_taken, isolate_mode, file) +TP_ARGS (classzone_idx, order, nr_requested, nr_scanned, nr_taken, isolate_mode, file) );
mm/vmscan.c +9 -5
@@ -1433,7 +1433,7 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,if (!list_empty (&pages_skipped))list_splice (&pages_skipped, src); *nr_scanned = scan; -trace_mm_vmscan_lru_isolate (sc->order, nr_to_scan, scan, +trace_mm_vmscan_lru_isolate (sc->reclaim_idx, sc->order, nr_to_scan, scan, nr_taken, mode,is_file_lru (lru));for (scan =0 ; scan <MAX_NR_ZONES ; scan++) { nr_pages = nr_zone_taken[scan];
@@ -2893,7 +2893,8 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,trace_mm_vmscan_direct_reclaim_begin (order, sc.may_writepage, - gfp_mask); + gfp_mask, + sc.reclaim_idx); nr_reclaimed =do_try_to_free_pages (zonelist, &sc);
@@ -2924,7 +2925,8 @@ unsigned long mem_cgroup_shrink_node(struct mem_cgroup *memcg,trace_mm_vmscan_memcg_softlimit_reclaim_begin (sc.order, sc.may_writepage, - sc.gfp_mask); + sc.gfp_mask, + sc.reclaim_idx);/* * NOTE: Although we can get the priority field, using it
@@ -2972,7 +2974,8 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,trace_mm_vmscan_memcg_reclaim_begin (0 , sc.may_writepage, - sc.gfp_mask); + sc.gfp_mask, + sc.reclaim_idx); nr_reclaimed =do_try_to_free_pages (zonelist, &sc);
@@ -3407,7 +3410,8 @@ static int kswapd(void *p)* but kcompactd is woken to compact for the original * request (alloc_order). */ -trace_mm_vmscan_kswapd_wake (pgdat->node_id, alloc_order); +trace_mm_vmscan_kswapd_wake (pgdat->node_id, classzone_idx, + alloc_order); reclaim_order =balance_pgdat (pgdat, alloc_order, classzone_idx);if (reclaim_order < alloc_order) goto kswapd_try_sleep;
Signature · 7 lines
2.6.4 -- 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/27 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 | 5 ---- mm/internal.h | 1 - mm/page_alloc.c | 75 +------------------------------------------------- mm/vmstat.c | 4 +-- 4 files changed, 2 insertions(+), 83 deletions(-)
include/linux/mmzone.h +0 -5
@@ -110,7 +110,6 @@ struct zone_padding {enum zone_stat_item {/* First 128 byte cacheline (assuming 64 bit words) */ NR_FREE_PAGES , -NR_ALLOC_BATCH ,NR_ZONE_LRU_BASE ,/* Used only for compaction and reclaim retry */ NR_ZONE_LRU_ANON =NR_ZONE_LRU_BASE ,NR_ZONE_LRU_FILE ,
@@ -512,10 +511,6 @@ struct zone {atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS ]; }____cacheline_internodealigned_in_smp ; -enum zone_flags { -ZONE_FAIR_DEPLETED ,/* fair zone policy batch depleted */ -}; -enum pgdat_flags {PGDAT_CONGESTED ,/* zone has many dirty pages backed by * a congested BDI
mm/internal.h +0 -1
@@ -469,7 +469,6 @@ 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 */ enum ttu_flags ;struct tlbflush_unmap_batch ;
mm/page_alloc.c +1 -74
145 lines not on this page · raw message
mm/vmstat.c +1 -3
@@ -920,7 +920,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_zone_anon_lru" ,"nr_zone_file_lru" ,"nr_mlock" ,
@@ -1626,10 +1625,9 @@ int vmstat_refresh(struct ctl_table *table, int write, val =atomic_long_read (&vm_zone_stat[i]);if (val <0 ) {switch (i) { -case NR_ALLOC_BATCH :case NR_PAGES_SCANNED :/* -* These are often seen to go negative in +* This is often seen to go negative in * recent kernels, but not to go permanently * negative. Whilst it would be nicer not to * have exceptions, rooting them out would be
Signature · 7 lines
2.6.4 -- 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/27 mm: page_alloc: Cache the last node whose dirty limit is reached
In reply to Mel GormanIf a page is about to be dirtied then the page allocator attempts to limit the total number of dirty pages that exists in any given zone. The call to node_dirty_ok is expensive so this patch records if the last pgdat examined hit the dirty limits. In some cases, this reduces the number of calls to node_dirty_ok().
--- mm/page_alloc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
mm/page_alloc.c +11 -2
@@ -2853,6 +2853,8 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, {struct zoneref *z = ac->preferred_zoneref;struct zone *zone; +struct pglist_data *last_pgdat_dirty_limit =NULL ; +/* * Scan zonelist, looking for a zone with enough free. * See also __cpuset_node_allowed() comment in kernel/cpuset.c.
@@ -2885,8 +2887,15 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,* will require awareness of nodes in the * dirty-throttling and the flusher threads. */ -if (ac->spread_dirty_pages && !node_dirty_ok (zone->zone_pgdat)) -continue ; +if (ac->spread_dirty_pages) { +if (last_pgdat_dirty_limit == zone->zone_pgdat) +continue ; + +if (!node_dirty_ok (zone->zone_pgdat)) { + last_pgdat_dirty_limit = zone->zone_pgdat; +continue ; + } + } mark = zone->watermark[alloc_flags &ALLOC_WMARK_MASK ]; if (!zone_watermark_fast(zone, order, mark,
Signature · 7 lines
2.6.4 -- 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 26/27 mm: vmstat: Replace __count_zone_vm_events with a zone id equivalent
In reply to Mel GormanThis is partially a preparation patch for more vmstat work but it also has the slight advantage that __count_zid_vm_events is cheaper to calculate than __count_zone_vm_events().
--- include/linux/vmstat.h | 5 ++--- mm/page_alloc.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-)
include/linux/vmstat.h +2 -3
@@ -107,9 +107,8 @@ static inline void vm_events_fold_cpu(int cpu)#define count_vm_vmacache_event (x) do {} while (0)#endif -#define __count_zone_vm_events (item, zone, delta) \ - __count_vm_events(item##_NORMAL - ZONE_NORMAL + \ - zone_idx(zone), delta) +#define __count_zid_vm_events (item, zid, delta) \ + __count_vm_events(item##_NORMAL - ZONE_NORMAL + zid, delta)/* * Zone and node-based page accounting with per cpu differentials.
mm/page_alloc.c +1 -1
@@ -2621,7 +2621,7 @@ struct page *buffered_rmqueue(struct zone *preferred_zone, get_pcppage_migratetype(page)); } -__count_zone_vm_events (PGALLOC , zone,1 << order); +__count_zid_vm_events (PGALLOC ,page_zonenum (page),1 << order);zone_statistics (preferred_zone, zone, gfp_flags);local_irq_restore (flags);
Signature · 7 lines
2.6.4 -- 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 27/27 mm: vmstat: Account per-zone stalls and pages skipped during reclaim
In reply to Mel GormanThe vmstat allocstall was fairly useful in the general sense but node-based LRUs change that. It's important to know if a stall was for an address-limited allocation request as this will require skipping pages from other zones. This patch adds pgstall_* counters to replace allocstall. The sum of the counters will equal the old allocstall so it can be trivially recalculated. A high number of address-limited allocation requests may result in a lot of useless LRU scanning for suitable pages.
As address-limited allocations require pages to be skipped, it's important to know how much useless LRU scanning took place so this patch adds pgskip* counters. This yields the following model
1. The number of address-space limited stalls can be accounted for (pgstall)
2. The amount of useless work required to reclaim the data is accounted (pgskip)
3. The total number of scans is available from pgscan_kswapd and pgscan_direct so from that the ratio of useful to useless scans can be calculated.
--- include/linux/vm_event_item.h | 4 +++- mm/huge_memory.c | 19 +++++++++++++++---- mm/vmscan.c | 15 +++++++++++++-- mm/vmstat.c | 3 ++- 4 files changed, 33 insertions(+), 8 deletions(-)
include/linux/vm_event_item.h +3 -1
@@ -23,6 +23,8 @@enum vm_event_item {PGPGIN ,PGPGOUT ,PSWPIN ,PSWPOUT , FOR_ALL_ZONES(PGALLOC), + FOR_ALL_ZONES(PGSTALL), + FOR_ALL_ZONES(PGSCAN_SKIP),PGFREE ,PGACTIVATE ,PGDEACTIVATE ,PGFAULT ,PGMAJFAULT ,PGLAZYFREED ,
@@ -37,7 +39,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,#endif PGINODESTEAL ,SLABS_SCANNED ,KSWAPD_INODESTEAL ,KSWAPD_LOW_WMARK_HIT_QUICKLY ,KSWAPD_HIGH_WMARK_HIT_QUICKLY , -PAGEOUTRUN ,ALLOCSTALL ,PGROTATED , +PAGEOUTRUN ,PGROTATED ,DROP_PAGECACHE ,DROP_SLAB , #ifdef CONFIG_NUMA_BALANCING NUMA_PTE_UPDATES,
mm/huge_memory.c +15 -4
@@ -2452,6 +2452,17 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm,return true; } +static unsigned long sum_alloc_stalls (void ) +{ +int zid; +unsigned long allocstall =0 ; + +for (zid =0 ; zid <MAX_NR_ZONES -1 ; zid++) + allocstall +=sum_vm_event (PGSTALL_NORMAL -ZONE_NORMAL + zid); + +return allocstall; +} + static void collapse_huge_page(struct mm_struct *mm, unsigned long address, struct page **hpage,
@@ -2488,7 +2499,7 @@ static void collapse_huge_page(struct mm_struct *mm, } swap =get_mm_counter (mm,MM_SWAPENTS ); - curr_allocstall =sum_vm_event (ALLOCSTALL ); + curr_allocstall =sum_alloc_stalls ();;down_read (&mm->mmap_sem); result =hugepage_vma_revalidate (mm, address);if (result) {
@@ -2934,7 +2945,7 @@ static void khugepaged_wait_work(void)if (!scan_sleep_jiffies)return ; - allocstall =sum_vm_event (ALLOCSTALL ); + allocstall =sum_alloc_stalls (); khugepaged_sleep_expire = jiffies + scan_sleep_jiffies; wait_event_freezable_timeout(khugepaged_wait, khugepaged_should_wakeup(),
@@ -2943,7 +2954,7 @@ static void khugepaged_wait_work(void) }if (khugepaged_enabled ()) { - allocstall =sum_vm_event (ALLOCSTALL ); + allocstall =sum_alloc_stalls ();wait_event_freezable (khugepaged_wait,khugepaged_wait_event ()); } }
@@ -2954,7 +2965,7 @@ static int khugepaged(void *none)set_freezable ();set_user_nice (current,MAX_NICE ); - allocstall =sum_vm_event (ALLOCSTALL ); + allocstall =sum_alloc_stalls ();while (!kthread_should_stop ()) {khugepaged_do_scan ();
mm/vmscan.c +13 -2
@@ -1388,6 +1388,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 nr_zone_taken[MAX_NR_ZONES ] = {0 }; +unsigned long nr_skipped[MAX_NR_ZONES ] = {0 , };unsigned long scan, nr_pages;LIST_HEAD (pages_skipped);
@@ -1402,6 +1403,7 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,if (page_zonenum (page) > sc->reclaim_idx) {list_move (&page->lru, &pages_skipped); + nr_skipped[page_zonenum (page)]++;continue ; }
@@ -1430,8 +1432,17 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,* scanning would soon rescan the same pages to skip and put the * system at risk of premature OOM. */ -if (!list_empty (&pages_skipped)) +if (!list_empty (&pages_skipped)) { +int zid; +list_splice (&pages_skipped, src); +for (zid =0 ; zid <MAX_NR_ZONES ; zid++) { +if (!nr_skipped[zid]) +continue ; + +__count_zid_vm_events (PGSCAN_SKIP , zid, nr_skipped[zid]); + } + } *nr_scanned = scan;trace_mm_vmscan_lru_isolate (sc->reclaim_idx, sc->order, nr_to_scan, scan, nr_taken, mode,is_file_lru (lru));
@@ -2684,7 +2695,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,delayacct_freepages_start ();if (global_reclaim (sc)) -count_vm_event (ALLOCSTALL ); +__count_zid_vm_events (PGSTALL , classzone_idx,1 ); do { vmpressure_prio(sc->gfp_mask, sc->target_mem_cgroup,
mm/vmstat.c +2 -1
@@ -979,6 +979,8 @@ const char * const vmstat_text[] = {"pswpout" , TEXTS_FOR_ZONES("pgalloc") + TEXTS_FOR_ZONES("pgstall") + TEXTS_FOR_ZONES("pgskip")"pgfree" , "pgactivate",
@@ -1004,7 +1006,6 @@ const char * const vmstat_text[] = {"kswapd_low_wmark_hit_quickly" ,"kswapd_high_wmark_hit_quickly" ,"pageoutrun" , -"allocstall" , "pgrotated",
Signature · 7 lines
2.6.4 -- 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 3 lines · Mel Gorman
The bulk of the updates are in response to review from Vlastimil Babka and received a lot more testing than v6.
Hi Andrew,
Please drop these patches again from mmotm.
There has been a number of odd conflicts resulting in at least one major bug where a node-counter is used on a zone that will result in random behaviour. Some of the additional feedback is non-trivial and all of it will need to be resolved against the OOM detection rework and the huge tmpfs implementation.
It'll take time to resolve this and I don't want to leave mmotm in a broken state in the meantime. I have a copy of mmots so I have the conflict resolutions you already applied.
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>
Michal Hocko
maintainerQuoted 7 lines · Mel Gorman
Quoted 3 lines · Mel Gorman
The bulk of the updates are in response to review from Vlastimil Babka and received a lot more testing than v6.
Hi Andrew,
Quoted 7 lines
Please drop these patches again from mmotm.
There has been a number of odd conflicts resulting in at least one major bug where a node-counter is used on a zone that will result in random behaviour. Some of the additional feedback is non-trivial and all of it will need to be resolved against the OOM detection rework and the huge tmpfs implementation.
FWIW I haven't spotted any obvious misbehaving wrt. the OOM detection rework. You have kept the per-zone counters which are used for the retry logic so I think we should be safe. I am still reading through the series though.
Signature · 8 lines
Michal Hocko 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>
Quoted 16 lines · Michal Hocko
Quoted 7 lines · Mel Gorman
Quoted 3 lines · Mel Gorman
The bulk of the updates are in response to review from Vlastimil Babka and received a lot more testing than v6.
Hi Andrew,
Quoted 7 lines
Please drop these patches again from mmotm.
There has been a number of odd conflicts resulting in at least one major bug where a node-counter is used on a zone that will result in random behaviour. Some of the additional feedback is non-trivial and all of it will need to be resolved against the OOM detection rework and the huge tmpfs implementation.
Quoted 5 lines
FWIW I haven't spotted any obvious misbehaving wrt. the OOM detection rework. You have kept the per-zone counters which are used for the retry logic so I think we should be safe. I am still reading through the series though.
The main snag is NR_FILE_DIRTY and NR_WRITEBACK in should_reclaim_retry. It currently is a random number generator if it reads a zone stat instead of the node one. In some configurations, it even reads values after the stats array.
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>
Michal Hocko
maintainerQuoted 23 lines · Mel Gorman
Quoted 16 lines · Michal Hocko
Quoted 7 lines · Mel Gorman
Quoted 3 lines · Mel Gorman
The bulk of the updates are in response to review from Vlastimil Babka and received a lot more testing than v6.
Hi Andrew,
Quoted 7 lines
Please drop these patches again from mmotm.
There has been a number of odd conflicts resulting in at least one major bug where a node-counter is used on a zone that will result in random behaviour. Some of the additional feedback is non-trivial and all of it will need to be resolved against the OOM detection rework and the huge tmpfs implementation.
Quoted 5 lines
FWIW I haven't spotted any obvious misbehaving wrt. the OOM detection rework. You have kept the per-zone counters which are used for the retry logic so I think we should be safe. I am still reading through the series though.
Quoted 4 lines
The main snag is
NR_FILE_DIRTYandNR_WRITEBACKinshould_reclaim_retry. It currently is a random number generator if it reads a zone stat instead of the node one. In some configurations, it even reads values after the stats array.
OK, I haven't spotted that. As I've said I haven't seen the whole series yet. I have just seen that the counters are there and assumed they are used properly where appropriate.
Signature · 8 lines
Michal Hocko 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>
Andrew Morton
maintainerQuoted 8 lines · On Thu, 23 Jun 2016 11:26:48 +0100 Mel Gorman <[email protected]>…
Quoted 3 lines · Mel Gorman
The bulk of the updates are in response to review from Vlastimil Babka and received a lot more testing than v6.
Hi Andrew,
Please drop these patches again from mmotm.
Done. Silently, to avoid wearing out various inboxes.
--
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 348 lines · Mel Gorman
(sorry for resend, the previous attempt didn't go through fully for some reason)
The bulk of the updates are in response to review from Vlastimil Babka and received a lot more testing than v6.
Changelog since v6
o Correctreclaim_idxwhen direct reclaiming for memcg
o Also account LRU pages per zone for compaction/reclaim
o Addpage_pgdathelper with more efficient lookup
o Init pgdat LRU lock only once
o Slight optimisation towake_all_kswapds
o Always wake kcompactd when kswapd is going to sleep
o Rebase to mmotm as of June 15th, 2016Changelog since v5
o Rebase and adjust to changesChangelog since v4
o Rebase on top of v3 of page allocator optimisation seriesChangelog since v3
o Rebase on top of the page allocator optimisation series
o Remove RFC tagThis is the latest version of a series that moves LRUs from the zones to the node that is based upon 4.6-rc3 plus the page allocator optimisation series. Conceptually, this is simple but there are a lot of details. Some of the broad motivations for this are;
1. 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.
2. Currently, reclaim on node 0 behaves slightly different to node 1. For example, direct reclaim scans in zonelist order and reclaims even if the zone is over the high watermark regardless of the age of pages in that LRU. Kswapd on the other hand starts reclaim on the highest unbalanced zone. A difference in distribution of file/anon pages due to when they were allocated results can result in a difference in again. While the fair zone allocation policy mitigates some of the problems here, the page reclaim results on a multi-zone node will always be different to a single-zone node.
it was scheduled on as a result.3. kswapd and the page allocator scan zones in the opposite order to avoid interfering with each other but it's sensitive to timing. This mitigates the page allocator using pages that were allocated very recently in the ideal case but it's sensitive to timing. When kswapd is allocating from lower zones then it's great but during the rebalancing of the highest zone, the page allocator and kswapd interfere with each other. It's worse if the highest zone is small and difficult to balance.
4. slab shrinkers are node-based which makes it harder to identify the exact relationship between slab reclaim and LRU reclaim.
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.
The series has been tested on a 16 core UMA machine and a 2-socket 48 core NUMA machine. The UMA results are presented in most cases as the NUMA machine behaved similarly.
pagealloc
---------This is a microbenchmark that shows the benefit of removing the fair zone allocation policy. It was tested uip to order-4 but only orders 0 and 1 are shown as the other orders were comparable.
4.7.0-rc3 4.7.0-rc3 mmotm-20160615 nodelru-v7r17 Min total-odr0-1 485.00 ( 0.00%) 462.00 ( 4.74%) Min total-odr0-2 354.00 ( 0.00%) 341.00 ( 3.67%) Min total-odr0-4 285.00 ( 0.00%) 277.00 ( 2.81%) Min total-odr0-8 249.00 ( 0.00%) 240.00 ( 3.61%) Min total-odr0-16 230.00 ( 0.00%) 224.00 ( 2.61%) Min total-odr0-32 222.00 ( 0.00%) 215.00 ( 3.15%) Min total-odr0-64 216.00 ( 0.00%) 210.00 ( 2.78%) Min total-odr0-128 214.00 ( 0.00%) 208.00 ( 2.80%) Min total-odr0-256 248.00 ( 0.00%) 233.00 ( 6.05%) Min total-odr0-512 277.00 ( 0.00%) 270.00 ( 2.53%) Min total-odr0-1024 294.00 ( 0.00%) 284.00 ( 3.40%) Min total-odr0-2048 308.00 ( 0.00%) 298.00 ( 3.25%) Min total-odr0-4096 318.00 ( 0.00%) 307.00 ( 3.46%) Min total-odr0-8192 322.00 ( 0.00%) 308.00 ( 4.35%) Min total-odr0-16384 324.00 ( 0.00%) 309.00 ( 4.63%) Min total-odr1-1 729.00 ( 0.00%) 686.00 ( 5.90%) Min total-odr1-2 533.00 ( 0.00%) 520.00 ( 2.44%) Min total-odr1-4 434.00 ( 0.00%) 415.00 ( 4.38%) Min total-odr1-8 390.00 ( 0.00%) 364.00 ( 6.67%) Min total-odr1-16 359.00 ( 0.00%) 335.00 ( 6.69%) Min total-odr1-32 356.00 ( 0.00%) 327.00 ( 8.15%) Min total-odr1-64 356.00 ( 0.00%) 321.00 ( 9.83%) Min total-odr1-128 356.00 ( 0.00%) 333.00 ( 6.46%) Min total-odr1-256 354.00 ( 0.00%) 337.00 ( 4.80%) Min total-odr1-512 366.00 ( 0.00%) 340.00 ( 7.10%) Min total-odr1-1024 373.00 ( 0.00%) 354.00 ( 5.09%) Min total-odr1-2048 375.00 ( 0.00%) 354.00 ( 5.60%) Min total-odr1-4096 374.00 ( 0.00%) 354.00 ( 5.35%) Min total-odr1-8192 370.00 ( 0.00%) 355.00 ( 4.05%)This shows a steady improvement throughout. The primary benefit is from reduced system CPU usage which is obvious from the overall times;
4.7.0-rc3 4.7.0-rc3 mmotm-20160615 nodelru-v7 User 174.06 174.58 System 2656.78 2485.21 Elapsed 2885.07 2713.67The vmstats also showed that the fair zone allocation policy was definitely removed as can be seen here;
4.7.0-rc3 4.7.0-rc3 mmotm-20160615nodelru-v7r17DMA32 allocs 28794408561 0
Normal allocs 48431969998 77226313470
Movable allocs 0 0tiobench on ext4
----------------tiobench is a benchmark that artifically benefits if old pages remain resident while new pages get reclaimed. The fair zone allocation policy mitigates this problem so pages age fairly. While the benchmark has problems, it is important that tiobench performance remains constant as it implies that page aging problems that the fair zone allocation policy fixes are not re-introduced.
4.7.0-rc3 4.7.0-rc3 mmotm-20160615 nodelru-v7r17 Min PotentialReadSpeed 90.24 ( 0.00%) 90.14 ( -0.11%) Min SeqRead-MB/sec-1 80.63 ( 0.00%) 83.09 ( 3.05%) Min SeqRead-MB/sec-2 71.91 ( 0.00%) 72.44 ( 0.74%) Min SeqRead-MB/sec-4 75.20 ( 0.00%) 74.32 ( -1.17%) Min SeqRead-MB/sec-8 65.30 ( 0.00%) 65.21 ( -0.14%) Min SeqRead-MB/sec-16 62.62 ( 0.00%) 62.12 ( -0.80%) Min RandRead-MB/sec-1 0.90 ( 0.00%) 0.94 ( 4.44%) Min RandRead-MB/sec-2 0.96 ( 0.00%) 0.97 ( 1.04%) Min RandRead-MB/sec-4 1.43 ( 0.00%) 1.41 ( -1.40%) Min RandRead-MB/sec-8 1.67 ( 0.00%) 1.72 ( 2.99%) Min RandRead-MB/sec-16 1.77 ( 0.00%) 1.86 ( 5.08%) Min SeqWrite-MB/sec-1 78.12 ( 0.00%) 79.78 ( 2.12%) Min SeqWrite-MB/sec-2 72.74 ( 0.00%) 73.23 ( 0.67%) Min SeqWrite-MB/sec-4 79.40 ( 0.00%) 78.32 ( -1.36%) Min SeqWrite-MB/sec-8 73.18 ( 0.00%) 71.40 ( -2.43%) Min SeqWrite-MB/sec-16 75.82 ( 0.00%) 75.24 ( -0.76%) Min RandWrite-MB/sec-1 1.18 ( 0.00%) 1.15 ( -2.54%) Min RandWrite-MB/sec-2 1.05 ( 0.00%) 0.99 ( -5.71%) Min RandWrite-MB/sec-4 1.00 ( 0.00%) 0.96 ( -4.00%) Min RandWrite-MB/sec-8 0.91 ( 0.00%) 0.92 ( 1.10%) Min RandWrite-MB/sec-16 0.92 ( 0.00%) 0.92 ( 0.00%)This shows that the series has little or not impact on tiobench which is desirable. It indicates that the fair zone allocation policy was removed in a manner that didn't reintroduce one class of page aging bug. There were only minor differences in overall reclaim activity
4.7.0-rc3 4.7.0-rc3 mmotm-20160615nodelru-v7r17 Minor Faults 640992 640721 Major Faults 728 623 Swap Ins 0 0 Swap Outs 0 0 DMA allocs 0 0 DMA32 allocs 46174282 44219717 Normal allocs 77949344 79858024 Movable allocs 0 0 Allocation stalls 38 76 Direct pages scanned 17463 34865 Kswapd pages scanned 93331163 93302388 Kswapd pages reclaimed 93328173 93299677Direct pages reclaimed 17463 34865
Kswapd efficiency 99% 99%
Kswapd velocity 13729.855 13755.612
Direct efficiency 100% 100%
Direct velocity 2.569 5.140
Percentage direct scans 0% 0%Page writes by reclaim 0 0 Page writes file 0 0 Page writes anon 0 0Page reclaim immediate 54 36
kswapd activity was roughly comparable. There was slight differences in direct reclaim activity but negligible in the context of the overall workload (velocity of 5 pages per second with the patches applied, 2 pages per second in the baseline kernel).
pgbench read-only large configuration on ext4
---------------------------------------------pgbench is a database benchmark that can be sensitive to page reclaim decisions. This also checks if removing the fair zone allocation policy is safe
pgbench Transactions
4.7.0-rc3 4.7.0-rc3 mmotm-20160615 nodelru-v7r17 Hmean 1 191.00 ( 0.00%) 193.67 ( 1.40%) Hmean 5 338.59 ( 0.00%) 336.99 ( -0.47%) Hmean 12 374.03 ( 0.00%) 386.15 ( 3.24%) Hmean 21 372.24 ( 0.00%) 372.02 ( -0.06%) Hmean 30 383.98 ( 0.00%) 370.69 ( -3.46%) Hmean 32 431.01 ( 0.00%) 438.47 ( 1.73%)Negligible differences again. As with tiobench, overall reclaim activity was comparable.
bonnie++ on ext4
----------------No interesting performance difference, negligible differences on reclaim stats.
paralleldd on ext4
------------------This workload uses varying numbers of dd instances to read large amounts of data from disk.
paralleldd
4.7.0-rc3 4.7.0-rc3 mmotm-20160615 nodelru-v7r17 Amean Elapsd-1 181.57 ( 0.00%) 179.63 ( 1.07%) Amean Elapsd-3 188.29 ( 0.00%) 183.68 ( 2.45%) Amean Elapsd-5 188.02 ( 0.00%) 181.73 ( 3.35%) Amean Elapsd-7 186.07 ( 0.00%) 184.11 ( 1.05%) Amean Elapsd-12 188.16 ( 0.00%) 183.51 ( 2.47%) Amean Elapsd-16 189.03 ( 0.00%) 181.27 ( 4.10%)4.7.0-rc3 4.7.0-rc3 mmotm-20160615nodelru-v7r17 User 1439.23 1433.37 System 8332.31 8216.01 Elapsed 3619.80 3532.69There is a slight gain in performance, some of which is from the reduced system CPU usage. There areminor differences in reclaim activity but nothing significant
4.7.0-rc3 4.7.0-rc3 mmotm-20160615nodelru-v7r17Minor Faults 362486 358215
Major Faults 1143 1113
Swap Ins 26 0
Swap Outs 2920 482
DMA allocs 0 0DMA32 allocs 31568814 28598887 Normal allocs 46539922 49514444 Movable allocs 0 0 Allocation stalls 0 0 Direct pages scanned 0 0 Kswapd pages scanned 40886878 40849710 Kswapd pages reclaimed 40869923 40835207Direct pages reclaimed 0 0
Kswapd efficiency 99% 99%
Kswapd velocity 11295.342 11563.344
Direct efficiency 100% 100%
Direct velocity 0.000 0.000
Slabs scanned 131673 126099
Direct inode steals 57 60
Kswapd inode steals 762 18It basically shows that kswapd was active at roughly the same rate in both kernels. There was also comparable slab scanning activity and direct reclaim was avoided in both cases. There appears to be a large difference in numbers of inodes reclaimed but the workload has few active inodes and is likely a timing artifact. It's interesting to note that the node-lru did not swap in any pages but given the low swap activity, it's unlikely to be significant.
stutter
-------stutter simulates a simple workload. One part uses a lot of anonymous memory, a second measures mmap latency and a third copies a large file. The primary metric is checking for mmap latency.
stutter
4.7.0-rc3 4.7.0-rc3 mmotm-20160615 nodelru-v7r17 Min mmap 16.8422 ( 0.00%) 15.9821 ( 5.11%) 1st-qrtle mmap 57.8709 ( 0.00%) 58.0794 ( -0.36%) 2nd-qrtle mmap 58.4335 ( 0.00%) 59.4286 ( -1.70%) 3rd-qrtle mmap 58.6957 ( 0.00%) 59.6862 ( -1.69%) Max-90% mmap 58.9388 ( 0.00%) 59.8759 ( -1.59%) Max-93% mmap 59.0505 ( 0.00%) 59.9333 ( -1.50%) Max-95% mmap 59.1877 ( 0.00%) 59.9844 ( -1.35%) Max-99% mmap 60.3237 ( 0.00%) 60.2337 ( 0.15%) Max mmap 285.6454 ( 0.00%) 135.6006 ( 52.53%) Mean mmap 57.8366 ( 0.00%) 58.4884 ( -1.13%)This shows that there is a slight impact on mmap latency but that the worst-case outlier is much improved. As the problem with this benchmark used to be that the kernel stalled for minutes, this difference is negligible.
Some of the vmstats are interesting
4.7.0-rc3 4.7.0-rc3 mmotm-20160615nodelru-v7r17 Swap Ins 58 42 Swap Outs 0 0 Allocation stalls 16 0 Direct pages scanned 1374 0 Kswapd pages scanned 42454910 41782544 Kswapd pages reclaimed 41571035 41781833Direct pages reclaimed 1167 0
Kswapd efficiency 97% 99%
Kswapd velocity 14774.479 14223.796
Direct efficiency 84% 100%
Direct velocity 0.478 0.000
Percentage direct scans 0% 0%Page writes by reclaim 696918 0 Page writes file 696918 0 Page writes anon 0 0 Page reclaim immediate 2940 137 Sector Reads 81644424 81699544 Sector Writes 99193620 98862160Page rescued immediate 0 0
Slabs scanned 1279838 22640kswapd and direct reclaim activity are similar but the node LRU series did not attempt to trigger any page writes from reclaim context.
This series is not without its hazards. There are at least three areas that I'm concerned with even though I could not reproduce any problems in that area.
1. Reclaim/compaction is going to be affected because the amount of reclaim is no longer targetted at a specific zone. Compaction works on a per-zone basis so there is no guarantee that reclaiming a few THP's worth page pages will have a positive impact on compaction success rates.
2. The Slab/LRU reclaim ratio is affected because the frequency the shrinkers are called is now different. This may or may not be a problem but if it is, it'll be because shrinkers are not called enough and some balancing is required.
Quoted 5 lines
3. The anon/file reclaim ratio may be affected. Pages about to be dirtied are distributed between zones and the fair zone allocation policy used to do something very similar for anon. The distribution is now different but not necessarily in any way that matters but it's still worth bearing in mind.
Sorry, I am late in reading the thread and the patches, but I am trying to understand the key benefits? Is it simplification and consistency of the mm subsystem? I know that zones have grown to be overloaded to mean many things now. What is the contention impact of moving the LRU from zone to nodes? Your benchmark shows almost no impact with the micro benchmarks
Balbir Singh
--
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 24 lines · Balbir Singh
Quoted 24 lines
1. 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.
2. Currently, reclaim on node 0 behaves slightly different to node 1. For example, direct reclaim scans in zonelist order and reclaims even if the zone is over the high watermark regardless of the age of pages in that LRU. Kswapd on the other hand starts reclaim on the highest unbalanced zone. A difference in distribution of file/anon pages due to when they were allocated results can result in a difference in again. While the fair zone allocation policy mitigates some of the problems here, the page reclaim results on a multi-zone node will always be different to a single-zone node.
it was scheduled on as a result.3. kswapd and the page allocator scan zones in the opposite order to avoid interfering with each other but it's sensitive to timing. This mitigates the page allocator using pages that were allocated very recently in the ideal case but it's sensitive to timing. When kswapd is allocating from lower zones then it's great but during the rebalancing of the highest zone, the page allocator and kswapd interfere with each other. It's worse if the highest zone is small and difficult to balance.
Quoted 6 lines
Quoted 3 lines
4. slab shrinkers are node-based which makes it harder to identify the exact relationship between slab reclaim and LRU reclaim.
Sorry, I am late in reading the thread and the patches, but I am trying to understand the key benefits?
The key benefits were outlined at the beginning of the changelog. The one that is missing is the large overhead from the fair zone allocation policy which can be removed safely by the feature. The benefit to page allocator micro-benchmarks is outlined in the series introduction.
Quoted 3 lines
I know that
zones have grown to be overloaded to mean many things now. What is the contention impact of moving the LRU from zone to nodes?
Expected to be minimal. On NUMA machines, most nodes have only one zone. On machines with multiple zones, the lock per zone is not that fine-grained given the size of the zones on large memory configurations.
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>
Quoted 29 lines · Mel Gorman
Quoted 28 lines · Balbir Singh
Quoted 27 lines
1. 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.
2. Currently, reclaim on node 0 behaves slightly different to node 1. For example, direct reclaim scans in zonelist order and reclaims even if the zone is over the high watermark regardless of the age of pages in that LRU. Kswapd on the other hand starts reclaim on the highest unbalanced zone. A difference in distribution of file/anon pages due to when they were allocated results can result in a difference in again. While the fair zone allocation policy mitigates some of the problems here, the page reclaim results on a multi-zone node will always be different to a single-zone node.
it was scheduled on as a result.3. kswapd and the page allocator scan zones in the opposite order to avoid interfering with each other but it's sensitive to timing. This mitigates the page allocator using pages that were allocated very recently in the ideal case but it's sensitive to timing. When kswapd is allocating from lower zones then it's great but during the rebalancing of the highest zone, the page allocator and kswapd interfere with each other. It's worse if the highest zone is small and difficult to balance.
4. slab shrinkers are node-based which makes it harder to identify the exact relationship between slab reclaim and LRU reclaim.
Quoted 7 lines
Quoted 2 lines
Sorry, I am late in reading the thread and the patches, but I am trying to understand the key benefits?
The key benefits were outlined at the beginning of the changelog. The one that is missing is the large overhead from the fair zone allocation policy which can be removed safely by the feature. The benefit to page allocator micro-benchmarks is outlined in the series introduction.
I did look at them, but between 1 to 4, it seemed like the largest benefit was mm cleanup and better behaviour of reclaim on node 0.
Quoted 9 lines
Quoted 4 lines
I know that
zones have grown to be overloaded to mean many things now. What is the contention impact of moving the LRU from zone to nodes?Expected to be minimal. On NUMA machines, most nodes have only one zone. On machines with multiple zones, the lock per zone is not that fine-grained given the size of the zones on large memory configurations.
Makes sense
Thanks,
Balbir Singh.
--
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>