Move LRU page reclaim from zones to nodes v9
Subsystems (29)
cover Move LRU page reclaim from zones to nodes v9
Minor changes this time
Changelog since v8
o Cosmetic cleanups to comments
o Calculate node vmstat threshold based on the largest zone in the node
o Align retry checks with decisions made by the OOM killer
o Avoid tricks with -1 and kswapd_classzone_idx
o More consistent handling of buffer_heads_over_limit
Changelog since v7
o Rebase onto current mmots
o Avoid double accounting of stats in node and zone
o Kswapd will avoid more reclaim if an eligible zone is available
o Remove some duplications of sc->reclaim_idx and classzone_idx
o Print per-node stats in zoneinfo
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.7-rc4 with Andrew's tree applied. While this is a current rebase, the test results were based on mmotm as of June 23rd. Conceptually, this series 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-rc4 4.7.0-rc4
mmotm-20160623 nodelru-v9
Min total-odr0-1 490.00 ( 0.00%) 457.00 ( 6.73%)
Min total-odr0-2 347.00 ( 0.00%) 329.00 ( 5.19%)
Min total-odr0-4 288.00 ( 0.00%) 273.00 ( 5.21%)
Min total-odr0-8 251.00 ( 0.00%) 239.00 ( 4.78%)
Min total-odr0-16 234.00 ( 0.00%) 222.00 ( 5.13%)
Min total-odr0-32 223.00 ( 0.00%) 211.00 ( 5.38%)
Min total-odr0-64 217.00 ( 0.00%) 208.00 ( 4.15%)
Min total-odr0-128 214.00 ( 0.00%) 204.00 ( 4.67%)
Min total-odr0-256 250.00 ( 0.00%) 230.00 ( 8.00%)
Min total-odr0-512 271.00 ( 0.00%) 269.00 ( 0.74%)
Min total-odr0-1024 291.00 ( 0.00%) 282.00 ( 3.09%)
Min total-odr0-2048 303.00 ( 0.00%) 296.00 ( 2.31%)
Min total-odr0-4096 311.00 ( 0.00%) 309.00 ( 0.64%)
Min total-odr0-8192 316.00 ( 0.00%) 314.00 ( 0.63%)
Min total-odr0-16384 317.00 ( 0.00%) 315.00 ( 0.63%)
Min total-odr1-1 742.00 ( 0.00%) 712.00 ( 4.04%)
Min total-odr1-2 562.00 ( 0.00%) 530.00 ( 5.69%)
Min total-odr1-4 457.00 ( 0.00%) 433.00 ( 5.25%)
Min total-odr1-8 411.00 ( 0.00%) 381.00 ( 7.30%)
Min total-odr1-16 381.00 ( 0.00%) 356.00 ( 6.56%)
Min total-odr1-32 372.00 ( 0.00%) 346.00 ( 6.99%)
Min total-odr1-64 372.00 ( 0.00%) 343.00 ( 7.80%)
Min total-odr1-128 375.00 ( 0.00%) 351.00 ( 6.40%)
Min total-odr1-256 379.00 ( 0.00%) 351.00 ( 7.39%)
Min total-odr1-512 385.00 ( 0.00%) 355.00 ( 7.79%)
Min total-odr1-1024 386.00 ( 0.00%) 358.00 ( 7.25%)
Min total-odr1-2048 390.00 ( 0.00%) 362.00 ( 7.18%)
Min total-odr1-4096 390.00 ( 0.00%) 362.00 ( 7.18%)
Min total-odr1-8192 388.00 ( 0.00%) 363.00 ( 6.44%)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-rc4 4.7.0-rc4
mmotm-20160623nodelru-v8
User 189.19 191.80
System 2604.45 2533.56
Elapsed 2855.30 2786.39The 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-20160623 nodelru-v8DMA32 allocs 28794729769 0
Normal allocs 48432501431 77227309877
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-rc4 4.7.0-rc4
mmotm-20160623 nodelru-v9
Min PotentialReadSpeed 89.65 ( 0.00%) 90.21 ( 0.62%)
Min SeqRead-MB/sec-1 82.68 ( 0.00%) 82.01 ( -0.81%)
Min SeqRead-MB/sec-2 72.76 ( 0.00%) 72.07 ( -0.95%)
Min SeqRead-MB/sec-4 75.13 ( 0.00%) 74.92 ( -0.28%)
Min SeqRead-MB/sec-8 64.91 ( 0.00%) 65.19 ( 0.43%)
Min SeqRead-MB/sec-16 62.24 ( 0.00%) 62.22 ( -0.03%)
Min RandRead-MB/sec-1 0.88 ( 0.00%) 0.88 ( 0.00%)
Min RandRead-MB/sec-2 0.95 ( 0.00%) 0.92 ( -3.16%)
Min RandRead-MB/sec-4 1.43 ( 0.00%) 1.34 ( -6.29%)
Min RandRead-MB/sec-8 1.61 ( 0.00%) 1.60 ( -0.62%)
Min RandRead-MB/sec-16 1.80 ( 0.00%) 1.90 ( 5.56%)
Min SeqWrite-MB/sec-1 76.41 ( 0.00%) 76.85 ( 0.58%)
Min SeqWrite-MB/sec-2 74.11 ( 0.00%) 73.54 ( -0.77%)
Min SeqWrite-MB/sec-4 80.05 ( 0.00%) 80.13 ( 0.10%)
Min SeqWrite-MB/sec-8 72.88 ( 0.00%) 73.20 ( 0.44%)
Min SeqWrite-MB/sec-16 75.91 ( 0.00%) 76.44 ( 0.70%)
Min RandWrite-MB/sec-1 1.18 ( 0.00%) 1.14 ( -3.39%)
Min RandWrite-MB/sec-2 1.02 ( 0.00%) 1.03 ( 0.98%)
Min RandWrite-MB/sec-4 1.05 ( 0.00%) 0.98 ( -6.67%)
Min RandWrite-MB/sec-8 0.89 ( 0.00%) 0.92 ( 3.37%)
Min RandWrite-MB/sec-16 0.92 ( 0.00%) 0.93 ( 1.09%) 4.7.0-rc4 4.7.0-rc4
mmotm-20160623 approx-v9
User 645.72 525.90
System 403.85 331.75Elapsed 6795.36 6783.67
This shows that the series has little or not impact on tiobench which is desirable and a reduction in system CPU usage. 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-rc4 4.7.0-rc4
mmotm-20160623nodelru-v8
Minor Faults 645838 647465
Major Faults 573 640
Swap Ins 0 0
Swap Outs 0 0
DMA allocs 0 0
DMA32 allocs 46041453 44190646
Normal allocs 78053072 79887245
Movable allocs 0 0
Allocation stalls 24 67
Stall zone DMA 0 0
Stall zone DMA32 0 0
Stall zone Normal 0 2
Stall zone HighMem 0 0
Stall zone Movable 0 65
Direct pages scanned 10969 30609
Kswapd pages scanned 93375144 93492094
Kswapd pages reclaimed 93372243 93489370Direct pages reclaimed 10969 30609
Kswapd efficiency 99% 99%
Kswapd velocity 13741.015 13781.934
Direct efficiency 100% 100%
Direct velocity 1.614 4.512
Percentage direct scans 0% 0%
kswapd activity was roughly comparable. There were differences in direct reclaim activity but negligible in the context of the overall workload (velocity of 4 pages per second with the patches applied, 1.6 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-rc4 4.7.0-rc4
mmotm-20160623 nodelru-v8
Hmean 1 188.26 ( 0.00%) 189.78 ( 0.81%)
Hmean 5 330.66 ( 0.00%) 328.69 ( -0.59%)
Hmean 12 370.32 ( 0.00%) 380.72 ( 2.81%)
Hmean 21 368.89 ( 0.00%) 369.00 ( 0.03%)
Hmean 30 382.14 ( 0.00%) 360.89 ( -5.56%)
Hmean 32 428.87 ( 0.00%) 432.96 ( 0.95%)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.
4.7.0-rc3 4.7.0-rc3
mmotm-20160623 nodelru-v9
Amean Elapsd-1 186.04 ( 0.00%) 189.41 ( -1.82%)
Amean Elapsd-3 192.27 ( 0.00%) 191.38 ( 0.46%)
Amean Elapsd-5 185.21 ( 0.00%) 182.75 ( 1.33%)
Amean Elapsd-7 183.71 ( 0.00%) 182.11 ( 0.87%)
Amean Elapsd-12 180.96 ( 0.00%) 181.58 ( -0.35%)
Amean Elapsd-16 181.36 ( 0.00%) 183.72 ( -1.30%) 4.7.0-rc4 4.7.0-rc4
mmotm-20160623 nodelru-v9
User 1548.01 1552.44
System 8609.71 8515.08
Elapsed 3587.10 3594.54There is little or no change in performance but some drop in system CPU usage.
4.7.0-rc3 4.7.0-rc3
mmotm-20160623 nodelru-v9Minor Faults 362662 367360
Major Faults 1204 1143
Swap Ins 22 0
Swap Outs 2855 1029
DMA allocs 0 0
DMA32 allocs 31409797 28837521 Normal allocs 46611853 49231282 Movable allocs 0 0 Direct pages scanned 0 0 Kswapd pages scanned 40845270 40869088 Kswapd pages reclaimed 40830976 40855294
Direct pages reclaimed 0 0
Kswapd efficiency 99% 99%
Kswapd velocity 11386.711 11369.769
Direct efficiency 100% 100%
Direct velocity 0.000 0.000
Percentage direct scans 0% 0%
Page writes by reclaim 2855 1029
Page writes file 0 0
Page writes anon 2855 1029
Page reclaim immediate 771 1628
Sector Reads 293312636 293536360
Sector Writes 18213568 18186480
Page rescued immediate 0 0
Slabs scanned 128257 132747
Direct inode steals 181 56
Kswapd inode steals 59 1131
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.
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-rc4 4.7.0-rc4
mmotm-20160623 nodelru-v8
Min mmap 16.6283 ( 0.00%) 13.4258 ( 19.26%)
1st-qrtle mmap 54.7570 ( 0.00%) 34.9121 ( 36.24%)
2nd-qrtle mmap 57.3163 ( 0.00%) 46.1147 ( 19.54%)
3rd-qrtle mmap 58.9976 ( 0.00%) 47.1882 ( 20.02%)
Max-90% mmap 59.7433 ( 0.00%) 47.4453 ( 20.58%)
Max-93% mmap 60.1298 ( 0.00%) 47.6037 ( 20.83%)
Max-95% mmap 73.4112 ( 0.00%) 82.8719 (-12.89%)
Max-99% mmap 92.8542 ( 0.00%) 88.8870 ( 4.27%)
Max mmap 1440.6569 ( 0.00%) 121.4201 ( 91.57%)
Mean mmap 59.3493 ( 0.00%) 42.2991 ( 28.73%)
Best99%Mean mmap 57.2121 ( 0.00%) 41.8207 ( 26.90%)
Best95%Mean mmap 55.9113 ( 0.00%) 39.9620 ( 28.53%)
Best90%Mean mmap 55.6199 ( 0.00%) 39.3124 ( 29.32%)
Best50%Mean mmap 53.2183 ( 0.00%) 33.1307 ( 37.75%)
Best10%Mean mmap 45.9842 ( 0.00%) 20.4040 ( 55.63%)
Best5%Mean mmap 43.2256 ( 0.00%) 17.9654 ( 58.44%)
Best1%Mean mmap 32.9388 ( 0.00%) 16.6875 ( 49.34%)This shows a number of improvements with the worst-case outlier greatly improved.
Some of the vmstats are interesting
4.7.0-rc4 4.7.0-rc4
mmotm-20160623nodelru-v8
Swap Ins 163 502
Swap Outs 0 0
DMA allocs 0 0
DMA32 allocs 618719206 1381662383
Normal allocs 891235743 564138421
Movable allocs 0 0
Allocation stalls 2603 1
Direct pages scanned 216787 2
Kswapd pages scanned 50719775 41778378
Kswapd pages reclaimed 41541765 41777639Direct pages reclaimed 209159 0
Kswapd efficiency 81% 99%
Kswapd velocity 16859.554 14329.059
Direct efficiency 96% 0%
Direct velocity 72.061 0.001
Percentage direct scans 0% 0%
Page writes by reclaim 6215049 0 Page writes file 6215049 0 Page writes anon 0 0
Page reclaim immediate 70673 90
Sector Reads 81940800 81680456
Sector Writes 100158984 98816036
Page rescued immediate 0 0
Slabs scanned 1366954 22683
While this is not guaranteed in all cases, this particular test showed a large reduction in direct reclaim activity. It's also worth noting that no page writes were issued 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 | 77 ++- drivers/staging/android/lowmemorykiller.c | 12 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 6 +- fs/fs-writeback.c | 4 +- fs/fuse/file.c | 8 +- fs/nfs/internal.h | 2 +- fs/nfs/write.c | 2 +- fs/proc/meminfo.c | 20 +- include/linux/backing-dev.h | 2 +- include/linux/memcontrol.h | 63 +- include/linux/mm.h | 5 + include/linux/mm_inline.h | 39 +- include/linux/mm_types.h | 2 +- include/linux/mmzone.h | 161 +++-- include/linux/swap.h | 24 +- 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 | 48 +- mm/filemap.c | 16 +- mm/huge_memory.c | 12 +- mm/internal.h | 11 +- mm/khugepaged.c | 14 +- mm/memcontrol.c | 215 +++---- 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 | 123 ++-- mm/page_alloc.c | 349 +++++----- mm/page_idle.c | 4 +- mm/rmap.c | 26 +- mm/shmem.c | 14 +- mm/swap.c | 64 +- mm/swap_state.c | 4 +- mm/util.c | 4 +- mm/vmscan.c | 893 +++++++++++++------------- mm/vmstat.c | 411 +++++++++--- mm/workingset.c | 54 +- 50 files changed, 1690 insertions(+), 1318 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/34 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 | 76 +++++++------ include/linux/mm.h | 5 + include/linux/mmzone.h | 13 +++ include/linux/vmstat.h | 92 +++++++++++++-- mm/page_alloc.c | 10 +- mm/vmstat.c | 295 +++++++++++++++++++++++++++++++++++++++++++++---- mm/workingset.c | 9 +- 7 files changed, 424 insertions(+), 76 deletions(-)
drivers/base/node.c +41 -35
@@ -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,
@@ -117,31 +117,31 @@ static ssize_t node_read_meminfo(struct device *dev,"Node %d ShmemPmdMapped: %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 (node_page_state (nid,NR_ANON_THPS ) * + nid,K (sum_zone_node_page_state (nid,NR_SLAB_UNRECLAIMABLE )), + nid,K (sum_zone_node_page_state (nid,NR_ANON_THPS ) *HPAGE_PMD_NR ), - nid,K (node_page_state (nid,NR_SHMEM_THPS ) * + nid,K (sum_zone_node_page_state (nid,NR_SHMEM_THPS ) *HPAGE_PMD_NR ), - nid,K (node_page_state (nid,NR_SHMEM_PMDMAPPED ) * + nid,K (sum_zone_node_page_state (nid,NR_SHMEM_PMDMAPPED ) * 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;
@@ -160,12 +160,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);
@@ -173,12 +173,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
@@ -933,6 +933,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
@@ -160,6 +160,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
@@ -267,6 +271,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 {
@@ -695,6 +704,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
@@ -4247,8 +4247,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];
@@ -5373,6 +5373,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); + } }/*
@@ -6078,6 +6083,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 +272 -23
468 lines not on this page · raw message
mm/workingset.c +5 -4
@@ -351,12 +351,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/34 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 | 6 ++--- 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, 75 insertions(+), 69 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.
@@ -496,7 +496,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;/*
@@ -690,6 +689,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 by page reclaim */ +ZONE_PADDING (_pad1_) + spinlock_t lru_lock;#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT /*
@@ -721,6 +723,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
@@ -752,7 +752,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 ;
@@ -813,7 +813,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; }
@@ -836,7 +836,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 ;
@@ -899,7 +899,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);
@@ -927,7 +927,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 +3 -3
@@ -1860,7 +1860,7 @@ static void __split_huge_page(struct page *page, struct list_head *list,spin_unlock (&head->mapping->tree_lock); } -spin_unlock_irqrestore (&page_zone (head)->lru_lock, flags); +spin_unlock_irqrestore (zone_lru_lock (page_zone (head)), flags);unfreeze_page (head);
@@ -2046,7 +2046,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list)lru_add_drain ();/* prevent PageLRU to go away from under us, and freeze lru stats */ -spin_lock_irqsave (&page_zone (head)->lru_lock, flags); +spin_lock_irqsave (zone_lru_lock (page_zone (head)), flags);if (mapping) {void **pslot;
@@ -2089,7 +2089,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list)spin_unlock (&pgdata->split_queue_lock); fail:if (mapping)spin_unlock (&mapping->tree_lock); -spin_unlock_irqrestore (&page_zone (head)->lru_lock, flags); +spin_unlock_irqrestore (zone_lru_lock (page_zone (head)), flags);unfreeze_page (head); ret = -EBUSY ; }
mm/memcontrol.c +3 -3
@@ -2065,7 +2065,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;
@@ -2089,7 +2089,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,
@@ -2389,7 +2389,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
@@ -5947,6 +5947,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;
@@ -6001,10 +6002,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); }
@@ -318,9 +318,9 @@ void activate_page(struct page *page)struct zone *zone =page_zone (page); page =compound_head (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
@@ -448,13 +448,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)); }/**
@@ -744,7 +744,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 ; }
@@ -759,7 +759,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);
@@ -771,11 +771,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);
@@ -790,7 +790,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);
@@ -826,7 +826,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/34 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 active 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.
In the event that there is excessive overhead on 32-bit systems due to the nodes being on LRU then there are two potential solutions
1. Long-term isolation of highmem pages when reclaim is lowmem
When pages are skipped, they are immediately added back onto the LRU list. If lowmem reclaim persisted for long periods of time, the same highmem pages get continually scanned. The idea would be that lowmem keeps those pages on a separate list until a reclaim for highmem pages arrives that splices the highmem pages back onto the LRU. It potentially could be implemented similar to the UNEVICTABLE list.
That would reduce the skip rate with the potential corner case is that highmem pages have to be scanned and reclaimed to free lowmem slab pages.
2. Linear scan lowmem pages if the initial LRU shrink fails
This will break LRU ordering but may be preferable and faster during memory pressure than skipping LRU pages.
--- 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 | 18 +-- include/linux/mm_inline.h | 21 ++- include/linux/mmzone.h | 68 +++++---- 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 | 2 +- mm/internal.h | 2 +- mm/khugepaged.c | 4 +- mm/memcontrol.c | 17 +-- 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 | 68 +++++---- mm/swap.c | 50 +++---- mm/vmscan.c | 226 +++++++++++++++++------------- mm/vmstat.c | 47 ++++--- mm/workingset.c | 4 +- 29 files changed, 386 insertions(+), 300 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 +9 -9
@@ -340,7 +340,7 @@ static inline 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; }
@@ -349,15 +349,15 @@ static inline struct lruvec *mem_cgroup_zone_lruvec(struct zone *zone, out:/* * Since a node can be onlined after the mem_cgroup was created, -* we have to be prepared to initialize lruvec->zone here; +* we have to be prepared to initialize lruvec->pgdat 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; } -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);
@@ -438,7 +438,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);
@@ -613,13 +613,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 +41 -27
141 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
@@ -178,6 +178,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 node_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
@@ -646,8 +646,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 */
@@ -655,12 +655,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 ; }
@@ -856,7 +856,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 +1 -1
@@ -1830,7 +1830,7 @@ static void __split_huge_page(struct page *page, struct list_head *list,pgoff_t end =-1 ;int i; - 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
@@ -78,7 +78,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/khugepaged.c +2 -2
@@ -480,7 +480,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); }
@@ -576,7 +576,7 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, goto out; }/* 0 stands for page_is_file_cache(page) == false */ -inc_zone_page_state (page,NR_ISOLATED_ANON +0 ); +inc_node_page_state (page,NR_ISOLATED_ANON +0 );VM_BUG_ON_PAGE (!PageLocked (page), page);VM_BUG_ON_PAGE (PageLRU (page), page);
mm/memcontrol.c +9 -8
@@ -943,14 +943,14 @@ static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg)* 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; }
@@ -970,8 +970,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; }
@@ -979,6 +979,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
@@ -986,14 +987,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 ;
@@ -2069,7 +2070,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 ;
@@ -2084,7 +2085,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
@@ -1119,7 +1119,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)); }
@@ -1460,7 +1460,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:
@@ -1726,15 +1726,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) +
@@ -1828,7 +1829,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));/*
@@ -1886,7 +1887,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); }
@@ -1979,7 +1980,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;
@@ -2030,7 +2031,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 +37 -31
130 lines not on this page · raw message
mm/swap.c +25 -25
122 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
@@ -355,8 +355,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>
PATCH 4/34 mm, mmzone: clarify the usage of zone padding
In reply to Mel GormanZone padding separates write-intensive fields used by page allocation, compaction and vmstats but the comments are a little misleading and need clarification.
--- include/linux/mmzone.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
include/linux/mmzone.h +4 -3
@@ -477,20 +477,21 @@ struct zone {unsigned long wait_table_hash_nr_entries;unsigned long wait_table_bits; +/* Write-intensive fields used from the page allocator */ ZONE_PADDING (_pad1_) +/* free areas of different sizes */ struct free_area free_area[MAX_ORDER];/* zone flags, see below */ unsigned long flags; -/* Write-intensive fields used from the page allocator */ +/* Primarily protects free_area */ spinlock_t lock; +/* Write-intensive fields used by compaction and vmstats. */ ZONE_PADDING (_pad2_) -/* Write-intensive fields used by page reclaim */ -/* * When free pages are below this point, additional steps are taken * when reading the number of free pages to avoid per-cpu counter
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 5/34 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 | 79 ++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 24 deletions(-)
mm/vmscan.c +55 -24
@@ -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? */
@@ -1392,6 +1395,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++) {
@@ -1402,6 +1406,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);
@@ -1420,6 +1429,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));
@@ -1589,7 +1607,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
@@ -2401,12 +2419,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;
@@ -2438,7 +2457,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))shrink_slab (sc->gfp_mask,zone_to_nid (zone), memcg, sc->nr_scanned - scanned, lru_pages);
@@ -2469,7 +2488,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))shrink_slab (sc->gfp_mask,zone_to_nid (zone),NULL , sc->nr_scanned - nr_scanned, zone_lru_pages);
@@ -2553,7 +2572,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; -enum zone_type requested_highidx =gfp_zone (sc->gfp_mask); +enum zone_type classzone_idx;/* * If the number of buffer_heads in the machine exceeds the maximum
@@ -2561,17 +2580,23 @@ 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; + sc->reclaim_idx = classzone_idx =gfp_zone (sc->gfp_mask); + }for_each_zone_zonelist_nodemask (zone, z, zonelist, -gfp_zone (sc->gfp_mask), sc->nodemask) { -enum zone_type classzone_idx; - + sc->reclaim_idx, sc->nodemask) {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. +*/ + classzone_idx = sc->reclaim_idx;while (!populated_zone (zone->zone_pgdat->node_zones + classzone_idx)) classzone_idx--;
@@ -2600,8 +2625,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 ; }
@@ -2621,7 +2646,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); }/*
@@ -2847,6 +2872,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 ,
@@ -2886,6 +2912,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 = MAX_NR_ZONES - 1, .may_swap = !noswap, };unsigned long lru_pages;
@@ -2924,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,
@@ -3118,7 +3146,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);
@@ -3167,6 +3195,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,
@@ -3237,15 +3266,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))
@@ -3256,6 +3284,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 ;/*
@@ -3513,6 +3542,7 @@ unsigned long shrink_all_memory(unsigned long nr_to_reclaim)struct scan_control sc = { .nr_to_reclaim = nr_to_reclaim, .gfp_mask =GFP_HIGHUSER_MOVABLE , + .reclaim_idx =MAX_NR_ZONES -1 , .priority =DEF_PRIORITY , .may_writepage =1 , .may_unmap =1 ,
@@ -3704,6 +3734,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 ();
@@ -3723,7 +3754,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>
PATCH 6/34 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
@@ -3209,11 +3209,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 7/34 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
@@ -2980,7 +2980,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;
@@ -2999,85 +3000,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. *
@@ -3086,6 +3017,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;
@@ -3106,101 +3039,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 );
@@ -3211,21 +3133,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
@@ -3233,19 +3144,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);
@@ -3256,51 +3165,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
@@ -3316,20 +3208,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,
@@ -3486,8 +3395,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); } }
@@ -3517,7 +3427,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 8/34 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
@@ -2518,7 +2518,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;/*
@@ -2527,9 +2527,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);/*
@@ -3000,10 +2998,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); }
@@ -3045,7 +3042,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; }
@@ -3148,7 +3145,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 {
@@ -3216,7 +3213,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;
@@ -3427,7 +3424,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 9/34 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 | 101 ++++++++++++++++++++++++------------------------- 4 files changed, 57 insertions(+), 56 deletions(-)
include/linux/mmzone.h +3 -2
@@ -668,8 +668,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
@@ -6084,7 +6084,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 +50 -51
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 10/34 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 | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
mm/vmscan.c +14 -8
@@ -2552,14 +2552,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. */
@@ -2571,6 +2563,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)unsigned long nr_soft_scanned;gfp_t orig_mask;enum zone_type classzone_idx; +pg_data_t *last_pgdat =NULL ;/* * If the number of buffer_heads in the machine exceeds the maximum
@@ -2630,6 +2623,15 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc) }/* +* 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 ; + +/* * This steals pages from memory cgroups over softlimit * and returns the number of reclaimed pages and * scanned pages. This works for global memory pressure
@@ -2644,6 +2646,10 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)/* need some check for avoid more shrink_zone() */ } +/* See comment about same check for global reclaim above */ +if (zone->zone_pgdat == last_pgdat) +continue ; + last_pgdat = zone->zone_pgdat;shrink_node (zone->zone_pgdat, sc, classzone_idx); }
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/34 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
@@ -3008,7 +3008,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; }/*
@@ -3154,13 +3164,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); } }
@@ -3219,11 +3222,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 12/34 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 | 59 +++++++++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 32 deletions(-)
mm/vmscan.c +27 -32
@@ -3144,31 +3144,39 @@ 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 */ -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 the number of buffer_heads in the machine exceeds the +* maximum allowed level then reclaim from all zones. This is +* not specific to highmem as highmem may not exist but it is +* it is expected that buffer_heads are stripped in writeback. +*/ +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 (!zone_balanced (zone, order,0 )) { classzone_idx = i;break ; } } -if (i <0 ) - goto out; +/* +* Only reclaim if there are no eligible zones. Check from +* high to low zone as allocations prefer higher zones. +* Scanning from low to high zone would allow congestion to be +* cleared during a very small window when a small low +* zone was balanced even under extreme pressure when the +* overall node may be congested. +*/ +for (i = classzone_idx; i >=0 ; i--) { + zone = pgdat->node_zones + i; +if (!populated_zone (zone)) +continue ; + +if (zone_balanced (zone, sc.order, classzone_idx)) + goto out; + }/* * Do some background aging of the anon list, to give
@@ -3214,19 +3222,6 @@ 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, classzone_idx)) - goto out; - } - -/* * Raise priority if scanning rate is too low or there was no * progress in reclaiming pages */
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 13/34 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 | 19 ++++++++------- include/linux/mmzone.h | 4 ++-- include/linux/swap.h | 2 +- mm/memcontrol.c | 4 ++-- mm/page_alloc.c | 2 +- mm/vmscan.c | 59 ++++++++++++++++++++++++++-------------------- mm/workingset.c | 6 ++--- 7 files changed, 52 insertions(+), 44 deletions(-)
include/linux/memcontrol.h +10 -9
@@ -325,22 +325,23 @@ mem_cgroup_zone_zoneinfo(struct mem_cgroup *memcg, struct zone *zone) }/** -* 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. */ -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) {struct mem_cgroup_per_zone *mz;struct lruvec *lruvec;if (mem_cgroup_disabled ()) { - lruvec =zone_lruvec (zone); + lruvec =node_lruvec (pgdat); goto out; }
@@ -610,10 +611,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
@@ -739,9 +739,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 +2 -2
@@ -1432,8 +1432,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
@@ -5954,6 +5954,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;
@@ -6016,7 +6017,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 -26
153 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 ();
@@ -319,7 +319,7 @@ void workingset_activation(struct page *page) memcg =page_memcg_rcu (page);if (!mem_cgroup_disabled () && !memcg) goto out; - lruvec =mem_cgroup_zone_lruvec (page_zone (page), memcg); + lruvec =mem_cgroup_lruvec (page_pgdat (page),page_zone (page), memcg);atomic_long_inc (&lruvec->inactive_age); out:rcu_read_unlock ();
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 14/34 mm, memcg: move memcg limit enforcement from zones to nodes
In reply to Mel GormanMemcg needs adjustment after moving LRUs to the node. Limits are tracked per memcg but the soft-limit excess is tracked per zone. As global page reclaim is based on the node, it is easy to imagine a situation where a zone soft limit is exceeded even though the memcg limit is fine.
This patch moves the soft limit tree the node. 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 | 38 ++++----- include/linux/swap.h | 2 +- mm/memcontrol.c | 190 ++++++++++++++++++++------------------------- mm/vmscan.c | 19 +++-- mm/workingset.c | 6 +- 5 files changed, 111 insertions(+), 144 deletions(-)
include/linux/memcontrol.h +15 -23
@@ -61,7 +61,7 @@ enum mem_cgroup_stat_index { };struct mem_cgroup_reclaim_cookie { -struct zone *zone; +pg_data_t *pgdat;int priority;unsigned int generation; };
@@ -119,7 +119,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 ];
@@ -133,10 +133,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;
@@ -315,19 +311,15 @@ void mem_cgroup_uncharge_list(struct list_head *page_list);void mem_cgroup_migrate (struct page *oldpage,struct page *newpage); -static inline 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]; }/** * 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
@@ -335,9 +327,9 @@ mem_cgroup_zone_zoneinfo(struct mem_cgroup *memcg, struct zone *zone)* is disabled. */ static inline 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 ()) {
@@ -345,7 +337,7 @@ static inline 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:/*
@@ -353,8 +345,8 @@ static inline struct lruvec *mem_cgroup_lruvec(struct pglist_data *pgdat,* we have to be prepared to initialize lruvec->pgdat 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; }
@@ -447,9 +439,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]; }
@@ -520,7 +512,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);
@@ -612,7 +604,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); }
@@ -724,7 +716,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 +83 -107
423 lines not on this page · raw message
mm/vmscan.c +9 -10
@@ -2229,8 +2229,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;
@@ -2437,7 +2436,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;
@@ -2645,7 +2644,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;
@@ -2915,7 +2914,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 = {
@@ -2942,7 +2941,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);
@@ -2992,7 +2991,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;
@@ -3001,7 +3000,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,
@@ -3191,7 +3190,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
@@ -3203,7 +3202,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 ();
@@ -319,7 +319,7 @@ void workingset_activation(struct page *page) memcg =page_memcg_rcu (page);if (!mem_cgroup_disabled () && !memcg) goto out; - lruvec =mem_cgroup_lruvec (page_pgdat (page),page_zone (page), memcg); + lruvec =mem_cgroup_lruvec (page_pgdat (page), memcg);atomic_long_inc (&lruvec->inactive_age); out:rcu_read_unlock ();
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/34 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_THPS ,NR_SHMEM_THPS , NR_SHMEM_PMDMAPPED,
@@ -164,6 +161,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
@@ -227,7 +227,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
@@ -446,11 +446,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 );
@@ -539,15 +534,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;
@@ -967,9 +953,6 @@ const char * const vmstat_text[] = {"numa_local" ,"numa_other" , #endif -"workingset_refault" , -"workingset_activate" , -"workingset_nodereclaim" ,"nr_anon_transparent_hugepages" ,"nr_shmem_hugepages" , "nr_shmem_pmdmapped",
@@ -984,6 +967,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 16/34 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 | 91 +++++++++++++++++++++++++++++++---------------- mm/page_alloc.c | 26 ++++++-------- 4 files changed, 79 insertions(+), 52 deletions(-)
include/linux/mmzone.h +6 -6
@@ -363,12 +363,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.
@@ -687,6 +681,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 by page reclaim */ 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 +61 -30
142 lines not on this page · raw message
mm/page_alloc.c +11 -15
@@ -2955,31 +2955,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 ];
@@ -6749,6 +6742,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 ;
@@ -6765,7 +6761,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>
PATCH 17/34 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 | 14 +++++++------- mm/vmscan.c | 2 +- mm/vmstat.c | 4 ++-- 8 files changed, 21 insertions(+), 21 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
@@ -121,8 +121,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
@@ -140,8 +140,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,
@@ -164,6 +161,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
@@ -4355,7 +4355,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),
@@ -4377,6 +4377,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,
@@ -4387,6 +4388,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"); }
@@ -4411,7 +4413,6 @@ void show_free_areas(unsigned int filter)" mlocked:%lukB" " dirty:%lukB" " writeback:%lukB" -" mapped:%lukB" " shmem:%lukB" #ifdef CONFIG_TRANSPARENT_HUGEPAGE" shmem_thp: %lukB"
@@ -4440,7 +4441,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 )), #ifdef CONFIG_TRANSPARENT_HUGEPAGE K(zone_page_state(zone, NR_SHMEM_THPS) * HPAGE_PMD_NR),
mm/rmap.c +7 -7
@@ -1217,7 +1217,7 @@ void do_page_add_anon_rmap(struct page *page,*/ if (compound)__inc_zone_page_state (page,NR_ANON_THPS ); -__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 ;
@@ -1261,7 +1261,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 ); }
@@ -1296,7 +1296,7 @@ void page_add_file_rmap(struct page *page, bool compound)if (!atomic_inc_and_test (&page->_mapcount)) goto out; } -__mod_zone_page_state (page_zone (page),NR_FILE_MAPPED , nr); +__mod_node_page_state (page_pgdat (page),NR_FILE_MAPPED , nr);mem_cgroup_inc_page_stat (page,MEM_CGROUP_STAT_FILE_MAPPED ); out:unlock_page_memcg (page);
@@ -1332,11 +1332,11 @@ static void page_remove_file_rmap(struct page *page, bool compound) }/* -* We use the irq-unsafe __{inc|mod}_zone_page_stat because +* We use the irq-unsafe __{inc|mod}_zone_page_state because * these counters are not modified in interrupt context, and * pte lock(a spinlock) is held, which implies preemption disabled. */ -__mod_zone_page_state (page_zone (page),NR_FILE_MAPPED , -nr); +__mod_node_page_state (page_pgdat (page),NR_FILE_MAPPED , -nr);mem_cgroup_dec_page_stat (page,MEM_CGROUP_STAT_FILE_MAPPED );if (unlikely (PageMlocked (page)))
@@ -1378,7 +1378,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); } }
@@ -1407,7 +1407,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
@@ -3587,7 +3587,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
@@ -925,8 +925,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",
@@ -970,6 +968,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>
PATCH 18/34 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
@@ -122,7 +122,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
@@ -140,7 +140,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
@@ -161,7 +161,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
@@ -1217,7 +1217,7 @@ void do_page_add_anon_rmap(struct page *page,*/ if (compound)__inc_zone_page_state (page,NR_ANON_THPS ); -__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 ;
@@ -1261,7 +1261,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 ); }
@@ -1378,7 +1378,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); } }
@@ -1407,7 +1407,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>
PATCH 19/34 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. Due to throttling logic in the page allocator for reliable OOM detection, it is still necessary to track dirty and writeback pages on a per-zone basis.
--- arch/s390/appldata/appldata_mem.c | 2 +- arch/tile/mm/pgtable.c | 8 +-- drivers/base/node.c | 16 +++--- drivers/staging/android/lowmemorykiller.c | 4 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 6 ++- fs/fs-writeback.c | 4 +- fs/fuse/file.c | 8 +-- fs/nfs/internal.h | 2 +- fs/nfs/write.c | 2 +- fs/proc/meminfo.c | 16 +++--- include/linux/mmzone.h | 19 +++---- include/trace/events/writeback.h | 6 +-- mm/filemap.c | 12 ++--- mm/huge_memory.c | 4 +- mm/khugepaged.c | 6 +-- mm/migrate.c | 14 ++--- mm/page-writeback.c | 47 ++++++++--------- mm/page_alloc.c | 74 ++++++++++++--------------- mm/rmap.c | 10 ++-- mm/shmem.c | 14 ++--- mm/swap_state.c | 4 +- mm/util.c | 4 +- mm/vmscan.c | 16 +++--- mm/vmstat.c | 19 +++---- 24 files changed, 155 insertions(+), 162 deletions(-)
arch/s390/appldata/appldata_mem.c +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 +8 -8
@@ -118,28 +118,28 @@ static ssize_t node_read_meminfo(struct device *dev,"Node %d ShmemPmdMapped: %8lu kB\n" #endif , - nid,K (sum_zone_node_page_state (nid,NR_FILE_DIRTY )), - nid,K (sum_zone_node_page_state (nid,NR_WRITEBACK )), - nid,K (sum_zone_node_page_state (nid,NR_FILE_PAGES )), + nid,K (node_page_state (pgdat,NR_FILE_DIRTY )), + nid,K (node_page_state (pgdat,NR_WRITEBACK )), + nid,K (node_page_state (pgdat,NR_FILE_PAGES )), nid,K (node_page_state (pgdat,NR_FILE_MAPPED )), nid,K (node_page_state (pgdat,NR_ANON_MAPPED )), nid,K (i.sharedram), nid,sum_zone_node_page_state (nid,NR_KERNEL_STACK ) *THREAD_SIZE /1024 , nid,K (sum_zone_node_page_state (nid,NR_PAGETABLE )), - nid,K (sum_zone_node_page_state (nid,NR_UNSTABLE_NFS )), + nid,K (node_page_state (pgdat,NR_UNSTABLE_NFS )), nid,K (sum_zone_node_page_state (nid,NR_BOUNCE )), - nid,K (sum_zone_node_page_state (nid,NR_WRITEBACK_TEMP )), + nid,K (node_page_state (pgdat,NR_WRITEBACK_TEMP )), nid,K (sum_zone_node_page_state (nid,NR_SLAB_RECLAIMABLE ) +sum_zone_node_page_state (nid,NR_SLAB_UNRECLAIMABLE )), nid,K (sum_zone_node_page_state (nid,NR_SLAB_RECLAIMABLE )), #ifdef CONFIG_TRANSPARENT_HUGEPAGE nid,K (sum_zone_node_page_state (nid,NR_SLAB_UNRECLAIMABLE )), - nid,K (sum_zone_node_page_state (nid,NR_ANON_THPS ) * + nid,K (node_page_state (pgdat,NR_ANON_THPS ) *HPAGE_PMD_NR ), - nid,K (sum_zone_node_page_state (nid,NR_SHMEM_THPS ) * + nid,K (node_page_state (pgdat,NR_SHMEM_THPS ) *HPAGE_PMD_NR ), - nid,K (sum_zone_node_page_state (nid,NR_SHMEM_PMDMAPPED ) * + nid,K (node_page_state (pgdat,NR_SHMEM_PMDMAPPED ) * HPAGE_PMD_NR));#else nid, K(sum_zone_node_page_state(nid, NR_SLAB_UNRECLAIMABLE)));
drivers/staging/android/lowmemorykiller.c +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)
drivers/staging/lustre/lustre/osc/osc_cache.c +4 -2
@@ -1864,7 +1864,8 @@ void osc_dec_unstable_pages(struct ptlrpc_request *req)LASSERT (page_count >=0 );for (i =0 ; i < page_count; i++) -dec_zone_page_state (desc->bd_iov[i].kiov_page,NR_UNSTABLE_NFS ); +dec_node_page_state (desc->bd_iov[i].kiov_page, +NR_UNSTABLE_NFS );atomic_sub (page_count, &cli->cl_cache->ccc_unstable_nr);LASSERT (atomic_read (&cli->cl_cache->ccc_unstable_nr) >=0 );
@@ -1898,7 +1899,8 @@ void osc_inc_unstable_pages(struct ptlrpc_request *req)LASSERT (page_count >=0 );for (i =0 ; i < page_count; i++) -inc_zone_page_state (desc->bd_iov[i].kiov_page,NR_UNSTABLE_NFS ); +inc_node_page_state (desc->bd_iov[i].kiov_page, +NR_UNSTABLE_NFS );LASSERT (atomic_read (&cli->cl_cache->ccc_unstable_nr) >=0 );atomic_add (page_count, &cli->cl_cache->ccc_unstable_nr);
fs/fs-writeback.c +2 -2
@@ -1807,8 +1807,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
@@ -1451,7 +1451,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);
@@ -1641,7 +1641,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);
@@ -1755,7 +1755,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);
@@ -1854,7 +1854,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
@@ -655,7 +655,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 +8 -8
@@ -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 ;
@@ -138,8 +138,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),
@@ -152,9 +152,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,
@@ -164,9 +164,9 @@ static int meminfo_proc_show(struct seq_file *m, void *v) , atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)#endif #ifdef CONFIG_TRANSPARENT_HUGEPAGE - , K(global_page_state(NR_ANON_THPS) * HPAGE_PMD_NR) - , K(global_page_state(NR_SHMEM_THPS) * HPAGE_PMD_NR) - , K(global_page_state(NR_SHMEM_PMDMAPPED) * HPAGE_PMD_NR) + , K(global_node_page_state(NR_ANON_THPS) * HPAGE_PMD_NR) + , K(global_node_page_state(NR_SHMEM_THPS) * HPAGE_PMD_NR) + , K(global_node_page_state(NR_SHMEM_PMDMAPPED) * HPAGE_PMD_NR)#endif #ifdef CONFIG_CMA , K(totalcma_pages)
include/linux/mmzone.h +10 -9
@@ -114,21 +114,16 @@ enum zone_stat_item {NR_ZONE_LRU_BASE ,/* Used only for compaction and reclaim retry */ NR_ZONE_LRU_ANON =NR_ZONE_LRU_BASE ,NR_ZONE_LRU_FILE , +NR_ZONE_WRITE_PENDING ,/* Count of dirty, writeback and unstable pages */ NR_MLOCK ,/* mlock()ed pages found and moved off LRU */ -NR_FILE_PAGES , -NR_FILE_DIRTY , -NR_WRITEBACK ,NR_SLAB_RECLAIMABLE ,NR_SLAB_UNRECLAIMABLE ,NR_PAGETABLE ,/* used for pagetables */ NR_KERNEL_STACK ,/* Second 128 byte cacheline */ -NR_UNSTABLE_NFS ,/* NFS unstable pages */ NR_BOUNCE ,NR_VMSCAN_WRITE ,NR_VMSCAN_IMMEDIATE ,/* Prioritise for reclaim when writeback ends */ -NR_WRITEBACK_TEMP ,/* Writeback using temporary buffers */ -NR_SHMEM ,/* shmem pages (included tmpfs/GEM pages) */ NR_DIRTIED ,/* page dirtyings since bootup */ NR_WRITTEN ,/* page writings since bootup */ #if IS_ENABLED(CONFIG_ZSMALLOC)
@@ -142,9 +137,6 @@ enum zone_stat_item {NUMA_LOCAL ,/* allocation from local node */ NUMA_OTHER ,/* allocation from other node */ #endif -NR_ANON_THPS , -NR_SHMEM_THPS , -NR_SHMEM_PMDMAPPED ,NR_FREE_CMA_PAGES , NR_VM_ZONE_STAT_ITEMS };
@@ -164,6 +156,15 @@ enum node_stat_item {NR_ANON_MAPPED ,/* Mapped anonymous pages */ NR_FILE_MAPPED ,/* pagecache pages mapped into pagetables. only modified from process context */ +NR_FILE_PAGES , +NR_FILE_DIRTY , +NR_WRITEBACK , +NR_WRITEBACK_TEMP ,/* Writeback using temporary buffers */ +NR_SHMEM ,/* shmem pages (included tmpfs/GEM pages) */ +NR_SHMEM_THPS , +NR_SHMEM_PMDMAPPED , +NR_ANON_THPS , +NR_UNSTABLE_NFS ,/* NFS unstable pages */ NR_VM_NODE_STAT_ITEMS };
include/trace/events/writeback.h +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 +6 -6
@@ -218,11 +218,11 @@ void __delete_from_page_cache(struct page *page, void *shadow)/* hugetlb pages do not participate in page cache accounting. */ if (!PageHuge (page)) -__mod_zone_page_state (page_zone (page),NR_FILE_PAGES , -nr); +__mod_node_page_state (page_pgdat (page),NR_FILE_PAGES , -nr);if (PageSwapBacked (page)) { -__mod_zone_page_state (page_zone (page),NR_SHMEM , -nr); +__mod_node_page_state (page_pgdat (page),NR_SHMEM , -nr);if (PageTransHuge (page)) -__dec_zone_page_state (page,NR_SHMEM_THPS ); +__dec_node_page_state (page,NR_SHMEM_THPS ); }else {VM_BUG_ON_PAGE (PageTransHuge (page) && !PageHuge (page), page); }
@@ -568,9 +568,9 @@ int replace_page_cache_page(struct page *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 ();
@@ -677,7 +677,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/huge_memory.c +2 -2
@@ -1591,7 +1591,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,if (atomic_add_negative (-1 ,compound_mapcount_ptr (page))) {/* Last compound_mapcount is gone. */ -__dec_zone_page_state (page,NR_ANON_THPS ); +__dec_node_page_state (page,NR_ANON_THPS );if (TestClearPageDoubleMap (page)) {/* No need in mapcount reference anymore */ for (i =0 ; i <HPAGE_PMD_NR ; i++)
@@ -2073,7 +2073,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list)list_del (page_deferred_list (head)); }if (mapping) -__dec_zone_page_state (page,NR_SHMEM_THPS ); +__dec_node_page_state (page,NR_SHMEM_THPS );spin_unlock (&pgdata->split_queue_lock);__split_huge_page (page, list, flags); ret =0 ;
mm/khugepaged.c +3 -3
@@ -1474,10 +1474,10 @@ static void collapse_shmem(struct mm_struct *mm, }local_irq_save (flags); -__inc_zone_page_state (new_page,NR_SHMEM_THPS ); +__inc_node_page_state (new_page,NR_SHMEM_THPS );if (nr_none) { -__mod_zone_page_state (zone,NR_FILE_PAGES , nr_none); -__mod_zone_page_state (zone,NR_SHMEM , nr_none); +__mod_node_page_state (zone->zone_pgdat,NR_FILE_PAGES , nr_none); +__mod_node_page_state (zone->zone_pgdat,NR_SHMEM , nr_none); }local_irq_restore (flags);
mm/migrate.c +8 -6
@@ -505,15 +505,17 @@ 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 ); +__dec_zone_state (oldzone,NR_ZONE_WRITE_PENDING ); +__inc_node_state (newzone->zone_pgdat,NR_FILE_DIRTY ); +__dec_zone_state (newzone,NR_ZONE_WRITE_PENDING ); } }local_irq_enable ();
mm/page-writeback.c +22 -25
111 lines not on this page · raw message
mm/page_alloc.c +32 -42
158 lines not on this page · raw message
mm/rmap.c +5 -5
@@ -1216,7 +1216,7 @@ void do_page_add_anon_rmap(struct page *page,* disabled. */ if (compound) -__inc_zone_page_state (page,NR_ANON_THPS ); +__inc_node_page_state (page,NR_ANON_THPS );__mod_node_page_state (page_pgdat (page),NR_ANON_MAPPED , nr); }if (unlikely (PageKsm (page)))
@@ -1254,7 +1254,7 @@ void page_add_new_anon_rmap(struct page *page,VM_BUG_ON_PAGE (!PageTransHuge (page), page);/* increment count (starts at -1) */ atomic_set (compound_mapcount_ptr (page),0 ); -__inc_zone_page_state (page,NR_ANON_THPS ); +__inc_node_page_state (page,NR_ANON_THPS ); }else {/* Anon THP always mapped first with PMD */ VM_BUG_ON_PAGE (PageTransCompound (page), page);
@@ -1285,7 +1285,7 @@ void page_add_file_rmap(struct page *page, bool compound)if (!atomic_inc_and_test (compound_mapcount_ptr (page))) goto out;VM_BUG_ON_PAGE (!PageSwapBacked (page), page); -__inc_zone_page_state (page,NR_SHMEM_PMDMAPPED ); +__inc_node_page_state (page,NR_SHMEM_PMDMAPPED ); }else {if (PageTransCompound (page)) {VM_BUG_ON_PAGE (!PageLocked (page), page);
@@ -1325,7 +1325,7 @@ static void page_remove_file_rmap(struct page *page, bool compound)if (!atomic_add_negative (-1 ,compound_mapcount_ptr (page))) goto out;VM_BUG_ON_PAGE (!PageSwapBacked (page), page); -__dec_zone_page_state (page,NR_SHMEM_PMDMAPPED ); +__dec_node_page_state (page,NR_SHMEM_PMDMAPPED ); }else {if (!atomic_add_negative (-1 , &page->_mapcount)) goto out;
@@ -1359,7 +1359,7 @@ static void page_remove_anon_compound_rmap(struct page *page)if (!IS_ENABLED (CONFIG_TRANSPARENT_HUGEPAGE ))return ; -__dec_zone_page_state (page,NR_ANON_THPS ); +__dec_node_page_state (page,NR_ANON_THPS );if (TestClearPageDoubleMap (page)) {/*
mm/shmem.c +7 -7
@@ -575,9 +575,9 @@ static int shmem_add_to_page_cache(struct page *page,if (!error) { mapping->nrpages += nr;if (PageTransHuge (page)) -__inc_zone_page_state (page,NR_SHMEM_THPS ); -__mod_zone_page_state (page_zone (page),NR_FILE_PAGES , nr); -__mod_zone_page_state (page_zone (page),NR_SHMEM , nr); +__inc_node_page_state (page,NR_SHMEM_THPS ); +__mod_node_page_state (page_pgdat (page),NR_FILE_PAGES , nr); +__mod_node_page_state (page_pgdat (page),NR_SHMEM , nr);spin_unlock_irq (&mapping->tree_lock); }else { page->mapping =NULL ;
@@ -601,8 +601,8 @@ static void shmem_delete_from_page_cache(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);
@@ -1493,8 +1493,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
@@ -528,7 +528,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
@@ -536,7 +536,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
@@ -3585,11 +3585,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
@@ -3608,17 +3608,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 +10 -9
@@ -924,20 +924,15 @@ const char * const vmstat_text[] = {"nr_alloc_batch" ,"nr_zone_anon_lru" ,"nr_zone_file_lru" , +"nr_zone_write_pending" ,"nr_mlock" , -"nr_file_pages" , -"nr_dirty" , -"nr_writeback" ,"nr_slab_reclaimable" ,"nr_slab_unreclaimable" ,"nr_page_table_pages" ,"nr_kernel_stack" , -"nr_unstable" ,"nr_bounce" ,"nr_vmscan_write" ,"nr_vmscan_immediate_reclaim" , -"nr_writeback_temp" , -"nr_shmem" ,"nr_dirtied" ,"nr_written" , #if IS_ENABLED(CONFIG_ZSMALLOC)
@@ -951,9 +946,6 @@ const char * const vmstat_text[] = {"numa_local" ,"numa_other" , #endif -"nr_anon_transparent_hugepages" , -"nr_shmem_hugepages" , -"nr_shmem_pmdmapped" , "nr_free_cma",/* Node-based counters */
@@ -970,6 +962,15 @@ const char * const vmstat_text[] = {"workingset_nodereclaim" ,"nr_anon_pages" ,"nr_mapped" , +"nr_file_pages" , +"nr_dirty" , +"nr_writeback" , +"nr_writeback_temp" , +"nr_shmem" , +"nr_shmem_hugepages" , +"nr_shmem_pmdmapped" , +"nr_anon_transparent_hugepages" , +"nr_unstable" ,/* enum writeback_stat_item counters */ "nr_dirty_threshold",
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 20/34 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
@@ -122,10 +122,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
@@ -165,6 +161,10 @@ enum node_stat_item {NR_SHMEM_PMDMAPPED ,NR_ANON_THPS ,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
@@ -2461,7 +2461,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_ZONE_WRITE_PENDING ); -__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 );
@@ -2550,7 +2550,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); }
@@ -2787,7 +2787,7 @@ int test_clear_page_writeback(struct page *page)mem_cgroup_dec_page_stat (page,MEM_CGROUP_STAT_WRITEBACK );dec_node_page_state (page,NR_WRITEBACK );dec_zone_page_state (page,NR_ZONE_WRITE_PENDING ); -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 ; }
@@ -1117,7 +1117,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
@@ -931,10 +931,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
@@ -971,6 +967,10 @@ const char * const vmstat_text[] = {"nr_shmem_pmdmapped" ,"nr_anon_transparent_hugepages" ,"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>
PATCH 21/34 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
@@ -3410,10 +3410,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
@@ -3419,6 +3419,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 ;
@@ -3430,8 +3431,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>
PATCH 22/34 mm, page_alloc: wake kswapd based on the highest eligible zone
In reply to Mel GormanThe ac_classzone_idx is used as the basis for waking kswapd and that is based on the preferred zoneref. If the preferred zoneref's first zone is lower than what is available on other nodes, it's possible that kswapd is woken on a zone with only higher, but still eligible, zones. As classzone_idx is strictly adhered to now, it causes a problem because eligible pages are skipped.
For example, node 0 has only DMA32 and node 1 has only NORMAL. An allocating context running on node 0 may wake kswapd on node 1 telling it to skip all NORMAL pages.
--- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
@@ -3415,7 +3415,7 @@ static void wake_all_kswapds(unsigned int order, const struct alloc_context *ac)for_each_zone_zonelist_nodemask (zone, z, ac->zonelist, ac->high_zoneidx, ac->nodemask) {if (last_pgdat != zone->zone_pgdat) -wakeup_kswapd (zone, order,ac_classzone_idx (ac)); +wakeup_kswapd (zone, order, ac->high_zoneidx); last_pgdat = zone->zone_pgdat; } }
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/34 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/internal.h | 8 ++--- mm/khugepaged.c | 4 +-- mm/page_alloc.c | 24 ++++++++++----- mm/vmscan.c | 77 ++++++++++++++++++++++++------------------------ 8 files changed, 77 insertions(+), 69 deletions(-)
include/linux/mmzone.h +9 -9
@@ -372,14 +372,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;
@@ -525,7 +517,6 @@ struct zone { }____cacheline_internodealigned_in_smp ;enum zone_flags { -ZONE_RECLAIM_LOCKED ,/* prevents concurrent reclaim */ ZONE_FAIR_DEPLETED ,/* fair zone policy batch depleted */ };
@@ -540,6 +531,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)
@@ -688,6 +680,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 by page reclaim */ 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
@@ -1498,8 +1498,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/internal.h +4 -4
@@ -433,10 +433,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/khugepaged.c +2 -2
@@ -672,10 +672,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/page_alloc.c +16 -8
@@ -2985,16 +2985,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 :
@@ -5991,9 +5991,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;
@@ -6970,6 +6970,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;
@@ -6977,8 +6978,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 ; }
@@ -6986,6 +6990,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;
@@ -6993,8 +6998,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 24/34 mm, vmscan: avoid passing in classzone_idx unnecessarily to shrink_node
In reply to Mel Gormanshrink_node receives all information it needs about classzone_idx from sc->reclaim_idx so remove the aliases.
--- mm/vmscan.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
mm/vmscan.c +9 -11
@@ -2426,8 +2426,7 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat,return true; } -static bool shrink_node (pg_data_t *pgdat,struct scan_control *sc, -enum zone_type classzone_idx) +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;
@@ -2656,7 +2655,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)if (zone->zone_pgdat == last_pgdat)continue ; last_pgdat = zone->zone_pgdat; -shrink_node (zone->zone_pgdat, sc, classzone_idx); +shrink_node (zone->zone_pgdat, sc); }/*
@@ -3080,7 +3079,6 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, long remaining,* This is used to determine if the scanning priority needs to be raised. */ static bool kswapd_shrink_node (pg_data_t *pgdat, -int classzone_idx,struct scan_control *sc) {struct zone *zone;
@@ -3088,7 +3086,7 @@ static bool kswapd_shrink_node(pg_data_t *pgdat,/* Reclaim a number of pages proportional to the number of zones */ sc->nr_to_reclaim =0 ; -for (z =0 ; z <= classzone_idx; z++) { +for (z =0 ; z <= sc->reclaim_idx; z++) { zone = pgdat->node_zones + z;if (!populated_zone (zone))continue ;
@@ -3100,7 +3098,7 @@ static bool kswapd_shrink_node(pg_data_t *pgdat,* Historically care was taken to put equal pressure on all zones but * now pressure is applied based on node LRU order. */ -shrink_node (pgdat, sc, classzone_idx); +shrink_node (pgdat, sc);/* * Fragmentation may mean that the system cannot be rebalanced for
@@ -3162,7 +3160,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)if (!populated_zone (zone))continue ; - classzone_idx = i; + sc.reclaim_idx = i;break ; } }
@@ -3175,12 +3173,12 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)* zone was balanced even under extreme pressure when the * overall node may be congested. */ -for (i = classzone_idx; i >=0 ; i--) { +for (i = sc.reclaim_idx; i >=0 ; i--) { zone = pgdat->node_zones + i;if (!populated_zone (zone))continue ; -if (zone_balanced (zone, sc.order, classzone_idx)) +if (zone_balanced (zone, sc.order, sc.reclaim_idx)) goto out; }
@@ -3211,7 +3209,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)* enough pages are already being scanned that that high * watermark would be met at 100% efficiency. */ -if (kswapd_shrink_node (pgdat, classzone_idx, &sc)) +if (kswapd_shrink_node (pgdat, &sc)) raise_priority = false;/*
@@ -3674,7 +3672,7 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in* priorities until we have enough memory freed. */ do { -shrink_node (pgdat, &sc, classzone_idx); +shrink_node (pgdat, &sc); }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>
PATCH 25/34 mm, vmscan: avoid passing in classzone_idx unnecessarily to compaction_ready
In reply to Mel GormanThe scan_control structure has enough information available for compaction_ready() to make a decision. The classzone_idx manipulations in shrink_zones() are no longer necessary as the highest populated zone is no longer used to determine if shrink_slab should be called or not.
--- mm/vmscan.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)
mm/vmscan.c +8 -20
@@ -2521,7 +2521,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)* Returns true if compaction should go ahead for a high-order request, or * the high-order allocation would succeed without compaction. */ -static inline bool compaction_ready (struct zone *zone,int order,int classzone_idx) +static inline bool compaction_ready (struct zone *zone,struct scan_control *sc) {unsigned long watermark;bool watermark_ok;
@@ -2532,21 +2532,21 @@ 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 */ - watermark =high_wmark_pages (zone) + (2UL << order); - watermark_ok =zone_watermark_ok_safe (zone,0 , watermark, classzone_idx); + watermark =high_wmark_pages (zone) + (2UL << sc->order); + watermark_ok =zone_watermark_ok_safe (zone,0 , watermark, sc->reclaim_idx);/* * If compaction is deferred, reclaim up to a point where * compaction will have a chance of success when re-enabled */ -if (compaction_deferred (zone, order)) +if (compaction_deferred (zone, sc->order))return watermark_ok;/* * If compaction is not ready to start and allocation is not likely * to succeed without it, then keep reclaiming. */ -if (compaction_suitable (zone, order,0 , classzone_idx) ==COMPACT_SKIPPED ) +if (compaction_suitable (zone, sc->order,0 , sc->reclaim_idx) ==COMPACT_SKIPPED )return false;return watermark_ok;
@@ -2567,7 +2567,6 @@ 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; -enum zone_type classzone_idx;pg_data_t *last_pgdat =NULL ;/*
@@ -2578,7 +2577,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc) orig_mask = sc->gfp_mask;if (buffer_heads_over_limit) { sc->gfp_mask |= __GFP_HIGHMEM; - sc->reclaim_idx = classzone_idx =gfp_zone (sc->gfp_mask); + sc->reclaim_idx =gfp_zone (sc->gfp_mask); } for_each_zone_zonelist_nodemask(zone, z, zonelist,
@@ -2587,17 +2586,6 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)continue ;/* -* 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. -*/ - classzone_idx = sc->reclaim_idx; -while (!populated_zone (zone->zone_pgdat->node_zones + - classzone_idx)) - classzone_idx--; - -/* * Take care memory controller reclaiming has small influence * to global LRU. */
@@ -2621,8 +2609,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) <= classzone_idx && -compaction_ready (zone, sc->order, classzone_idx)) { +zonelist_zone_idx (z) <= sc->reclaim_idx && +compaction_ready (zone, sc)) { sc->compaction_ready = true;continue ; }
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/34 mm, vmscan: avoid passing in remaining unnecessarily to prepare_kswapd_sleep
In reply to Mel GormanAs pointed out by Minchan Kim, the first call to prepare_kswapd_sleep always passes in 0 for remaining and the second call can trivially check the parameter in advance.
--- mm/vmscan.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
mm/vmscan.c +4 -8
@@ -3020,15 +3020,10 @@ static bool zone_balanced(struct zone *zone, int order, int classzone_idx)* * Returns true if kswapd is ready to sleep */ -static bool prepare_kswapd_sleep (pg_data_t *pgdat,int order,long remaining, -int classzone_idx) +static bool prepare_kswapd_sleep (pg_data_t *pgdat,int order,int classzone_idx) {int i; -/* If a direct reclaimer woke kswapd within HZ/10, it's premature */ -if (remaining) -return false; -/* * The throttled processes are normally woken up in balance_pgdat() as * soon as pfmemalloc_watermark_ok() is true. But there is a potential
@@ -3243,7 +3238,7 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_oprepare_to_wait (&pgdat->kswapd_wait, &wait,TASK_INTERRUPTIBLE );/* Try to sleep for a short interval */ -if (prepare_kswapd_sleep (pgdat, reclaim_order, remaining, classzone_idx)) { +if (prepare_kswapd_sleep (pgdat, reclaim_order, classzone_idx)) {/* * Compaction records what page blocks it recently failed to * isolate pages from and skips them in the future scanning.
@@ -3278,7 +3273,8 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_o* After a short sleep, check if it was a premature sleep. If not, then * go fully to sleep until explicitly woken up. */ -if (prepare_kswapd_sleep (pgdat, reclaim_order, remaining, classzone_idx)) { +if (!remaining && +prepare_kswapd_sleep (pgdat, reclaim_order, classzone_idx)) {trace_mm_vmscan_kswapd_sleep (pgdat->node_id);/*
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/34 mm, vmscan: Have kswapd reclaim from all zones if reclaiming and buffer_heads_over_limit
In reply to Mel GormanThe buffer_heads_over_limit limit in kswapd is inconsistent with direct reclaim behaviour. It may force an an attempt to reclaim from all zones and then not reclaim at all because higher zones were balanced than required by the original request.
This patch will causes kswapd to consider reclaiming from all zones if buffer_heads_over_limit. However, if there are eligible zones for the allocation request that woke kswapd then no reclaim will occur even if buffer_heads_over_limit. This avoids kswapd over-reclaiming just because buffer_heads_over_limit.
--- mm/vmscan.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
mm/vmscan.c +13 -8
@@ -3122,7 +3122,6 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx) .may_writepage = !laptop_mode, .may_unmap = 1, .may_swap = 1, - .reclaim_idx = classzone_idx, };count_vm_event (PAGEOUTRUN );
@@ -3130,12 +3129,16 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)bool raise_priority = true; sc.nr_reclaimed =0 ; + sc.reclaim_idx = classzone_idx;/* -* If the number of buffer_heads in the machine exceeds the -* maximum allowed level then reclaim from all zones. This is -* not specific to highmem as highmem may not exist but it is -* it is expected that buffer_heads are stripped in writeback. +* If the number of buffer_heads exceeds the maximum allowed +* then consider reclaiming from all zones. This is not +* specific to highmem which may not exist but it is it is +* expected that buffer_heads are stripped in writeback. +* Reclaim may still not go ahead if all eligible zones +* for the original allocation request are balanced to +* avoid excessive reclaim from kswapd. */ if (buffer_heads_over_limit) {for (i =MAX_NR_ZONES -1 ; i >=0 ; i--) {
@@ -3154,14 +3157,16 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)* Scanning from low to high zone would allow congestion to be * cleared during a very small window when a small low * zone was balanced even under extreme pressure when the -* overall node may be congested. +* overall node may be congested. Note that sc.reclaim_idx +* is not used as buffer_heads_over_limit may have adjusted +* it. */ -for (i = sc.reclaim_idx; i >=0 ; i--) { +for (i = classzone_idx; i >=0 ; i--) { zone = pgdat->node_zones + i;if (!populated_zone (zone))continue ; -if (zone_balanced (zone, sc.order, sc.reclaim_idx)) +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 28/34 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
@@ -1439,7 +1439,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];
@@ -2888,7 +2888,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);
@@ -2919,7 +2920,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
@@ -2967,7 +2969,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);
@@ -3384,7 +3387,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 29/34 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 ,
@@ -516,10 +515,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 ,/* pgdat has many dirty pages backed by * a congested BDI
mm/internal.h +0 -1
@@ -467,7 +467,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
@@ -921,7 +921,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_zone_write_pending" ,
@@ -1632,10 +1631,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 30/34 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
@@ -2891,6 +2891,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.
@@ -2923,8 +2925,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 31/34 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
@@ -101,9 +101,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
@@ -2659,7 +2659,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 32/34 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/vmscan.c | 15 +++++++++++++-- mm/vmstat.c | 3 ++- 3 files changed, 18 insertions(+), 4 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/vmscan.c +13 -2
@@ -1394,6 +1394,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);
@@ -1408,6 +1409,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 ; }
@@ -1436,8 +1438,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));
@@ -2679,7 +2690,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 , sc->reclaim_idx,1 ); do { vmpressure_prio(sc->gfp_mask, sc->target_mem_cgroup,
mm/vmstat.c +2 -1
@@ -983,6 +983,8 @@ const char * const vmstat_text[] = {"pswpout" , TEXTS_FOR_ZONES("pgalloc") + TEXTS_FOR_ZONES("pgstall") + TEXTS_FOR_ZONES("pgskip")"pgfree" , "pgactivate",
@@ -1008,7 +1010,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>
PATCH 33/34 mm, vmstat: print node-based stats in zoneinfo file
In reply to Mel GormanThere are a number of stats that were previously accessible via zoneinfo that are now invisible. While it is possible to create a new file for the node stats, this may be missed by users. Instead this patch prints the stats under the first populated zone in /proc/zoneinfo.
--- mm/vmstat.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
mm/vmstat.c +24 -0
@@ -1415,11 +1415,35 @@ static const struct file_operations pagetypeinfo_file_ops = { .release = seq_release, }; +static bool is_zone_first_populated (pg_data_t *pgdat,struct zone *zone) +{ +int zid; + +for (zid =0 ; zid <MAX_NR_ZONES ; zid++) { +struct zone *compare = &pgdat->node_zones[zid]; + +if (populated_zone (compare)) +return zone == compare; + } + +/* The zone must be somewhere! */ +WARN_ON_ONCE (1 ); +return false; +} +static void zoneinfo_show_print (struct seq_file *m,pg_data_t *pgdat,struct zone *zone) {int i;seq_printf (m,"Node %d, zone %8s" , pgdat->node_id, zone->name); +if (is_zone_first_populated (pgdat, zone)) { +seq_printf (m,"\n per-node stats" ); +for (i =0 ; i <NR_VM_NODE_STAT_ITEMS ; i++) { +seq_printf (m,"\n %-12s %lu" , + vmstat_text[i +NR_VM_ZONE_STAT_ITEMS ], +node_page_state (pgdat, i)); + } + }seq_printf (m,"\n pages free %lu" "\n min %lu"
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 34/34 mm, vmstat: remove zone and node double accounting by approximating retries
In reply to Mel GormanThe number of LRU pages, dirty pages and writeback pages must be accounted for on both zones and nodes because of the reclaim retry logic, compaction retry logic and highmem calculations all depending on per-zone stats.
Many lowmem allocations are immune from OOM kill due to a check in __alloc_pages_may_oom for (ac->high_zoneidx < ZONE_NORMAL) since commit 03668b3ceb0c ("oom: avoid oom killer for lowmem allocations"). The exception is costly high-order allocations or allocations that cannot fail. If the __alloc_pages_may_oom avoids OOM-kill for low-order lowmem allocations then it would fall through to __alloc_pages_direct_compact.
This patch will blindly retry reclaim for zone-constrained allocations in should_reclaim_retry up to MAX_RECLAIM_RETRIES. This is not ideal but without per-zone stats there are not many alternatives. The impact it that zone-constrained allocations may delay before considering the OOM killer.
As there is no guarantee enough memory can ever be freed to satisfy compaction, this patch avoids retrying compaction for zone-contrained allocations.
In combination, that means that the per-node stats can be used when deciding whether to continue reclaim using a rough approximation. While it is possible this will make the wrong decision on occasion, it will not infinite loop as the number of reclaim attempts is capped by MAX_RECLAIM_RETRIES.
The final step is calculating the number of dirtyable highmem pages. As those calculations only care about the global count of file pages in highmem. This patch uses a global counter used instead of per-zone stats as it is sufficient.
In combination, this allows the per-zone LRU and dirty state counters to be removed.
Suggested by: Michal Hocko <[email protected]>
--- include/linux/mm_inline.h | 24 +++++++++++++++++++++--- include/linux/mmzone.h | 4 ---- include/linux/swap.h | 1 - mm/compaction.c | 20 +++++++++++++++++++- mm/migrate.c | 2 -- mm/page-writeback.c | 13 +++++-------- mm/page_alloc.c | 47 +++++++++++++++++++++++++++++++++++++++-------- mm/vmscan.c | 16 ---------------- mm/vmstat.c | 3 --- 9 files changed, 84 insertions(+), 46 deletions(-)
include/linux/mm_inline.h +21 -3
@@ -4,6 +4,26 @@#include <linux/huge_mm.h> #include <linux/swap.h> +#ifdef CONFIG_HIGHMEM +extern atomic_t highmem_file_pages; + +static inline void acct_highmem_file_pages (int zid,enum lru_list lru, +int nr_pages) +{ +if (is_highmem_idx (zid) &&is_file_lru (lru)) { +if (nr_pages >0 ) +atomic_add (nr_pages, &highmem_file_pages); +else +atomic_sub (nr_pages, &highmem_file_pages); + } +} +#else +static inline void acct_highmem_file_pages (int zid,enum lru_list lru, +int nr_pages) +{ +} +#endif +/** * page_is_file_cache - should the page be on a file LRU or anon LRU? * @page: the page to test
@@ -29,9 +49,7 @@ static __always_inline void __update_lru_size(struct lruvec *lruvec,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); +acct_highmem_file_pages (zid, lru, nr_pages); } static __always_inline void update_lru_size(struct lruvec *lruvec,
include/linux/mmzone.h +0 -4
@@ -110,10 +110,6 @@ struct zone_padding {enum zone_stat_item {/* First 128 byte cacheline (assuming 64 bit words) */ NR_FREE_PAGES , -NR_ZONE_LRU_BASE ,/* Used only for compaction and reclaim retry */ -NR_ZONE_LRU_ANON =NR_ZONE_LRU_BASE , -NR_ZONE_LRU_FILE , -NR_ZONE_WRITE_PENDING ,/* Count of dirty, writeback and unstable pages */ NR_MLOCK ,/* mlock()ed pages found and moved off LRU */ NR_SLAB_RECLAIMABLE ,NR_SLAB_UNRECLAIMABLE ,
include/linux/swap.h +0 -1
@@ -307,7 +307,6 @@ extern void lru_cache_add_active_or_unevictable(struct page *page, struct vm_area_struct *vma);/* 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);
mm/compaction.c +19 -1
@@ -1446,6 +1446,11 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, {struct zone *zone;struct zoneref *z; +pg_data_t *last_pgdat =NULL ; + +/* Do not retry compaction for zone-constrained allocations */ +if (ac->high_zoneidx <ZONE_NORMAL ) +return false;/* * Make sure at least one zone would pass __compaction_suitable if we continue
@@ -1456,14 +1461,27 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order,unsigned long available;enum compact_result compact_result; +if (last_pgdat == zone->zone_pgdat) +continue ; + +/* +* This over-estimates the number of pages available for +* reclaim/compaction but walking the LRU would take too +* long. The consequences are that compaction may retry +* longer than it should for a zone-constrained allocation +* request. +*/ + last_pgdat = zone->zone_pgdat; + available =pgdat_reclaimable_pages (zone->zone_pgdat) / order; +/* * Do not consider all the reclaimable memory because we do not * want to trash just for a single high order allocation which * is even not guaranteed to appear even if __compaction_suitable * is happy about the watermark check. */ - available =zone_reclaimable_pages (zone) / order; available +=zone_page_state_snapshot (zone,NR_FREE_PAGES ); + available =min (zone->managed_pages, available); compact_result =__compaction_suitable (zone, order, alloc_flags,ac_classzone_idx (ac), available); if (compact_result != COMPACT_SKIPPED &&
mm/migrate.c +0 -2
@@ -513,9 +513,7 @@ int migrate_page_move_mapping(struct address_space *mapping, }if (dirty &&mapping_cap_account_dirty (mapping)) {__dec_node_state (oldzone->zone_pgdat,NR_FILE_DIRTY ); -__dec_zone_state (oldzone,NR_ZONE_WRITE_PENDING );__inc_node_state (newzone->zone_pgdat,NR_FILE_DIRTY ); -__dec_zone_state (newzone,NR_ZONE_WRITE_PENDING ); } }local_irq_enable ();
mm/page-writeback.c +5 -8
@@ -299,6 +299,9 @@ static unsigned long node_dirtyable_memory(struct pglist_data *pgdat)return nr_pages; } +#ifdef CONFIG_HIGHMEM +atomic_t highmem_file_pages; +#endif static unsigned long highmem_dirtyable_memory (unsigned long total) {
@@ -306,18 +309,17 @@ static unsigned long highmem_dirtyable_memory(unsigned long total)int node;unsigned long x =0 ;int i; +unsigned long dirtyable =atomic_read (&highmem_file_pages);for_each_node_state (node,N_HIGH_MEMORY ) {for (i =ZONE_NORMAL +1 ; i <MAX_NR_ZONES ; i++) {struct zone *z; -unsigned long dirtyable;if (!is_highmem_idx (i))continue ; z = &NODE_DATA (node)->node_zones[i]; - dirtyable =zone_page_state (z,NR_FREE_PAGES ) + -zone_page_state (z,NR_ZONE_LRU_FILE ); + dirtyable +=zone_page_state (z,NR_FREE_PAGES );/* watch for underflows */ dirtyable -=min (dirtyable,high_wmark_pages (z));
@@ -2460,7 +2462,6 @@ 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_ZONE_WRITE_PENDING );__inc_node_page_state (page,NR_DIRTIED );__inc_wb_stat (wb,WB_RECLAIMABLE );__inc_wb_stat (wb,WB_DIRTIED );
@@ -2482,7 +2483,6 @@ 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_node_page_state (page,NR_FILE_DIRTY ); -dec_zone_page_state (page,NR_ZONE_WRITE_PENDING );dec_wb_stat (wb,WB_RECLAIMABLE );task_io_account_cancelled_write (PAGE_SIZE ); }
@@ -2739,7 +2739,6 @@ int clear_page_dirty_for_io(struct page *page)if (TestClearPageDirty (page)) {mem_cgroup_dec_page_stat (page,MEM_CGROUP_STAT_DIRTY );dec_node_page_state (page,NR_FILE_DIRTY ); -dec_zone_page_state (page,NR_ZONE_WRITE_PENDING );dec_wb_stat (wb,WB_RECLAIMABLE ); ret =1 ; }
@@ -2786,7 +2785,6 @@ 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 ); -dec_zone_page_state (page,NR_ZONE_WRITE_PENDING );inc_node_page_state (page,NR_WRITTEN ); }unlock_page_memcg (page);
@@ -2841,7 +2839,6 @@ int __test_set_page_writeback(struct page *page, bool keep_write)if (!ret) {mem_cgroup_inc_page_stat (page,MEM_CGROUP_STAT_WRITEBACK );inc_node_page_state (page,NR_WRITEBACK ); -inc_zone_page_state (page,NR_ZONE_WRITE_PENDING ); }unlock_page_memcg (page);return ret;
mm/page_alloc.c +39 -8
84 lines not on this page · raw message
mm/vmscan.c +0 -16
@@ -194,22 +194,6 @@ static bool sane_reclaim(struct scan_control *sc) }#endif -/* -* This misses isolated pages which are not accounted for to save counters. -* As the data only determines if reclaim or compaction continues, it is -* not expected that isolated pages will be a dominating factor. -*/ -unsigned long zone_reclaimable_pages (struct zone *zone) -{ -unsigned long nr; - - nr =zone_page_state_snapshot (zone,NR_ZONE_LRU_FILE ); -if (get_nr_swap_pages () >0 ) - nr +=zone_page_state_snapshot (zone,NR_ZONE_LRU_ANON ); - -return nr; -} -unsigned long pgdat_reclaimable_pages (struct pglist_data *pgdat) {unsigned long nr;
mm/vmstat.c +0 -3
@@ -921,9 +921,6 @@ int fragmentation_index(struct zone *zone, unsigned int order)const char *const vmstat_text[] = {/* enum zone_stat_item countes */ "nr_free_pages" , -"nr_zone_anon_lru" , -"nr_zone_file_lru" , -"nr_zone_write_pending" ,"nr_mlock" ,"nr_slab_reclaimable" ,"nr_slab_unreclaimable" ,
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 02/34] mm, vmscan: move lru_lock to the node
In reply to Mel GormanQuoted 49 lines · Mel Gorman
Node-based reclaim requires node-based LRUs and locking. This is a preparation patch that just moves the
lru_lockto 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.Signed-off-by Mel Gorman <[email protected]>Acked-by Johannes Weiner <[email protected]>Acked-by Vlastimil Babka <[email protected]>Reviewed-by Minchan Kim <[email protected]>--- 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 | 6 ++--- 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, 75 insertions(+), 69 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 pageDocumentation/cgroup-v1/memory.txt +0
-0
Documentation/cgroup-v1/memory.txt When oom event notifier is registered, event will be delivered. · line 270
Quoted 5 lines
Documentation/cgroup-v1/memory.txt +1
-1@@ -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
zone_lru_lock is a little confusing, can't we just call it node_lru_lock?
Quoted 43 lines
Documentation/cgroup-v1/memory.txt +1
-1lock_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 +1
-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. @@ -496,7 +496,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;/*
include/linux/mmzone.h typedef struct pglist_data { · line 693
Quoted 5 lines
include/linux/mmzone.h +2
-0@@ -690,6 +689,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 by page reclaim */ +ZONE_PADDING (_pad1_)a
I thought this was to have zone->lock and zone->lru_lock in different cachelines, do we still need the padding here?
include/linux/mmzone.h typedef struct pglist_data { · line 695
Quoted 2 lines
include/linux/mmzone.h +1
-0+spinlock_t lru_lock;
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>
Re: [PATCH 02/34] mm, vmscan: move lru_lock to the node
Quoted 5 lines · Balbir Singh
Quoted 5 lines
Documentation/cgroup-v1/memory.txt +0
-0@@ -267,11 +267,11 @@ When oom event notifier is registered, event will be delivered.
Quoted 9 lines
Documentation/cgroup-v1/memory.txt When oom event notifier is registered, event will be delivered. · line 270
Quoted 5 lines
Documentation/cgroup-v1/memory.txt +1
-1Other lock order is following: PG_locked. mm->page_table_lock - zone->lru_lock + zone_lru_lock
zone_lru_lockis a little confusing, can't we just call itnode_lru_lock?
It's a matter of perspective. People familiar with the VM already expect a zone lock so will be looking for it. I can do a rename if you insist but it may not actually help.
Quoted 7 lines
Quoted 7 lines
Documentation/cgroup-v1/memory.txt +0
-1@@ -496,7 +496,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;
Quoted 11 lines
Documentation/cgroup-v1/memory.txt typedef struct pglist_data { · line 693
Quoted 7 lines
Documentation/cgroup-v1/memory.txt +2
-0/*@@ -690,6 +689,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 by page reclaim */ + ZONE_PADDING(_pad1_)aI thought this was to have
zone->lockandzone->lru_lockin different cachelines, do we still need the padding here?
The zone padding current keeps the page lock wait tables, page allocator lists, compaction and vmstats on separate cache lines. They're still fine.
The node padding may not be necessary. It currently ensures that zonelists and numa balancing are separate from the LRU lock but there is no guarantee the current arrangement is optimal. It would depend on both the kernel config and the workload but it may be necessary in the future to split node into read-mostly sections and then different write-intensive sections similar to what has happened to struct zone in the past.
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 04/34] mm, mmzone: clarify the usage of zone padding
In reply to Mel GormanQuoted 5 lines · Mel Gorman
Zone padding separates write-intensive fields used by page allocation, compaction and vmstats but the comments are a little misleading and need clarification.
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>
Re: [PATCH 05/34] mm, vmscan: begin reclaiming pages on a per-node basis
In reply to Mel GormanQuoted 10 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.
Quoted 2 lines
Signed-off-by Mel Gorman <[email protected]>Acked-by Hillf Danton <[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>
Re: [PATCH 06/34] mm, vmscan: have kswapd only scan based on the highest requested zone
In reply to Mel GormanQuoted 10 lines · Mel Gorman
kswapd 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.
Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[email protected]>
I wasn't quite sure at first what the rationale is for this patch, since it probably won't make much difference in pratice. But I do agree that the code is cleaner to have kswapd check exactly what it was asked to check, rather than some do-the-"right"-thing magic.
A hypothetical onslaught of low-zone allocations will wreak havoc to the page age in higher zones anyway, right? So I don't think that case matters all that much.
--
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/34] mm, vmscan: remove balance gap
In reply to Mel GormanQuoted 7 lines · Mel Gorman
The 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.
[[email protected]: Also remove KSWAPD_ZONE_BALANCE_GAP_RATIO]Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[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>
Johannes Weiner
maintainerRe: [PATCH 11/34] mm, vmscan: remove duplicate logic clearing node congestion and dirty state
In reply to Mel GormanQuoted 4 lines · Mel Gorman
mm/vmscan.c +0
-0@@ -3008,7 +3008,17 @@ static bool zone_balanced(struct zone *zone, int order, int classzone_idx) {unsigned long mark =high_wmark_pages (zone);
mm/vmscan.c static bool zone_balanced(struct zone *zone, int order, int classzone_idx) · line 3019
Quoted 10 lines
mm/vmscan.c +9
-1-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);
Predicate functions that secretly modify internal state give me the willies... The diffstat is flat, too. Is this really an improvement?
--
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/34] mm: vmscan: do not reclaim from kswapd if there is any eligible zone
In reply to Mel GormanQuoted 8 lines · Mel Gorman
kswapd 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_headsare 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.
Quoted 5 lines
[[email protected]: Force kswapd reclaim no more than needed]Signed-off-by Mel Gorman <[email protected]>Signed-off-by Hillf Danton <[email protected]>Acked-by Vlastimil Babka <[email protected]>
One and a half observations:
Quoted 15 lines
mm/vmscan.c +0
-11@@ -3144,31 +3144,39 @@ 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 */ -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.
mm/vmscan.c static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx) · line 3151
Quoted 10 lines
mm/vmscan.c +5
-5-*/ -if (buffer_heads_over_limit &&is_highmem_idx (i)) { - classzone_idx = i; -break ; - } +/* +* If the number of buffer_heads in the machine exceeds the +* maximum allowed level then reclaim from all zones. This is +* not specific to highmem as highmem may not exist but it is +* it is expected that buffer_heads are stripped in writeback.
The mention of highmem in this comment make only sense within the context of this diff; it'll be pretty confusing in the standalone code.
Also, double "it is" :)
--
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/34] mm, vmscan: make shrink_node decisions more node-centric
In reply to Mel GormanQuoted 10 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]>Acked-by Michal Hocko <[email protected]>Acked-by Vlastimil Babka <[email protected]>
Second half of the memcg conversion is in the next patch. Ok.
--
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 14/34] mm, memcg: move memcg limit enforcement from zones to nodes
In reply to Mel GormanQuoted 11 lines · Mel Gorman
Memcg needs adjustment after moving LRUs to the node. Limits are tracked per memcg but the soft-limit excess is tracked per zone. As global page reclaim is based on the node, it is easy to imagine a situation where a zone soft limit is exceeded even though the memcg limit is fine.
This patch moves the soft limit tree the node. 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.
Signed-off-by Mel Gorman <[email protected]>Acked-by Michal Hocko <[email protected]>
Yep, the soft limit tracking scope needs to match the reclaim scope.
Nice patch :)
--
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/34] mm: move page mapped accounting to the node
In reply to Mel GormanQuoted 7 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.Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[email protected]>Acked-by Michal Hocko <[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>
Johannes Weiner
maintainerRe: [PATCH 18/34] mm: rename NR_ANON_PAGES to NR_ANON_MAPPED
In reply to Mel GormanQuoted 11 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
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.
That looks wrong to me. The symmetry is between NR_FILE_PAGES and NR_ANON_PAGES. NR_FILE_MAPPED is merely elaborating on the mapped subset of NR_FILE_PAGES, something which isn't necessary for anon pages as they're always mapped.
--
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/34] mm: move most file-based accounting to the node
In reply to Mel GormanQuoted 10 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. Due to throttling logic in the page allocator for reliable OOM detection, it is still necessary to track dirty and writeback pages on a per-zone basis.
Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[email protected]>Acked-by Michal Hocko <[email protected]>
The straight conversion bits are mind-numbing to review, so I focussed mostly on the NR_ZONE_WRITE_PENDING sites. They look good to me except for the migration one:
Quoted 11 lines
mm/migrate.c +2
-4@@ -505,15 +505,17 @@ 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 );
mm/migrate.c int migrate_page_move_mapping(struct address_space *mapping, · line 518
Quoted 10 lines
mm/migrate.c +6
-2+__dec_node_state (oldzone->zone_pgdat,NR_SHMEM ); +__inc_node_state (newzone->zone_pgdat,NR_SHMEM ); }if (dirty &&mapping_cap_account_dirty (mapping)) { -__dec_zone_state (oldzone,NR_FILE_DIRTY ); -__inc_zone_state (newzone,NR_FILE_DIRTY ); +__dec_node_state (oldzone->zone_pgdat,NR_FILE_DIRTY ); +__dec_zone_state (oldzone,NR_ZONE_WRITE_PENDING ); +__inc_node_state (newzone->zone_pgdat,NR_FILE_DIRTY ); +__dec_zone_state (newzone,NR_ZONE_WRITE_PENDING );
That double dec of NR_ZONE_WRITE_PENDING should be dec(old) -> inc(new).
Otherwise, the patch looks good to me.
--
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 20/34] mm: move vmscan writes and file write accounting to the node
In reply to Mel GormanQuoted 12 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
Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[email protected]>Acked-by Michal Hocko <[email protected]>
More conversion... ;) FWIW, I didn't spot anything problematic. And agreed with leaving unmovable stuff counters on a per-zone basis.
--
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/34] mm, vmscan: only wakeup kswapd once per node for the requested classzone
In reply to Mel GormanQuoted 5 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.
Quoted 7 lines
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]>Acked-by Vlastimil Babka <[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>
Re: [PATCH 22/34] mm, page_alloc: wake kswapd based on the highest eligible zone
In reply to Mel GormanQuoted 7 lines · Mel Gorman
The
ac_classzone_idxis used as the basis for waking kswapd and that is based on the preferred zoneref. If the preferred zoneref's first zone is lower than what is available on other nodes, it's possible that kswapd is woken on a zone with only higher, but still eligible, zones. Asclasszone_idxis strictly adhered to now, it causes a problem because eligible pages are skipped.
Quoted 6 lines
For example, node 0 has only DMA32 and node 1 has only NORMAL. An allocating context running on node 0 may wake kswapd on node 1 telling it to skip all NORMAL pages.
Signed-off-by Mel Gorman <[email protected]>Acked-by Hillf Danton <[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>
Re: [PATCH 23/34] mm: convert zone_reclaim to node_reclaim
In reply to Mel GormanQuoted 9 lines · Mel Gorman
As reclaim is now per-node based, convert
zone_reclaimto benode_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.Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[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>
Re: [PATCH 24/34] mm, vmscan: avoid passing in classzone_idx unnecessarily to shrink_node
In reply to Mel GormanQuoted 5 lines · Mel Gorman
shrink_nodereceives all information it needs aboutclasszone_idxfromsc->reclaim_idxso remove the aliases.Signed-off-by Mel Gorman <[email protected]>Acked-by Hillf Danton <[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>
Re: [PATCH 25/34] mm, vmscan: avoid passing in classzone_idx unnecessarily to compaction_ready
In reply to Mel GormanQuoted 7 lines · Mel Gorman
The
scan_controlstructure has enough information available forcompaction_ready()to make a decision. Theclasszone_idxmanipulations inshrink_zones()are no longer necessary as the highest populated zone is no longer used to determine ifshrink_slabshould be called or not.Signed-off-by Mel Gorman <[email protected]>Acked-by Hillf Danton <[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>
Re: [PATCH 26/34] mm, vmscan: avoid passing in remaining unnecessarily to prepare_kswapd_sleep
In reply to Mel GormanQuoted 6 lines · Mel Gorman
As pointed out by Minchan Kim, the first call to
prepare_kswapd_sleepalways passes in 0 for remaining and the second call can trivially check the parameter in advance.Suggested-by Minchan Kim <[email protected]>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>
Re: [PATCH 27/34] mm, vmscan: Have kswapd reclaim from all zones if reclaiming and buffer_heads_over_limit
In reply to Mel GormanQuoted 5 lines · Mel Gorman
The
buffer_heads_over_limitlimit in kswapd is inconsistent with direct reclaim behaviour. It may force an an attempt to reclaim from all zones and then not reclaim at all because higher zones were balanced than required by the original request.
Quoted 7 lines
This patch will causes kswapd to consider reclaiming from all zones if
buffer_heads_over_limit. However, if there are eligible zones for the allocation request that woke kswapd then no reclaim will occur even ifbuffer_heads_over_limit. This avoids kswapd over-reclaiming just becausebuffer_heads_over_limit.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>
Re: [PATCH 28/34] mm, vmscan: add classzone information to tracepoints
In reply to Mel GormanQuoted 6 lines · Mel Gorman
This 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.
Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[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>
Re: [PATCH 29/34] mm, page_alloc: remove fair zone allocation policy
In reply to Mel GormanQuoted 8 lines · Mel Gorman
The 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.
Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[email protected]>
It's indeed no longer needed with a single set of LRUs on each NUMA node. I'm glad this wart is finally going. Thanks Mel.
--
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 30/34] mm: page_alloc: cache the last node whose dirty limit is reached
In reply to Mel GormanQuoted 8 lines · Mel Gorman
If 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_okis expensive so this patch records if the last pgdat examined hit the dirty limits. In some cases, this reduces the number of calls tonode_dirty_ok().Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[email protected]>
I guess...
--
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 32/34] mm: vmstat: account per-zone stalls and pages skipped during reclaim
In reply to Mel GormanQuoted 13 lines · Mel Gorman
The 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
Quoted 7 lines
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 frompgscan_kswapdandpgscan_directso from that the ratio of useful to useless scans can be calculated.Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[email protected]>
These statistics should be quite helpful, so:
But I have one nitpick:
include/linux/vm_event_item.h line 30
Quoted 9 lines
include/linux/vm_event_item.h +2
-0@@ -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 ,
The PG prefix seems to stand for page, and all stat names that contain it represent some per-page event. PGSTALL is not a page event, though. Would you mind sticking with allocstall? allocstall_dma32 etc.
--
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 31/34] mm: vmstat: replace __count_zone_vm_events with a zone id equivalent
In reply to Mel GormanQuoted 6 lines · Mel Gorman
This is partially a preparation patch for more vmstat work but it also has the slight advantage that
__count_zid_vm_eventsis cheaper to calculate than__count_zone_vm_events().Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[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>
Re: [PATCH 33/34] mm, vmstat: print node-based stats in zoneinfo file
In reply to Mel GormanQuoted 7 lines · Mel Gorman
There are a number of stats that were previously accessible via zoneinfo that are now invisible. While it is possible to create a new file for the node stats, this may be missed by users. Instead this patch prints the stats under the first populated zone in
/proc/zoneinfo.Signed-off-by Mel Gorman <[email protected]>Acked-by Hillf Danton <[email protected]>
I had no idea we could make /proc/zoneinfo any worse!
But it'll work, I guess.
--
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 02/34] mm, vmscan: move lru_lock to the node
In reply to Mel GormanQuoted 16 lines · Mel Gorman
Quoted 5 lines · Balbir Singh
Quoted 5 lines
Documentation/cgroup-v1/memory.txt +0
-0@@ -267,11 +267,11 @@ When oom event notifier is registered, event will be delivered.Quoted 9 lines
Documentation/cgroup-v1/memory.txt When oom event notifier is registered, event will be delivered. · line 270
Quoted 5 lines
Documentation/cgroup-v1/memory.txt +1
-1Other lock order is following: PG_locked. mm->page_table_lock - zone->lru_lock + zone_lru_lock
zone_lru_lockis a little confusing, can't we just call itnode_lru_lock?
Quoted 3 lines
It's a matter of perspective. People familiar with the VM already expect a zone lock so will be looking for it. I can do a rename if you insist but it may not actually help.
I don't want to insist, but zone_ in the name can be confusing, as to leading us to think that the lru_lock is still in the zone
If the rest of the reviewers are fine with, we don't need to rename
Quoted 24 lines
Quoted 8 lines
Quoted 8 lines
Documentation/cgroup-v1/memory.txt +0
-1@@ -496,7 +496,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;Quoted 11 lines
Documentation/cgroup-v1/memory.txt typedef struct pglist_data { · line 693
Quoted 7 lines
Documentation/cgroup-v1/memory.txt +2
-0/*@@ -690,6 +689,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 by page reclaim */ + ZONE_PADDING(_pad1_)aI thought this was to have
zone->lockandzone->lru_lockin different cachelines, do we still need the padding here?The zone padding current keeps the page lock wait tables, page allocator lists, compaction and vmstats on separate cache lines. They're still fine.
Quoted 7 lines
The node padding may not be necessary. It currently ensures that zonelists and numa balancing are separate from the LRU lock but there is no guarantee the current arrangement is optimal. It would depend on both the kernel config and the workload but it may be necessary in the future to split node into read-mostly sections and then different write-intensive sections similar to what has happened to struct zone in the past.
Fair enough
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>
Re: [PATCH 06/34] mm, vmscan: have kswapd only scan based on the highest requested zone
In reply to Johannes WeinerQuoted 9 lines · Johannes Weiner
Quoted 8 lines · Mel Gorman
kswapd 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.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Mel Gorman <[email protected]>Acked-by Vlastimil Babka <[email protected]>Acked-by Johannes Weiner <[email protected]>I wasn't quite sure at first what the rationale is for this patch, since it probably won't make much difference in pratice.
Possibly not, it depends on how much embedded 32-bit platforms use features like zswap. What I wanted to avoid was a lowmem allocation for zswap excessively reclaiming highmem putting even further pressure on zswap if the pages are anonymous.
Quoted 4 lines
But I do
agree that the code is cleaner to have kswapd check exactly what it was asked to check, rather than some do-the-"right"-thing magic.
But this is a justification on its own. I encountered an astonishing number of magic number handling that just happened to mostly work. I wanted to iron them out as much as possible.
Quoted 3 lines
A hypothetical onslaught of low-zone allocations will wreak havoc to the page age in higher zones anyway, right? So I don't think that case matters all that much.
Possibly not, but it was straight-forward to mitigate the damage without too many side-effects.
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 02/34] mm, vmscan: move lru_lock to the node
In reply to Balbir SinghQuoted 17 lines · Balbir Singh
Quoted 16 lines · Mel Gorman
Quoted 14 lines · Balbir Singh
Documentation/cgroup-v1/memory.txt When oom event notifier is registered, event will be delivered. · line 270
Quoted 10 lines
Documentation/cgroup-v1/memory.txt +1
-1@@ -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
zone_lru_lockis a little confusing, can't we just call itnode_lru_lock?
Quoted 6 lines
Quoted 3 lines
It's a matter of perspective. People familiar with the VM already expect a zone lock so will be looking for it. I can do a rename if you insist but it may not actually help.
I don't want to insist, but
zone_in the name can be confusing, as to leading us to think that thelru_lockis still in the zone
On the other hand, it suggests that the argument of the function is a zone. Passing a zone to something called "node_lru_lock()" would be more confusing to me. Also it's mostly a convenience wrapper to ease the transition, whose usage will likely diminish over time.
Quoted 1 line
If the rest of the reviewers are fine with, we don't need to rename
Yes, it's not worth the trouble.
--
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 11/34] mm, vmscan: remove duplicate logic clearing node congestion and dirty state
In reply to Johannes WeinerQuoted 5 lines · Johannes Weiner
Quoted 4 lines · Mel Gorman
mm/vmscan.c +0
-0@@ -3008,7 +3008,17 @@ static bool zone_balanced(struct zone *zone, int order, int classzone_idx) {unsigned long mark =high_wmark_pages (zone);
Quoted 13 lines
mm/vmscan.c static bool zone_balanced(struct zone *zone, int order, int classzone_idx) · line 3019
Quoted 10 lines
mm/vmscan.c +9
-1-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);Predicate functions that secretly modify internal state give me the willies... The diffstat is flat, too. Is this really an improvement?
Primarily, it's about less duplicated code and maintenance overhead. Overall I was both trying to remove side-effects and make the kswapd flow easier to follow.
I'm open to renaming suggestions that make it clear the function has side-effects. Best I came up with after the first coffee is try_reset_zone_balanced() which returns true with congestion/dirty state cleared if the zone is balanced. The name is not great because it's also a little misleading. It doesn't try to reset anything, that's reclaim's job.
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 12/34] mm: vmscan: do not reclaim from kswapd if there is any eligible zone
In reply to Johannes WeinerQuoted 11 lines · Johannes Weiner
Review
Quoted 5 lines
(quoted diff) +5
-0+ /* + * If the number of buffer_heads in the machine exceeds the + * maximum allowed level then reclaim from all zones. This is + * not specific to highmem as highmem may not exist but it is + * it is expected that buffer_heads are stripped in writeback.The mention of highmem in this comment make only sense within the context of this diff; it'll be pretty confusing in the standalone code.
Also, double "it is" :)
Is this any better?
Note that it's marked as a fix to a later patch to reduce collisions in mmotm. It's not a bisection risk so I saw little need to cause unnecessary conflicts for Andrew.
---8<---
mm, vmscan: Have kswapd reclaim from all zones if reclaiming and buffer_heads_over_limit -fix
Johannes reported that the comment about buffer_heads_over_limit in balance_pgdat only made sense in the context of the patch. This patch clarifies the reasoning and how it applies to 32 and 64 bit systems.
This is a fix to the mmotm patch mm-vmscan-have-kswapd-reclaim-from-all-zones-if-reclaiming-and-buffer_heads_over_limit.patch
mm/vmscan.c +7 -6
@@ -3131,12 +3131,13 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)/* * If the number of buffer_heads exceeds the maximum allowed -* then consider reclaiming from all zones. This is not -* specific to highmem which may not exist but it is it is -* expected that buffer_heads are stripped in writeback. -* Reclaim may still not go ahead if all eligible zones -* for the original allocation request are balanced to -* avoid excessive reclaim from kswapd. +* then consider reclaiming from all zones. This has a dual +* purpose -- on 64-bit systems it is expected that +* buffer_heads are stripped during active rotation. On 32-bit +* systems, highmem pages can pin lowmem memory and shrinking +* buffers can relieve lowmem pressure. Reclaim may still not +* go ahead if all eligible zones for the original allocation +* request are balanced to avoid excessive reclaim from kswapd. */ if (buffer_heads_over_limit) {for (i =MAX_NR_ZONES -1 ; i >=0 ; i--) {
--
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/34] mm, vmscan: make shrink_node decisions more node-centric
In reply to Johannes WeinerQuoted 8 lines · Johannes Weiner
Quoted 7 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.
Quoted 7 lines
Quoted 3 lines
Signed-off-by Mel Gorman <[email protected]>Acked-by Michal Hocko <[email protected]>Acked-by Vlastimil Babka <[email protected]>Acked-by Johannes Weiner <[email protected]>Second half of the memcg conversion is in the next patch. Ok.
Yeah. I know it bumps the patch count but the combined patch is a headache to read.
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 18/34] mm: rename NR_ANON_PAGES to NR_ANON_MAPPED
In reply to Johannes WeinerQuoted 9 lines · Johannes Weiner
Quoted 8 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 8 lines
Quoted 3 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.That looks wrong to me. The symmetry is between
NR_FILE_PAGESandNR_ANON_PAGES.NR_FILE_MAPPEDis merely elaborating on the mapped subset ofNR_FILE_PAGES, something which isn't necessary for anon pages as they're always mapped.
How strongly do you feel about reverting it as later patches would cause lots of conflicts.
Obviously I found the new names clearer but I was thinking a lot at the time about mapped vs unmapped due to looking closely at both reclaim and [f|m]advise functions at the time. I found it mildly irksome to switch between the semantics of file/anon when looking at the vmstat updates.
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 12/34] mm: vmscan: do not reclaim from kswapd if there is any eligible zone
In reply to Mel GormanQuoted 11 lines · Mel Gorman
Quoted 10 lines · Johannes Weiner
Review
Quoted 5 lines
(quoted diff) +5
-0+ /* + * If the number of buffer_heads in the machine exceeds the + * maximum allowed level then reclaim from all zones. This is + * not specific to highmem as highmem may not exist but it is + * it is expected that buffer_heads are stripped in writeback.The mention of highmem in this comment make only sense within the context of this diff; it'll be pretty confusing in the standalone code.
Quoted 3 lines
Quoted 1 line
Also, double "it is" :)
Is this any better?
Yes, this is great! Thank you.
Quoted 3 lines
Note that it's marked as a fix to a later patch to reduce collisions in mmotm. It's not a bisection risk so I saw little need to cause unnecessary conflicts for Andrew.
That seems completely reasonable to me.
Quoted 8 lines
---8<---
mm, vmscan: Have kswapd reclaim from all zones if reclaiming andbuffer_heads_over_limit-fixJohannes reported that the comment about
buffer_heads_over_limitinbalance_pgdatonly made sense in the context of the patch. This patch clarifies the reasoning and how it applies to 32 and 64 bit systems.
Quoted 5 lines
This is a fix to the mmotm patch mm-vmscan-have-kswapd-reclaim-from-all-zones-if-reclaiming-and-buffer_heads_over_limit.patch
Suggested-by Johannes Weiner <[email protected]>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>
Johannes Weiner
maintainerRe: [PATCH 18/34] mm: rename NR_ANON_PAGES to NR_ANON_MAPPED
In reply to Mel GormanQuoted 19 lines · Mel Gorman
Quoted 9 lines · Johannes Weiner
Quoted 8 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 haveQuoted 8 lines
Quoted 3 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.That looks wrong to me. The symmetry is between
NR_FILE_PAGESandNR_ANON_PAGES.NR_FILE_MAPPEDis merely elaborating on the mapped subset ofNR_FILE_PAGES, something which isn't necessary for anon pages as they're always mapped.
Quoted 7 lines
How strongly do you feel about reverting it as later patches would cause lots of conflicts.
Obviously I found the new names clearer but I was thinking a lot at the time about mapped vs unmapped due to looking closely at both reclaim and [f|m]advise functions at the time. I found it mildly irksome to switch between the semantics of file/anon when looking at the vmstat updates.
I can see that. It all depends on whether you consider mapping state or page type the more fundamental attribute, and coming from the mapping perspective those new names make sense as well.
However, that leaves the disconnect between the enum name and what we print to userspace. I find myself having to associate those quite a lot to find all the sites that modify a given /proc/vmstat item, and that's a bit of a pain if the names don't match.
I don't care strongly enough to cause a respin of half the series, and it's not your problem that I waited until the last revision went into mmots to review and comment. But if you agreed to a revert, would you consider tacking on a revert patch at the end of the series?
Something like this?
Re: [PATCH 18/34] mm: rename NR_ANON_PAGES to NR_ANON_MAPPED
Quoted 11 lines · Johannes Weiner
Quoted 4 lines
Obviously I found the new names clearer but I was thinking a lot at the time about mapped vs unmapped due to looking closely at both reclaim and [f|m]advise functions at the time. I found it mildly irksome to switch between the semantics of file/anon when looking at the vmstat updates.
I can see that. It all depends on whether you consider mapping state or page type the more fundamental attribute, and coming from the mapping perspective those new names make sense as well.
From a reclaim perspective, I consider the mapped state to be more
important. This is particularly true when the advise calls are taken into account. For example, madvise unmaps the pages without affecting memory residency (distinct from RSS) without aging. fadvise ignores mapped pages so the mapped state is very important for advise hints. Similarly, the mapped state can affect how the pages are aged as mapped pages affect slab scan rates and incur TLB flushes on unmap. I guess I've been thinking about mapped/unmapped a lot recently which pushed me towards distinct naming.
Quoted 5 lines
However, that leaves the disconnect between the enum name and what we print to userspace. I find myself having to associate those quite a lot to find all the sites that modify a given
/proc/vmstatitem, and that's a bit of a pain if the names don't match.
I was tempted to rename userspace what is printed to vmstat as well but worried about breaking tools that parse it.
Quoted 5 lines
I don't care strongly enough to cause a respin of half the series, and it's not your problem that I waited until the last revision went into mmots to review and comment. But if you agreed to a revert, would you consider tacking on a revert patch at the end of the series?
In this case, I'm going to ask the other people on the cc for a tie-breaker. If someone else prefers the old names then I'm happy for your patch to be applied on top with my ack instead of respinning the whole series.
Anyone for a tie breaker?
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>
Andrew Morton
maintainerRe: [PATCH 18/34] mm: rename NR_ANON_PAGES to NR_ANON_MAPPED
Quoted 6 lines · On Wed, 13 Jul 2016 14:37:01 +0100 Mel Gorman <[email protected]>…
Quoted 5 lines
I don't care strongly enough to cause a respin of half the series, and it's not your problem that I waited until the last revision went into mmots to review and comment. But if you agreed to a revert, would you consider tacking on a revert patch at the end of the series?
Quoted 6 lines
In this case, I'm going to ask the other people on the cc for a tie-breaker. If someone else prefers the old names then I'm happy for your patch to be applied on top with my ack instead of respinning the whole series.
Anyone for a tie breaker?
I am aggressively undecided. I guess as it's a bit of a 51/49 situation, the "stay with what people are familiar with" benefit tips the balance toward the legacy names?
--
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/34] mm: rename NR_ANON_PAGES to NR_ANON_MAPPED
In reply to Mel GormanQuoted 35 lines · Mel Gorman
Quoted 9 lines · Johannes Weiner
Quoted 4 lines
Obviously I found the new names clearer but I was thinking a lot at the time about mapped vs unmapped due to looking closely at both reclaim and [f|m]advise functions at the time. I found it mildly irksome to switch between the semantics of file/anon when looking at the vmstat updates.
I can see that. It all depends on whether you consider mapping state or page type the more fundamental attribute, and coming from the mapping perspective those new names make sense as well.
From a reclaim perspective, I consider the mapped state to be more important. This is particularly true when the advise calls are taken into account. For example, madvise unmaps the pages without affecting memory residency (distinct from RSS) without aging. fadvise ignores mapped pages so the mapped state is very important for advise hints. Similarly, the mapped state can affect how the pages are aged as mapped pages affect slab scan rates and incur TLB flushes on unmap. I guess I've been thinking about mapped/unmapped a lot recently which pushed me towards distinct naming.
Quoted 5 lines
However, that leaves the disconnect between the enum name and what we print to userspace. I find myself having to associate those quite a lot to find all the sites that modify a given
/proc/vmstatitem, and that's a bit of a pain if the names don't match.I was tempted to rename userspace what is printed to vmstat as well but worried about breaking tools that parse it.
Quoted 5 lines
I don't care strongly enough to cause a respin of half the series, and it's not your problem that I waited until the last revision went into mmots to review and comment. But if you agreed to a revert, would you consider tacking on a revert patch at the end of the series?
Quoted 6 lines
In this case, I'm going to ask the other people on the cc for a tie-breaker. If someone else prefers the old names then I'm happy for your patch to be applied on top with my ack instead of respinning the whole series.
Anyone for a tie breaker?
I have thought it from reclaim perspective for a long time so I tempted to change the naming like new one but there is no big justification for that. In this chance, I vote new name.
Thanks.
--
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 05/34] mm, vmscan: begin reclaiming pages on a per-node basis
In reply to Mel GormanQuoted 10 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.
Quoted 2 lines
Signed-off-by Mel Gorman <[email protected]>Acked-by Hillf Danton <[email protected]>
I think my previous complaints are fixed.
[...]
Quoted 10 lines
mm/vmscan.c +1
-1@@ -2553,7 +2572,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; -enum zone_type requested_highidx =gfp_zone (sc->gfp_mask); +enum zone_type classzone_idx;/* * 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 2585
Quoted 7 lines
mm/vmscan.c +2
-1@@ -2561,17 +2580,23 @@ 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; + sc->reclaim_idx = classzone_idx =gfp_zone (sc->gfp_mask);
Setting classzone_idx seems pointless here as it will be overwritten in the for loop. Unless that changes with some later patch. Anyway it doesn't hurt anything.
--
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 11/34] mm, vmscan: remove duplicate logic clearing node congestion and dirty state
In reply to Mel GormanQuoted 7 lines · Mel Gorman
Reclaim 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.
Signed-off-by Mel Gorman <[email protected]>Acked-by Hillf Danton <[email protected]>
I don't think it's that big a side-effect to be concerned. I would be more worried about frequently dirtying cache lines from other zone_balanced callers where, but I guess even the calls from wakeup_kswapd() rarely return true for zone_balanced(), otherwise the wakeups wouldn't have a reason to happen.
Quoted 45 lines
--- mm/vmscan.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)mm/vmscan.c +11
-8@@ -3008,7 +3008,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; }/* @@ -3154,13 +3164,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); } }@@ -3219,11 +3222,8 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)if (!populated_zone (zone))continue ;
mm/vmscan.c static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx) · line 3229
Quoted 10 lines
mm/vmscan.c +1
-4-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; - } }/*
--
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 22/34] mm, page_alloc: wake kswapd based on the highest eligible zone
In reply to Mel GormanQuoted 7 lines · Mel Gorman
The
ac_classzone_idxis used as the basis for waking kswapd and that is based on the preferred zoneref. If the preferred zoneref's first zone is lower than what is available on other nodes, it's possible that kswapd is woken on a zone with only higher, but still eligible, zones. Asclasszone_idxis strictly adhered to now, it causes a problem because eligible pages are skipped.
Quoted 6 lines
For example, node 0 has only DMA32 and node 1 has only NORMAL. An allocating context running on node 0 may wake kswapd on node 1 telling it to skip all NORMAL pages.
Signed-off-by Mel Gorman <[email protected]>Acked-by Hillf Danton <[email protected]>
Quoted 10 lines
--- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/page_alloc.c +0
-0
mm/page_alloc.c static void wake_all_kswapds(unsigned int order, const struct alloc_context *ac) · line 3421
Quoted 8 lines
mm/page_alloc.c +1
-1@@ -3415,7 +3415,7 @@ static void wake_all_kswapds(unsigned int order, const struct alloc_context *ac)for_each_zone_zonelist_nodemask (zone, z, ac->zonelist, ac->high_zoneidx, ac->nodemask) {if (last_pgdat != zone->zone_pgdat) -wakeup_kswapd (zone, order,ac_classzone_idx (ac)); +wakeup_kswapd (zone, order, ac->high_zoneidx); last_pgdat = zone->zone_pgdat; } }
--
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 24/34] mm, vmscan: avoid passing in classzone_idx unnecessarily to shrink_node
In reply to Mel GormanQuoted 5 lines · Mel Gorman
shrink_nodereceives all information it needs aboutclasszone_idxfromsc->reclaim_idxso remove the aliases.Signed-off-by Mel Gorman <[email protected]>Acked-by Hillf Danton <[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>
Re: [PATCH 25/34] mm, vmscan: avoid passing in classzone_idx unnecessarily to compaction_ready
In reply to Mel GormanQuoted 7 lines · Mel Gorman
The
scan_controlstructure has enough information available forcompaction_ready()to make a decision. Theclasszone_idxmanipulations inshrink_zones()are no longer necessary as the highest populated zone is no longer used to determine ifshrink_slabshould be called or not.Signed-off-by Mel Gorman <[email protected]>Acked-by Hillf Danton <[email protected]>
mm/vmscan.c static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc) · line 2612
Quoted 7 lines
mm/vmscan.c +1
-2@@ -2621,8 +2609,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) <= classzone_idx && -compaction_ready (zone, sc->order, classzone_idx)) { + zonelist_zone_idx(z) <= sc->reclaim_idx &&
Hm I notice that the condition on the line above should be always true as the same sc->reclaim_idx value is used to limit zone_idx in for_each_zone_zonelist_nodemask(). The implication was probably true even before this patch (classzone_idx would be <= sc->reclaim_idx), but now it stands out clearly.
mm/vmscan.c static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc) · line 2616
Quoted 5 lines
mm/vmscan.c +1
-0+ compaction_ready(zone, sc)) { sc->compaction_ready = true;continue ; }
--
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 26/34] mm, vmscan: avoid passing in remaining unnecessarily to prepare_kswapd_sleep
In reply to Mel GormanQuoted 6 lines · Mel Gorman
As pointed out by Minchan Kim, the first call to
prepare_kswapd_sleepalways passes in 0 for remaining and the second call can trivially check the parameter in advance.Suggested-by Minchan Kim <[email protected]>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>
Re: [PATCH 27/34] mm, vmscan: Have kswapd reclaim from all zones if reclaiming and buffer_heads_over_limit
In reply to Mel GormanQuoted 5 lines · Mel Gorman
The
buffer_heads_over_limitlimit in kswapd is inconsistent with direct reclaim behaviour. It may force an an attempt to reclaim from all zones and then not reclaim at all because higher zones were balanced than required by the original request.
Quoted 7 lines
This patch will causes kswapd to consider reclaiming from all zones if
buffer_heads_over_limit. However, if there are eligible zones for the allocation request that woke kswapd then no reclaim will occur even ifbuffer_heads_over_limit. This avoids kswapd over-reclaiming just becausebuffer_heads_over_limit.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>
Re: [PATCH 33/34] mm, vmstat: print node-based stats in zoneinfo file
In reply to Mel GormanQuoted 7 lines · Mel Gorman
There are a number of stats that were previously accessible via zoneinfo that are now invisible. While it is possible to create a new file for the node stats, this may be missed by users. Instead this patch prints the stats under the first populated zone in
/proc/zoneinfo.Signed-off-by Mel Gorman <[email protected]>Acked-by Hillf Danton <[email protected]>
Re: [PATCH 34/34] mm, vmstat: remove zone and node double accounting by approximating retries
In reply to Mel GormanQuoted 30 lines · Mel Gorman
The number of LRU pages, dirty pages and writeback pages must be accounted for on both zones and nodes because of the reclaim retry logic, compaction retry logic and highmem calculations all depending on per-zone stats.
Many lowmem allocations are immune from OOM kill due to a check in
__alloc_pages_may_oomfor (ac->high_zoneidx<ZONE_NORMAL) since commit03668b3ceb0c("oom: avoid oom killer for lowmem allocations"). The exception is costly high-order allocations or allocations that cannot fail. If the__alloc_pages_may_oomavoids OOM-kill for low-order lowmem allocations then it would fall through to__alloc_pages_direct_compact.This patch will blindly retry reclaim for zone-constrained allocations in
should_reclaim_retryup toMAX_RECLAIM_RETRIES. This is not ideal but without per-zone stats there are not many alternatives. The impact it that zone-constrained allocations may delay before considering the OOM killer.As there is no guarantee enough memory can ever be freed to satisfy compaction, this patch avoids retrying compaction for zone-contrained allocations.
In combination, that means that the per-node stats can be used when deciding whether to continue reclaim using a rough approximation. While it is possible this will make the wrong decision on occasion, it will not infinite loop as the number of reclaim attempts is capped by
MAX_RECLAIM_RETRIES.The final step is calculating the number of dirtyable highmem pages. As those calculations only care about the global count of file pages in highmem. This patch uses a global counter used instead of per-zone stats as it is sufficient.
Quoted 6 lines
In combination, this allows the per-zone LRU and dirty state counters to be removed.
Suggested by: Michal Hocko <[email protected]>
Signed-off-by Mel Gorman <[email protected]>Acked-by Hillf Danton <[email protected]>
The resulting should_reclaim_retry() makes my head spin, I hope Michal can make more sense of it :) So just some comments below.
include/linux/mm_inline.h line 14
Quoted 12 lines
include/linux/mm_inline.h +8
-0@@ -4,6 +4,26 @@#include <linux/huge_mm.h> #include <linux/swap.h> +#ifdef CONFIG_HIGHMEM +extern atomic_t highmem_file_pages; + +static inline void acct_highmem_file_pages (int zid,enum lru_list lru, +int nr_pages) +{ +if (is_highmem_idx (zid) &&is_file_lru (lru)) { +if (nr_pages >0 )
This seems like a unnecessary branch, atomic_add should handle negative nr_pages just fine?
Quoted 5 lines
include/linux/mm_inline.h +5
-0+atomic_add (nr_pages, &highmem_file_pages); + else + atomic_sub(nr_pages, &highmem_file_pages); + } +}
[...]
Quoted 15 lines
mm/compaction.c +5
-0@@ -1446,6 +1446,11 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, {struct zone *zone;struct zoneref *z; +pg_data_t *last_pgdat =NULL ; + +/* Do not retry compaction for zone-constrained allocations */ +if (ac->high_zoneidx <ZONE_NORMAL ) +return false;/* * Make sure at least one zone would pass __compaction_suitable if we continue @@ -1456,14 +1461,27 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order,unsigned long available;enum compact_result compact_result;
mm/compaction.c bool compaction_zonelist_suitable(struct alloc_context *ac, int order, · line 1472
Quoted 10 lines
mm/compaction.c +9
-0+if (last_pgdat == zone->zone_pgdat) +continue ; + +/* +* This over-estimates the number of pages available for +* reclaim/compaction but walking the LRU would take too +* long. The consequences are that compaction may retry +* longer than it should for a zone-constrained allocation +* request.
The comment above says that we don't retry zone-constrained at all. Is this an obsolete comment, or does it refer to the ZONE_NORMAL constraint? (as opposed to HIGHMEM, MOVABLE etc?).
[...]
Quoted 11 lines
mm/page_alloc.c +1
-0@@ -3445,6 +3445,7 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order, {struct zone *zone;struct zoneref *z; +pg_data_t *current_pgdat =NULL ;/* * Make sure we converge to OOM if we cannot make any progress
mm/page_alloc.c should_reclaim_retry(gfp_t gfp_mask, unsigned order, · line 3464
Quoted 10 lines
mm/page_alloc.c +7
-0@@ -3454,6 +3455,15 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order,return false;/* +* Blindly retry lowmem allocation requests that are often ignored by +* the OOM killer up to MAX_RECLAIM_RETRIES as we not have a reliable +* and fast means of calculating reclaimable, dirty and writeback pages +* in eligible zones. +*/ +if (ac->high_zoneidx <ZONE_NORMAL ) + goto out;
A goto inside two nested for cycles? Is there no hope for sanity? :(
Quoted 59 lines
mm/page_alloc.c +30
-7+ +/* * Keep reclaiming pages while there is a chance this will lead somewhere. * If none of the target zones can satisfy our allocation request even * if all reclaimable pages are considered then we are screwed and have @@ -3463,18 +3473,38 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order, ac->nodemask) {unsigned long available;unsigned long reclaimable; +int zid; - available = reclaimable =zone_reclaimable_pages (zone); +if (current_pgdat == zone->zone_pgdat) +continue ; + + current_pgdat = zone->zone_pgdat; + available = reclaimable =pgdat_reclaimable_pages (current_pgdat); available -=DIV_ROUND_UP (no_progress_loops * available,MAX_RECLAIM_RETRIES ); - available +=zone_page_state_snapshot (zone,NR_FREE_PAGES ); + +/* Account for all free pages on eligible zones */ +for (zid =0 ; zid <=zone_idx (zone); zid++) { +struct zone *acct_zone = ¤t_pgdat->node_zones[zid]; + + available +=zone_page_state_snapshot (acct_zone,NR_FREE_PAGES ); + }/* * Would the allocation succeed if we reclaimed the whole -* available? +* available? This is approximate because there is no +* accurate count of reclaimable pages per zone. */ -if (__zone_watermark_ok (zone, order,min_wmark_pages (zone), -ac_classzone_idx (ac), alloc_flags, available)) { +for (zid =0 ; zid <=zone_idx (zone); zid++) { +struct zone *check_zone = ¤t_pgdat->node_zones[zid]; +unsigned long estimate; + + estimate =min (check_zone->managed_pages, available); +if (!__zone_watermark_ok (check_zone, order, +min_wmark_pages (check_zone),ac_classzone_idx (ac), + alloc_flags, estimate)) +continue ; +/* * If we didn't make any progress and have a lot of * dirty + writeback pages then we should wait for @@ -3484,15 +3514,16 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order,if (!did_some_progress) {unsigned long write_pending; - write_pending =zone_page_state_snapshot (zone, -NR_ZONE_WRITE_PENDING ); + write_pending = +node_page_state (current_pgdat,NR_WRITEBACK ) + +node_page_state (current_pgdat,NR_FILE_DIRTY );
mm/page_alloc.c should_reclaim_retry(gfp_t gfp_mask, unsigned order, · line 3529
Quoted 10 lines
mm/page_alloc.c +1
-1if (2 * write_pending > reclaimable) {congestion_wait (BLK_RW_ASYNC ,HZ /10 );return true; } } - +out:/* * Memory allocation/reclaim might be called from a WQ * context and the current implementation of the WQ
--
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 34/34] mm, vmstat: remove zone and node double accounting by approximating retries
Quoted 4 lines · Vlastimil Babka
Quoted 4 lines
include/linux/mm_inline.h +0
-0@@ -4,6 +4,26 @@#include <linux/huge_mm.h> #include <linux/swap.h>
Quoted 12 lines
include/linux/mm_inline.h line 14
Quoted 8 lines
include/linux/mm_inline.h +8
-0+#ifdef CONFIG_HIGHMEM +extern atomic_t highmem_file_pages; + +static inline void acct_highmem_file_pages (int zid,enum lru_list lru, +int nr_pages) +{ +if (is_highmem_idx (zid) &&is_file_lru (lru)) { +if (nr_pages >0 )This seems like a unnecessary branch,
atomic_addshould handle negativenr_pagesjust fine?
On x86 it would but the interface makes no guarantees it'll handle signed types properly on all architectures.
Quoted 4 lines
Quoted 4 lines
mm/compaction.c +0
-0@@ -1456,14 +1461,27 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order,unsigned long available;enum compact_result compact_result;
Quoted 14 lines
mm/compaction.c bool compaction_zonelist_suitable(struct alloc_context *ac, int order, · line 1472
Quoted 9 lines
mm/compaction.c +9
-0+if (last_pgdat == zone->zone_pgdat) +continue ; + +/* +* This over-estimates the number of pages available for +* reclaim/compaction but walking the LRU would take too +* long. The consequences are that compaction may retry +* longer than it should for a zone-constrained allocation +* request. The comment above says that we don't retry zone-constrained at all. Is this an obsolete comment, or does it refer to the
ZONE_NORMALconstraint? (as opposed to HIGHMEM, MOVABLE etc?).
It can still over-estimate the amount of memory available if ZONE_MOVABLE exists even if the request is not zone-constrained.
Quoted 14 lines
mm/page_alloc.c should_reclaim_retry(gfp_t gfp_mask, unsigned order, · line 3464
Quoted 11 lines
mm/page_alloc.c +7
-0@@ -3454,6 +3455,15 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order,return false;/* +* Blindly retry lowmem allocation requests that are often ignored by +* the OOM killer up to MAX_RECLAIM_RETRIES as we not have a reliable +* and fast means of calculating reclaimable, dirty and writeback pages +* in eligible zones. +*/ +if (ac->high_zoneidx <ZONE_NORMAL ) + goto out;A goto inside two nested for cycles? Is there no hope for sanity? :(
None, hand it in at the door.
It can be pulled out and put past the "return false" at the end. It's just not necessarily any better.
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 18/34] mm: rename NR_ANON_PAGES to NR_ANON_MAPPED
In reply to Andrew MortonQuoted 13 lines · Andrew Morton
Quoted 11 lines · On Wed, 13 Jul 2016 14:37:01 +0100 Mel Gorman <[email protected]>…
Quoted 5 lines
I don't care strongly enough to cause a respin of half the series, and it's not your problem that I waited until the last revision went into mmots to review and comment. But if you agreed to a revert, would you consider tacking on a revert patch at the end of the series?
In this case, I'm going to ask the other people on the cc for a tie-breaker. If someone else prefers the old names then I'm happy for your patch to be applied on top with my ack instead of respinning the whole series.
Quoted 6 lines
Quoted 1 line
Anyone for a tie breaker?
I am aggressively undecided. I guess as it's a bit of a 51/49 situation, the "stay with what people are familiar with" benefit tips the balance toward the legacy names?
I still can't decide. It's currently still a draw in terms of naming. If you're worried, use the old naming. It wouldn't be the first time I thought a name was odd.
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 34/34] mm, vmstat: remove zone and node double accounting by approximating retries
In reply to Mel GormanQuoted 18 lines · Mel Gorman
Quoted 4 lines · Vlastimil Babka
Quoted 4 lines
include/linux/mm_inline.h +0
-0@@ -4,6 +4,26 @@#include <linux/huge_mm.h> #include <linux/swap.h> Quoted 12 lines
include/linux/mm_inline.h line 14
Quoted 8 lines
include/linux/mm_inline.h +8
-0+#ifdef CONFIG_HIGHMEM +extern atomic_t highmem_file_pages; + +static inline void acct_highmem_file_pages (int zid,enum lru_list lru, +int nr_pages) +{ +if (is_highmem_idx (zid) &&is_file_lru (lru)) { +if (nr_pages >0 )This seems like a unnecessary branch,
atomic_addshould handle negativenr_pagesjust fine?
Quoted 2 lines
On x86 it would but the interface makes no guarantees it'll handle signed types properly on all architectures.
Hmm really? At least some drivers do that in an easily grepable way:
drivers/tty/serial/dz.c: atomic_add(-1, &mux->map_guard);drivers/tty/serial/sb1250-duart.c: atomic_add(-1, &duart->map_guard);drivers/tty/serial/zs.c: atomic_add(-1, &scc->irq_guard);
And our own __mod_zone_page_state() can get both negative and positive vales and boils down to atomic_long_add() (I assume the long variant wouldn't be different in this aspect).
Quoted 19 lines
Quoted 4 lines
Quoted 4 lines
mm/compaction.c +0
-0@@ -1456,14 +1461,27 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order,unsigned long available;enum compact_result compact_result;Quoted 14 lines
mm/compaction.c bool compaction_zonelist_suitable(struct alloc_context *ac, int order, · line 1472
Quoted 9 lines
mm/compaction.c +9
-0+if (last_pgdat == zone->zone_pgdat) +continue ; + +/* +* This over-estimates the number of pages available for +* reclaim/compaction but walking the LRU would take too +* long. The consequences are that compaction may retry +* longer than it should for a zone-constrained allocation +* request. The comment above says that we don't retry zone-constrained at all. Is this an obsolete comment, or does it refer to the
ZONE_NORMALconstraint? (as opposed to HIGHMEM, MOVABLE etc?).
Quoted 2 lines
It can still over-estimate the amount of memory available if
ZONE_MOVABLEexists even if the request is not zone-constrained.
OK.
Quoted 15 lines
Quoted 14 lines
mm/page_alloc.c should_reclaim_retry(gfp_t gfp_mask, unsigned order, · line 3464
Quoted 11 lines
mm/page_alloc.c +7
-0@@ -3454,6 +3455,15 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order,return false;/* +* Blindly retry lowmem allocation requests that are often ignored by +* the OOM killer up to MAX_RECLAIM_RETRIES as we not have a reliable +* and fast means of calculating reclaimable, dirty and writeback pages +* in eligible zones. +*/ +if (ac->high_zoneidx <ZONE_NORMAL ) + goto out;A goto inside two nested for cycles? Is there no hope for sanity? :(
Quoted 1 line
None, hand it in at the door.
Mine's long gone, was thinking for the future newbies :)
Quoted 2 lines
It can be pulled out and put past the "return false" at the end. It's just not necessarily any better.
I see...
--
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 18/34] mm: rename NR_ANON_PAGES to NR_ANON_MAPPED
In reply to Mel GormanQuoted 16 lines · On Fri, 15 Jul 2016 11:46:05 +0100 Mel Gorman <[email protected]>…
Quoted 15 lines · Andrew Morton
Quoted 12 lines · On Wed, 13 Jul 2016 14:37:01 +0100 Mel Gorman <[email protected]>…
Quoted 5 lines
I don't care strongly enough to cause a respin of half the series, and it's not your problem that I waited until the last revision went into mmots to review and comment. But if you agreed to a revert, would you consider tacking on a revert patch at the end of the series?
In this case, I'm going to ask the other people on the cc for a tie-breaker. If someone else prefers the old names then I'm happy for your patch to be applied on top with my ack instead of respinning the whole series.
Anyone for a tie breaker?
Quoted 8 lines
Quoted 4 lines
I am aggressively undecided. I guess as it's a bit of a 51/49 situation, the "stay with what people are familiar with" benefit tips the balance toward the legacy names?
I still can't decide. It's currently still a draw in terms of naming. If you're worried, use the old naming. It wouldn't be the first time I thought a name was odd.
Well I dunno. We can leave the series as-is for now and we can merge the rename-it-back patch sometime during the next -rc cycle if we find that people are running around in confusion and tumbling out of high windows.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Johannes Weiner
maintainerRe: [PATCH 18/34] mm: rename NR_ANON_PAGES to NR_ANON_MAPPED
Quoted 4 lines · Andrew Morton
Well I dunno. We can leave the series as-is for now and we can merge the rename-it-back patch sometime during the next -rc cycle if we find that people are running around in confusion and tumbling out of high windows.
Sounds good to me.
--
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 01/34] mm, vmstat: add infrastructure for per-node vmstats
In reply to Mel GormanQuoted 2 lines · Mel Gorman
void
refresh_zone_stat_thresholds(void)
{
[...]
Review
Quoted 6 lines
(quoted diff) +6
-0+ /* Zero current pgdat thresholds */ + for_each_online_pgdat(pgdat) { + for_each_online_cpu(cpu) { + per_cpu_ptr(pgdat->per_cpu_nodestats, cpu)->stat_threshold = 0; + } + }
I am oopsing here, for a node whose pgdat->per_cpu_nodestats is NULL.
The node in question is memoryless, so in setup_per_cpu_pageset(), the loop over its populated zones doesn't run, and the per_cpu_nodestat struct isn't allocated.
This patch fixes things for me:
mm/page_alloc.c +8 -0
@@ -5271,9 +5271,17 @@ static void __meminit setup_zone_pageset(struct zone *zone)void __init setup_per_cpu_pageset (void ) {struct zone *zone; +struct pglist_data *pgdat;for_each_populated_zone (zone)setup_zone_pageset (zone); + +for_each_online_pgdat (pgdat) { +if (!pgdat->per_cpu_nodestats) { + pgdat->per_cpu_nodestats = + alloc_percpu(struct per_cpu_nodestat); + } + } }static noinline __init_refok
Signature · 7 lines
Reza Arbab -- 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/34] mm, vmscan: move LRU lists to node
In reply to Mel GormanQuoted 31 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 active 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.
In the event that there is excessive overhead on 32-bit systems due to the nodes being on LRU then there are two potential solutions
1. Long-term isolation of highmem pages when reclaim is lowmem
When pages are skipped, they are immediately added back onto the LRU list. If lowmem reclaim persisted for long periods of time, the same highmem pages get continually scanned. The idea would be that lowmem keeps those pages on a separate list until a reclaim for highmem pages arrives that splices the highmem pages back onto the LRU. It potentially could be implemented similar to the UNEVICTABLE list.
That would reduce the skip rate with the potential corner case is that highmem pages have to be scanned and reclaimed to free lowmem slab pages.
Quoted 8 lines
2. Linear scan lowmem pages if the initial LRU shrink fails
This will break LRU ordering but may be preferable and faster during memory pressure than skipping LRU pages.
Signed-off-by Mel Gorman <[email protected]>Acked-by Johannes Weiner <[email protected]>Acked-by Vlastimil Babka <[email protected]>
This breaks boot on metag architecture:
Oops: err 0007 (Data access general read/write fault) addr 00233008 [#1]
It appears to be in node_page_state_snapshot() (via pgdat_reclaimable()), and have come via mm_init. Here's the relevant bit of the backtrace:
node_page_state_snapshot@0x4009c884(enum node_stat_item item =
???, struct pglist_data * pgdat = ???) + 0x48
pgdat_reclaimable(struct pglist_data * pgdat = 0x402517a0)
show_free_areas(unsigned int filter = 0) + 0x2cc
show_mem(unsigned int filter = 0) + 0x18
mm_init@0x4025c3d4()
start_kernel() + 0x204__per_cpu_offset[0] == 0x233000 (close to bad addr), pgdat->per_cpu_nodestats = NULL. and setup_per_cpu_pageset() definitely hasn't been called yet (mm_init is called before setup_per_cpu_pageset()).
Any ideas what the correct solution is (and why presumably others haven't seen the same issue on other architectures?).
Thanks
James
Quoted 1,941 lines
--- 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 | 18 +-- include/linux/mm_inline.h | 21 ++- include/linux/mmzone.h | 68 +++++---- 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 | 2 +- mm/internal.h | 2 +- mm/khugepaged.c | 4 +- mm/memcontrol.c | 17 +-- 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 | 68 +++++---- mm/swap.c | 50 +++---- mm/vmscan.c | 226 +++++++++++++++++------------- mm/vmstat.c | 47 ++++--- mm/workingset.c | 4 +- 29 files changed, 386 insertions(+), 300 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 +9
-9@@ -340,7 +340,7 @@ static inline 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; }@@ -349,15 +349,15 @@ static inline struct lruvec *mem_cgroup_zone_lruvec(struct zone *zone, out:/* * Since a node can be onlined after the mem_cgroup was created, -* we have to be prepared to initialize lruvec->zone here; +* we have to be prepared to initialize lruvec->pgdat 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; } -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);@@ -438,7 +438,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);@@ -613,13 +613,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 +41
-27@@ -111,12 +111,9 @@ enum zone_stat_item {/* First 128 byte cacheline (assuming 64 bit words) */ NR_FREE_PAGES ,NR_ALLOC_BATCH , -NR_LRU_BASE , -NR_INACTIVE_ANON =NR_LRU_BASE ,/* must match order of LRU_[IN]ACTIVE */ -NR_ACTIVE_ANON ,/* " " " " " */ -NR_INACTIVE_FILE ,/* " " " " " */ -NR_ACTIVE_FILE ,/* " " " " " */ -NR_UNEVICTABLE ,/* " " " " " */ +NR_ZONE_LRU_BASE ,/* Used only for compaction and reclaim retry */ +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.@@ -134,12 +131,9 @@ enum zone_stat_item {NR_VMSCAN_WRITE ,NR_VMSCAN_IMMEDIATE ,/* Prioritise for reclaim when writeback ends */ NR_WRITEBACK_TEMP ,/* Writeback using temporary buffers */ -NR_ISOLATED_ANON ,/* Temporary isolated pages from anon lru */ -NR_ISOLATED_FILE ,/* Temporary isolated pages from file lru */ NR_SHMEM ,/* shmem pages (included tmpfs/GEM pages) */ NR_DIRTIED ,/* page dirtyings since bootup */ NR_WRITTEN ,/* page writings since bootup */ -NR_PAGES_SCANNED ,/* pages scanned since last reclaim */ #if IS_ENABLED(CONFIG_ZSMALLOC) NR_ZSPAGES, /* allocated in zsmalloc */ #endif@@ -161,6 +155,15 @@ enum zone_stat_item { NR_VM_ZONE_STAT_ITEMS };enum node_stat_item { +NR_LRU_BASE , +NR_INACTIVE_ANON =NR_LRU_BASE ,/* must match order of LRU_[IN]ACTIVE */ +NR_ACTIVE_ANON ,/* " " " " " */ +NR_INACTIVE_FILE ,/* " " " " " */ +NR_ACTIVE_FILE ,/* " " " " " */ +NR_UNEVICTABLE ,/* " " " " " */ +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 */ NR_VM_NODE_STAT_ITEMS };@@ -219,7 +222,7 @@ struct lruvec {/* Evictions & activations on the inactive file list */ atomic_long_t inactive_age;#ifdef CONFIG_MEMCG -struct zone *zone; +struct pglist_data *pgdat;#endif };@@ -357,13 +360,6 @@ struct zone {#ifdef CONFIG_NUMA int node;#endif - -/* -* The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on -* this zone's LRU. Maintained by the pageout code. -*/ -unsigned int inactive_ratio; -struct pglist_data *zone_pgdat;struct per_cpu_pageset __percpu *pageset;@@ -495,9 +491,6 @@ struct zone {/* Write-intensive fields used by page reclaim */ -/* Fields commonly accessed by the page reclaim scanner */ -struct lruvec lruvec; -/* * When free pages are below this point, additional steps are taken * when reading the number of free pages to avoid per-cpu counter @@ -537,17 +530,20 @@ struct zone {enum zone_flags {ZONE_RECLAIM_LOCKED ,/* prevents concurrent reclaim */ -ZONE_CONGESTED ,/* zone has many dirty pages backed by +ZONE_FAIR_DEPLETED ,/* fair zone policy batch depleted */ +}; + +enum pgdat_flags { +PGDAT_CONGESTED ,/* pgdat has many dirty pages backed by * a congested BDI */ -ZONE_DIRTY ,/* reclaim scanning has recently found +PGDAT_DIRTY ,/* reclaim scanning has recently found * many dirty file pages at the tail * of the LRU. */ -ZONE_WRITEBACK ,/* reclaim scanning has recently found +PGDAT_WRITEBACK ,/* reclaim scanning has recently found * many pages under writeback */ -ZONE_FAIR_DEPLETED ,/* fair zone policy batch depleted */ };static inline unsigned long zone_end_pfn (const struct zone *zone)@@ -707,6 +703,19 @@ typedef struct pglist_data {unsigned long split_queue_len;#endif +/* Fields commonly accessed by the page reclaim scanner */ +struct lruvec lruvec; + +/* +* The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on +* this node's LRU. Maintained by the pageout code. +*/ +unsigned int inactive_ratio; + +unsigned long flags; + +ZONE_PADDING (_pad2_) +/* Per-node vmstats */ struct per_cpu_nodestat __percpu *per_cpu_nodestats;atomic_long_t vm_stat[NR_VM_NODE_STAT_ITEMS ];@@ -728,6 +737,11 @@ 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) +{ +return &zone->zone_pgdat->lruvec; +} +static inline unsigned long pgdat_end_pfn (pg_data_t *pgdat) {return pgdat->node_start_pfn + pgdat->node_spanned_pages;@@ -779,12 +793,12 @@ extern int init_currently_empty_zone(struct zone *zone, unsigned long start_pfn,extern void lruvec_init (struct lruvec *lruvec); -static inline struct zone *lruvec_zone (struct lruvec *lruvec) +static inline struct pglist_data *lruvec_pgdat (struct lruvec *lruvec) {#ifdef CONFIG_MEMCG -return lruvec->zone; +return lruvec->pgdat;#else - return container_of(lruvec, struct zone, lruvec); + return container_of(lruvec, struct pglist_data, lruvec);#endif }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@@ -178,6 +178,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 node_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@@ -646,8 +646,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 */ @@ -655,12 +655,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 ; }@@ -856,7 +856,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 +1
-1@@ -1830,7 +1830,7 @@ static void __split_huge_page(struct page *page, struct list_head *list,pgoff_t end =-1 ;int i; - 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@@ -78,7 +78,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/khugepaged.c +2
-2@@ -480,7 +480,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); }@@ -576,7 +576,7 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, goto out; }/* 0 stands for page_is_file_cache(page) == false */ -inc_zone_page_state (page,NR_ISOLATED_ANON +0 ); +inc_node_page_state (page,NR_ISOLATED_ANON +0 );VM_BUG_ON_PAGE (!PageLocked (page), page);VM_BUG_ON_PAGE (PageLRU (page), page);mm/memcontrol.c +9
-8@@ -943,14 +943,14 @@ static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg)* 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; }@@ -970,8 +970,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; }@@ -979,6 +979,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 @@ -986,14 +987,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 ;@@ -2069,7 +2070,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 ;@@ -2084,7 +2085,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 @@ -1119,7 +1119,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)); }@@ -1460,7 +1460,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:@@ -1726,15 +1726,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) +@@ -1828,7 +1829,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));/* @@ -1886,7 +1887,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); }@@ -1979,7 +1980,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;@@ -2030,7 +2031,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 +37
-31@@ -1090,9 +1090,9 @@ static void free_pcppages_bulk(struct zone *zone, int count,spin_lock (&zone->lock); isolated_pageblocks =has_isolate_pageblock (zone); - nr_scanned =zone_page_state (zone,NR_PAGES_SCANNED ); + nr_scanned =node_page_state (zone->zone_pgdat,NR_PAGES_SCANNED );if (nr_scanned) -__mod_zone_page_state (zone,NR_PAGES_SCANNED , -nr_scanned); +__mod_node_page_state (zone->zone_pgdat,NR_PAGES_SCANNED , -nr_scanned);while (count) {struct page *page;@@ -1147,9 +1147,9 @@ static void free_one_page(struct zone *zone, {unsigned long nr_scanned;spin_lock (&zone->lock); - nr_scanned =zone_page_state (zone,NR_PAGES_SCANNED ); + nr_scanned =node_page_state (zone->zone_pgdat,NR_PAGES_SCANNED );if (nr_scanned) -__mod_zone_page_state (zone,NR_PAGES_SCANNED , -nr_scanned); +__mod_node_page_state (zone->zone_pgdat,NR_PAGES_SCANNED , -nr_scanned);if (unlikely (has_isolate_pageblock (zone) ||is_migrate_isolate (migratetype))) {@@ -4331,6 +4331,7 @@ void show_free_areas(unsigned int filter)unsigned long free_pcp =0 ;int cpu;struct zone *zone; +pg_data_t *pgdat;for_each_populated_zone (zone) {if (skip_free_areas_node (filter,zone_to_nid (zone)))@@ -4349,13 +4350,13 @@ void show_free_areas(unsigned int filter)" anon_thp: %lu shmem_thp: %lu shmem_pmdmapped: %lu\n" #endif" free:%lu free_pcp:%lu free_cma:%lu\n" , -global_page_state (NR_ACTIVE_ANON ), -global_page_state (NR_INACTIVE_ANON ), -global_page_state (NR_ISOLATED_ANON ), -global_page_state (NR_ACTIVE_FILE ), -global_page_state (NR_INACTIVE_FILE ), -global_page_state (NR_ISOLATED_FILE ), -global_page_state (NR_UNEVICTABLE ), +global_node_page_state (NR_ACTIVE_ANON ), +global_node_page_state (NR_INACTIVE_ANON ), +global_node_page_state (NR_ISOLATED_ANON ), +global_node_page_state (NR_ACTIVE_FILE ), +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),@@ -4374,6 +4375,28 @@ void show_free_areas(unsigned int filter) free_pcp, global_page_state(NR_FREE_CMA_PAGES)); +for_each_online_pgdat (pgdat) { +printk ("Node %d" +" active_anon:%lukB" +" inactive_anon:%lukB" +" active_file:%lukB" +" inactive_file:%lukB" +" unevictable:%lukB" +" isolated(anon):%lukB" +" isolated(file):%lukB" +" all_unreclaimable? %s" +"\n" , + pgdat->node_id, +K (node_page_state (pgdat,NR_ACTIVE_ANON )), +K (node_page_state (pgdat,NR_INACTIVE_ANON )), +K (node_page_state (pgdat,NR_ACTIVE_FILE )), +K (node_page_state (pgdat,NR_INACTIVE_FILE )), +K (node_page_state (pgdat,NR_UNEVICTABLE )), +K (node_page_state (pgdat,NR_ISOLATED_ANON )), +K (node_page_state (pgdat,NR_ISOLATED_FILE )), + !pgdat_reclaimable (pgdat) ?"yes" :"no" ); + } +for_each_populated_zone (zone) {int i;@@ -4390,13 +4413,6 @@ void show_free_areas(unsigned int filter)" min:%lukB" " low:%lukB" " high:%lukB" -" active_anon:%lukB" -" inactive_anon:%lukB" -" active_file:%lukB" -" inactive_file:%lukB" -" unevictable:%lukB" -" isolated(anon):%lukB" -" isolated(file):%lukB" " present:%lukB" " managed:%lukB" " mlocked:%lukB" @@ -4419,21 +4435,13 @@ void show_free_areas(unsigned int filter)" local_pcp:%ukB" " free_cma:%lukB" " writeback_tmp:%lukB" -" pages_scanned:%lu" -" all_unreclaimable? %s" +" node_pages_scanned:%lu" "\n" , zone->name,K (zone_page_state (zone,NR_FREE_PAGES )),K (min_wmark_pages (zone)),K (low_wmark_pages (zone)),K (high_wmark_pages (zone)), -K (zone_page_state (zone,NR_ACTIVE_ANON )), -K (zone_page_state (zone,NR_INACTIVE_ANON )), -K (zone_page_state (zone,NR_ACTIVE_FILE )), -K (zone_page_state (zone,NR_INACTIVE_FILE )), -K (zone_page_state (zone,NR_UNEVICTABLE )), -K (zone_page_state (zone,NR_ISOLATED_ANON )), -K (zone_page_state (zone,NR_ISOLATED_FILE )),K (zone->present_pages),K (zone->managed_pages), K(zone_page_state(zone, NR_MLOCK)),@@ -4458,9 +4466,7 @@ void show_free_areas(unsigned int filter)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 (zone_page_state (zone,NR_PAGES_SCANNED )), - (!zone_reclaimable (zone) ?"yes" :"no" ) - ); + K(node_page_state(zone->zone_pgdat, NR_PAGES_SCANNED)));printk ("lowmem_reserve[]:" );for (i =0 ; i <MAX_NR_ZONES ; i++)printk (" %ld" , zone->lowmem_reserve[i]);@@ -6010,7 +6016,7 @@ 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); +lruvec_init (zone_lruvec (zone));if (!size)continue ;mm/swap.c +25
-25@@ -63,7 +63,7 @@ static void __page_cache_release(struct page *page)unsigned long flags;spin_lock_irqsave (zone_lru_lock (zone), flags); - lruvec =mem_cgroup_page_lruvec (page, zone); + lruvec =mem_cgroup_page_lruvec (page, zone->zone_pgdat);VM_BUG_ON_PAGE (!PageLRU (page), page);__ClearPageLRU (page);del_page_from_lru_list (page, lruvec,page_off_lru (page));@@ -194,7 +194,7 @@ static void pagevec_lru_move_fn(struct pagevec *pvec,spin_lock_irqsave (zone_lru_lock (zone), flags); } - lruvec =mem_cgroup_page_lruvec (page, zone); + lruvec =mem_cgroup_page_lruvec (page, zone->zone_pgdat); (*move_fn)(page, lruvec, arg); }if (zone)@@ -319,7 +319,7 @@ void activate_page(struct page *page) page =compound_head (page);spin_lock_irq (zone_lru_lock (zone)); -__activate_page (page,mem_cgroup_page_lruvec (page, zone),NULL ); +__activate_page (page,mem_cgroup_page_lruvec (page, zone->zone_pgdat),NULL ); spin_unlock_irq(zone_lru_lock(zone)); }#endif @@ -445,16 +445,16 @@ void lru_cache_add(struct page *page)*/ void add_page_to_unevictable_list (struct page *page) { -struct zone *zone =page_zone (page); +struct pglist_data *pgdat =page_pgdat (page);struct lruvec *lruvec; -spin_lock_irq (zone_lru_lock (zone)); - lruvec =mem_cgroup_page_lruvec (page, zone); +spin_lock_irq (&pgdat->lru_lock); + lruvec =mem_cgroup_page_lruvec (page, pgdat);ClearPageActive (page);SetPageUnevictable (page);SetPageLRU (page);add_page_to_lru_list (page, lruvec,LRU_UNEVICTABLE ); -spin_unlock_irq (zone_lru_lock (zone)); +spin_unlock_irq (&pgdat->lru_lock); }/** @@ -730,7 +730,7 @@ void release_pages(struct page **pages, int nr, bool cold) {int i;LIST_HEAD (pages_to_free); -struct zone *zone =NULL ; +struct pglist_data *locked_pgdat =NULL ;struct lruvec *lruvec;unsigned long uninitialized_var (flags );unsigned int uninitialized_var (lock_batch );@@ -741,11 +741,11 @@ void release_pages(struct page **pages, int nr, bool cold)/* * Make sure the IRQ-safe lock-holding time does not get * excessive with a continuous string of pages from the -* same zone. The lock is held only if zone != NULL. +* same pgdat. The lock is held only if pgdat != NULL. */ -if (zone && ++lock_batch ==SWAP_CLUSTER_MAX ) { -spin_unlock_irqrestore (zone_lru_lock (zone), flags); - zone =NULL ; +if (locked_pgdat && ++lock_batch ==SWAP_CLUSTER_MAX ) { +spin_unlock_irqrestore (&locked_pgdat->lru_lock, flags); + locked_pgdat =NULL ; }if (is_huge_zero_page (page)) {@@ -758,27 +758,27 @@ void release_pages(struct page **pages, int nr, bool cold)continue ;if (PageCompound (page)) { -if (zone) { -spin_unlock_irqrestore (zone_lru_lock (zone), flags); - zone =NULL ; +if (locked_pgdat) { +spin_unlock_irqrestore (&locked_pgdat->lru_lock, flags); + locked_pgdat =NULL ; }__put_compound_page (page);continue ; }if (PageLRU (page)) { -struct zone *pagezone =page_zone (page); +struct pglist_data *pgdat =page_pgdat (page); -if (pagezone != zone) { -if (zone) -spin_unlock_irqrestore (zone_lru_lock (zone), +if (pgdat != locked_pgdat) { +if (locked_pgdat) +spin_unlock_irqrestore (&locked_pgdat->lru_lock, flags); lock_batch =0 ; - zone = pagezone; -spin_lock_irqsave (zone_lru_lock (zone), flags); + locked_pgdat = pgdat; +spin_lock_irqsave (&locked_pgdat->lru_lock, flags); } - lruvec =mem_cgroup_page_lruvec (page, zone); + lruvec =mem_cgroup_page_lruvec (page, locked_pgdat);VM_BUG_ON_PAGE (!PageLRU (page), page);__ClearPageLRU (page);del_page_from_lru_list (page, lruvec,page_off_lru (page));@@ -789,8 +789,8 @@ 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 (zone), flags); +if (locked_pgdat) +spin_unlock_irqrestore (&locked_pgdat->lru_lock, flags);mem_cgroup_uncharge_list (&pages_to_free);free_hot_cold_page_list (&pages_to_free, cold);@@ -826,7 +826,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 (zone_lru_lock (lruvec_zone (lruvec)))); + !spin_is_locked (&lruvec_pgdat (lruvec)->lru_lock));if (!list)SetPageLRU (page_tail);mm/vmscan.c +131
-95@@ -191,26 +191,42 @@ static bool sane_reclaim(struct scan_control *sc) }#endif +/* +* This misses isolated pages which are not accounted for to save counters. +* As the data only determines if reclaim or compaction continues, it is +* not expected that isolated pages will be a dominating factor. +*/ unsigned long zone_reclaimable_pages (struct zone *zone) {unsigned long nr; - nr =zone_page_state_snapshot (zone,NR_ACTIVE_FILE ) + -zone_page_state_snapshot (zone,NR_INACTIVE_FILE ) + -zone_page_state_snapshot (zone,NR_ISOLATED_FILE ); + nr =zone_page_state_snapshot (zone,NR_ZONE_LRU_FILE ); +if (get_nr_swap_pages () >0 ) + nr +=zone_page_state_snapshot (zone,NR_ZONE_LRU_ANON ); + +return nr; +} + +unsigned long pgdat_reclaimable_pages (struct pglist_data *pgdat) +{ +unsigned long nr; + + nr =node_page_state_snapshot (pgdat,NR_ACTIVE_FILE ) + +node_page_state_snapshot (pgdat,NR_INACTIVE_FILE ) + +node_page_state_snapshot (pgdat,NR_ISOLATED_FILE );if (get_nr_swap_pages () >0 ) - nr +=zone_page_state_snapshot (zone,NR_ACTIVE_ANON ) + -zone_page_state_snapshot (zone,NR_INACTIVE_ANON ) + -zone_page_state_snapshot (zone,NR_ISOLATED_ANON ); + nr +=node_page_state_snapshot (pgdat,NR_ACTIVE_ANON ) + +node_page_state_snapshot (pgdat,NR_INACTIVE_ANON ) + +node_page_state_snapshot (pgdat,NR_ISOLATED_ANON );return nr; } -bool zone_reclaimable (struct zone *zone) +bool pgdat_reclaimable (struct pglist_data *pgdat) { -return zone_page_state_snapshot (zone,NR_PAGES_SCANNED ) < -zone_reclaimable_pages (zone) *6 ; +return node_page_state_snapshot (pgdat,NR_PAGES_SCANNED ) < +pgdat_reclaimable_pages (pgdat) *6 ; }unsigned long lruvec_lru_size (struct lruvec *lruvec,enum lru_list lru)@@ -218,7 +234,7 @@ unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru)if (!mem_cgroup_disabled ())return mem_cgroup_get_lru_size (lruvec, lru); -return zone_page_state (lruvec_zone (lruvec),NR_LRU_BASE + lru); +return node_page_state (lruvec_pgdat (lruvec),NR_LRU_BASE + lru); }/* @@ -877,7 +893,7 @@ static void page_check_dirty_writeback(struct page *page,* shrink_page_list() returns the number of reclaimed pages */ static unsigned long shrink_page_list(struct list_head *page_list, - struct zone *zone, + struct pglist_data *pgdat, struct scan_control *sc, enum ttu_flags ttu_flags, unsigned long *ret_nr_dirty,@@ -917,7 +933,6 @@ static unsigned long shrink_page_list(struct list_head *page_list, goto keep;VM_BUG_ON_PAGE (PageActive (page), page); -VM_BUG_ON_PAGE (page_zone (page) != zone, page); sc->nr_scanned++;@@ -996,7 +1011,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,/* Case 1 above */ if (current_is_kswapd () &&PageReclaim (page) && -test_bit (ZONE_WRITEBACK , &zone->flags)) { +test_bit (PGDAT_WRITEBACK , &pgdat->flags)) { nr_immediate++; goto keep_locked;@@ -1092,7 +1107,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,*/ if (page_is_file_cache (page) && (!current_is_kswapd () || - !test_bit (ZONE_DIRTY , &zone->flags))) { + !test_bit (PGDAT_DIRTY , &pgdat->flags))) {/* * Immediately reclaim when written back. * Similar in principal to deactivate_page() @@ -1266,11 +1281,11 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone, } } - ret =shrink_page_list (&clean_pages, zone, &sc, + ret =shrink_page_list (&clean_pages, zone->zone_pgdat, &sc,TTU_UNMAP |TTU_IGNORE_ACCESS , &dummy1, &dummy2, &dummy3, &dummy4, &dummy5, true);list_splice (&clean_pages, page_list); -mod_zone_page_state (zone,NR_ISOLATED_FILE , -ret); +mod_node_page_state (zone->zone_pgdat,NR_ISOLATED_FILE , -ret);return ret; }@@ -1375,7 +1390,8 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, {struct list_head *src = &lruvec->lists[lru];unsigned long nr_taken =0 ; -unsigned long scan; +unsigned long nr_zone_taken[MAX_NR_ZONES ] = {0 }; +unsigned long scan, nr_pages;for (scan =0 ; scan < nr_to_scan && nr_taken < nr_to_scan && !list_empty (src); scan++) {@@ -1388,7 +1404,9 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,switch (__isolate_lru_page (page, mode)) {case 0 : - nr_taken +=hpage_nr_pages (page); + nr_pages =hpage_nr_pages (page); + nr_taken += nr_pages; + nr_zone_taken[page_zonenum (page)] += nr_pages;list_move (&page->lru, dst);break ;@@ -1405,6 +1423,13 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, *nr_scanned = scan;trace_mm_vmscan_lru_isolate (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]; +if (!nr_pages) +continue ; + +update_lru_size (lruvec, lru, scan, -nr_pages); + }return nr_taken; }@@ -1445,7 +1470,7 @@ int isolate_lru_page(struct page *page)struct lruvec *lruvec;spin_lock_irq (zone_lru_lock (zone)); - lruvec =mem_cgroup_page_lruvec (page, zone); + lruvec =mem_cgroup_page_lruvec (page, zone->zone_pgdat);if (PageLRU (page)) {int lru =page_lru (page);get_page (page);@@ -1465,7 +1490,7 @@ int isolate_lru_page(struct page *page)* the LRU list will go small and be scanned faster than necessary, leading to * unnecessary swapping, thrashing and OOM. */ -static int too_many_isolated (struct zone *zone,int file, +static int too_many_isolated (struct pglist_data *pgdat,int file,struct scan_control *sc) {unsigned long inactive, isolated;@@ -1477,11 +1502,11 @@ static int too_many_isolated(struct zone *zone, int file,return 0 ;if (file) { - inactive =zone_page_state (zone,NR_INACTIVE_FILE ); - isolated =zone_page_state (zone,NR_ISOLATED_FILE ); + inactive =node_page_state (pgdat,NR_INACTIVE_FILE ); + isolated =node_page_state (pgdat,NR_ISOLATED_FILE ); }else { - inactive =zone_page_state (zone,NR_INACTIVE_ANON ); - isolated =zone_page_state (zone,NR_ISOLATED_ANON ); + inactive =node_page_state (pgdat,NR_INACTIVE_ANON ); + isolated =node_page_state (pgdat,NR_ISOLATED_ANON ); }/* @@ -1499,7 +1524,7 @@ static noinline_for_stack void putback_inactive_pages(struct lruvec *lruvec, struct list_head *page_list) { struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat; -struct zone *zone =lruvec_zone (lruvec); +struct pglist_data *pgdat =lruvec_pgdat (lruvec);LIST_HEAD (pages_to_free);/* @@ -1512,13 +1537,13 @@ putback_inactive_pages(struct lruvec *lruvec, struct list_head *page_list)VM_BUG_ON_PAGE (PageLRU (page), page);list_del (&page->lru);if (unlikely (!page_evictable (page))) { -spin_unlock_irq (zone_lru_lock (zone)); +spin_unlock_irq (&pgdat->lru_lock);putback_lru_page (page); -spin_lock_irq (zone_lru_lock (zone)); +spin_lock_irq (&pgdat->lru_lock);continue ; } - lruvec =mem_cgroup_page_lruvec (page, zone); + lruvec =mem_cgroup_page_lruvec (page, pgdat);SetPageLRU (page); lru =page_lru (page);@@ -1535,10 +1560,10 @@ putback_inactive_pages(struct lruvec *lruvec, struct list_head *page_list)del_page_from_lru_list (page, lruvec, lru);if (unlikely (PageCompound (page))) { -spin_unlock_irq (zone_lru_lock (zone)); +spin_unlock_irq (&pgdat->lru_lock);mem_cgroup_uncharge (page); (*get_compound_page_dtor (page))(page); -spin_lock_irq (zone_lru_lock (zone)); +spin_lock_irq (&pgdat->lru_lock); }else list_add (&page->lru, &pages_to_free); }@@ -1582,10 +1607,10 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,unsigned long nr_immediate =0 ;isolate_mode_t isolate_mode =0 ;int file =is_file_lru (lru); -struct zone *zone =lruvec_zone (lruvec); +struct pglist_data *pgdat =lruvec_pgdat (lruvec);struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat; -while (unlikely (too_many_isolated (zone, file, sc))) { +while (unlikely (too_many_isolated (pgdat, file, sc))) {congestion_wait (BLK_RW_ASYNC ,HZ /10 );/* We are about to die and free our memory. Return now. */ @@ -1600,48 +1625,45 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,if (!sc->may_writepage) isolate_mode |=ISOLATE_CLEAN ; -spin_lock_irq (zone_lru_lock (zone)); +spin_lock_irq (&pgdat->lru_lock); nr_taken =isolate_lru_pages (nr_to_scan, lruvec, &page_list, &nr_scanned, sc, isolate_mode, lru); -update_lru_size (lruvec, lru, -nr_taken); -__mod_zone_page_state (zone,NR_ISOLATED_ANON + file, nr_taken); +__mod_node_page_state (pgdat,NR_ISOLATED_ANON + file, nr_taken); reclaim_stat->recent_scanned[file] += nr_taken;if (global_reclaim (sc)) { -__mod_zone_page_state (zone,NR_PAGES_SCANNED , nr_scanned); +__mod_node_page_state (pgdat,NR_PAGES_SCANNED , nr_scanned);if (current_is_kswapd ()) -__count_zone_vm_events (PGSCAN_KSWAPD , zone, nr_scanned); +__count_vm_events (PGSCAN_KSWAPD , nr_scanned);else -__count_zone_vm_events (PGSCAN_DIRECT , zone, nr_scanned); +__count_vm_events (PGSCAN_DIRECT , nr_scanned); } -spin_unlock_irq (zone_lru_lock (zone)); +spin_unlock_irq (&pgdat->lru_lock);if (nr_taken ==0 )return 0 ; - nr_reclaimed =shrink_page_list (&page_list, zone, sc,TTU_UNMAP , + nr_reclaimed =shrink_page_list (&page_list, pgdat, sc,TTU_UNMAP , &nr_dirty, &nr_unqueued_dirty, &nr_congested, &nr_writeback, &nr_immediate, false); -spin_lock_irq (zone_lru_lock (zone)); +spin_lock_irq (&pgdat->lru_lock);if (global_reclaim (sc)) {if (current_is_kswapd ()) -__count_zone_vm_events (PGSTEAL_KSWAPD , zone, - nr_reclaimed); +__count_vm_events (PGSTEAL_KSWAPD , nr_reclaimed);else -__count_zone_vm_events (PGSTEAL_DIRECT , zone, - nr_reclaimed); +__count_vm_events (PGSTEAL_DIRECT , nr_reclaimed); }putback_inactive_pages (lruvec, &page_list); -__mod_zone_page_state (zone,NR_ISOLATED_ANON + file, -nr_taken); +__mod_node_page_state (pgdat,NR_ISOLATED_ANON + file, -nr_taken); -spin_unlock_irq (zone_lru_lock (zone)); +spin_unlock_irq (&pgdat->lru_lock);mem_cgroup_uncharge_list (&page_list);free_hot_cold_page_list (&page_list, true);@@ -1661,7 +1683,7 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,* are encountered in the nr_immediate check below. */ if (nr_writeback && nr_writeback == nr_taken) -set_bit (ZONE_WRITEBACK , &zone->flags); +set_bit (PGDAT_WRITEBACK , &pgdat->flags);/* * Legacy memcg will stall in page writeback so avoid forcibly @@ -1673,16 +1695,16 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,* backed by a congested BDI and wait_iff_congested will stall. */ if (nr_dirty && nr_dirty == nr_congested) -set_bit (ZONE_CONGESTED , &zone->flags); +set_bit (PGDAT_CONGESTED , &pgdat->flags);/* * If dirty pages are scanned that are not queued for IO, it * implies that flushers are not keeping up. In this case, flag -* the zone ZONE_DIRTY and kswapd will start writing pages from +* the pgdat PGDAT_DIRTY and kswapd will start writing pages from * reclaim context. */ if (nr_unqueued_dirty == nr_taken) -set_bit (ZONE_DIRTY , &zone->flags); +set_bit (PGDAT_DIRTY , &pgdat->flags);/* * If kswapd scans pages marked marked for immediate @@ -1701,9 +1723,10 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,*/ if (!sc->hibernation_mode && !current_is_kswapd () &¤t_may_throttle ()) -wait_iff_congested (zone,BLK_RW_ASYNC ,HZ /10 ); +wait_iff_congested (pgdat,BLK_RW_ASYNC ,HZ /10 ); -trace_mm_vmscan_lru_shrink_inactive (zone, nr_scanned, nr_reclaimed, +trace_mm_vmscan_lru_shrink_inactive (pgdat->node_id, + nr_scanned, nr_reclaimed, sc->priority, file);return nr_reclaimed; }@@ -1731,20 +1754,20 @@ static void move_active_pages_to_lru(struct lruvec *lruvec, struct list_head *pages_to_free, enum lru_list lru) { -struct zone *zone =lruvec_zone (lruvec); +struct pglist_data *pgdat =lruvec_pgdat (lruvec);unsigned long pgmoved =0 ;struct page *page;int nr_pages;while (!list_empty (list)) { page =lru_to_page (list); - lruvec =mem_cgroup_page_lruvec (page, zone); + lruvec =mem_cgroup_page_lruvec (page, pgdat);VM_BUG_ON_PAGE (PageLRU (page), page);SetPageLRU (page); nr_pages =hpage_nr_pages (page); -update_lru_size (lruvec, lru, nr_pages); +update_lru_size (lruvec, lru,page_zonenum (page), nr_pages);list_move (&page->lru, &lruvec->lists[lru]); pgmoved += nr_pages;@@ -1754,10 +1777,10 @@ static void move_active_pages_to_lru(struct lruvec *lruvec,del_page_from_lru_list (page, lruvec, lru);if (unlikely (PageCompound (page))) { -spin_unlock_irq (zone_lru_lock (zone)); +spin_unlock_irq (&pgdat->lru_lock);mem_cgroup_uncharge (page); (*get_compound_page_dtor (page))(page); -spin_lock_irq (zone_lru_lock (zone)); +spin_lock_irq (&pgdat->lru_lock); }else list_add (&page->lru, pages_to_free); }@@ -1783,7 +1806,7 @@ static void shrink_active_list(unsigned long nr_to_scan,unsigned long nr_rotated =0 ;isolate_mode_t isolate_mode =0 ;int file =is_file_lru (lru); -struct zone *zone =lruvec_zone (lruvec); +struct pglist_data *pgdat =lruvec_pgdat (lruvec);lru_add_drain ();@@ -1792,20 +1815,19 @@ static void shrink_active_list(unsigned long nr_to_scan,if (!sc->may_writepage) isolate_mode |=ISOLATE_CLEAN ; -spin_lock_irq (zone_lru_lock (zone)); +spin_lock_irq (&pgdat->lru_lock); nr_taken =isolate_lru_pages (nr_to_scan, lruvec, &l_hold, &nr_scanned, sc, isolate_mode, lru); -update_lru_size (lruvec, lru, -nr_taken); -__mod_zone_page_state (zone,NR_ISOLATED_ANON + file, nr_taken); +__mod_node_page_state (pgdat,NR_ISOLATED_ANON + file, nr_taken); reclaim_stat->recent_scanned[file] += nr_taken;if (global_reclaim (sc)) -__mod_zone_page_state (zone,NR_PAGES_SCANNED , nr_scanned); -__count_zone_vm_events (PGREFILL , zone, nr_scanned); +__mod_node_page_state (pgdat,NR_PAGES_SCANNED , nr_scanned); +__count_vm_events (PGREFILL , nr_scanned); -spin_unlock_irq (zone_lru_lock (zone)); +spin_unlock_irq (&pgdat->lru_lock);while (!list_empty (&l_hold)) {cond_resched ();@@ -1850,7 +1872,7 @@ static void shrink_active_list(unsigned long nr_to_scan,/* * Move pages back to the lru list. */ -spin_lock_irq (zone_lru_lock (zone)); +spin_lock_irq (&pgdat->lru_lock);/* * Count referenced pages from currently used mappings as rotated, * even though only some of them are actually re-activated. This @@ -1861,8 +1883,8 @@ static void shrink_active_list(unsigned long nr_to_scan,move_active_pages_to_lru (lruvec, &l_active, &l_hold, lru);move_active_pages_to_lru (lruvec, &l_inactive, &l_hold, lru -LRU_ACTIVE ); -__mod_zone_page_state (zone,NR_ISOLATED_ANON + file, -nr_taken); -spin_unlock_irq (zone_lru_lock (zone)); +__mod_node_page_state (pgdat,NR_ISOLATED_ANON + file, -nr_taken); +spin_unlock_irq (&pgdat->lru_lock);mem_cgroup_uncharge_list (&l_hold);free_hot_cold_page_list (&l_hold, true);@@ -1956,7 +1978,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg,struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat;u64 fraction[2 ];u64 denominator =0 ;/* gcc */ -struct zone *zone =lruvec_zone (lruvec); +struct pglist_data *pgdat =lruvec_pgdat (lruvec);unsigned long anon_prio, file_prio;enum scan_balance scan_balance;unsigned long anon, file;@@ -1977,7 +1999,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg,* well. */ if (current_is_kswapd ()) { -if (!zone_reclaimable (zone)) +if (!pgdat_reclaimable (pgdat)) force_scan = true;if (!mem_cgroup_online (memcg)) force_scan = true;@@ -2023,14 +2045,24 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg,* anon pages. Try to detect this based on file LRU size. */ if (global_reclaim (sc)) { -unsigned long zonefile; -unsigned long zonefree; +unsigned long pgdatfile; +unsigned long pgdatfree; +int z; +unsigned long total_high_wmark =0 ; - zonefree =zone_page_state (zone,NR_FREE_PAGES ); - zonefile =zone_page_state (zone,NR_ACTIVE_FILE ) + -zone_page_state (zone,NR_INACTIVE_FILE ); + pgdatfree =sum_zone_node_page_state (pgdat->node_id,NR_FREE_PAGES ); + pgdatfile =node_page_state (pgdat,NR_ACTIVE_FILE ) + +node_page_state (pgdat,NR_INACTIVE_FILE ); + +for (z =0 ; z <MAX_NR_ZONES ; z++) { +struct zone *zone = &pgdat->node_zones[z]; +if (!populated_zone (zone)) +continue ; + + total_high_wmark +=high_wmark_pages (zone); + } -if (unlikely (zonefile + zonefree <=high_wmark_pages (zone))) { +if (unlikely (pgdatfile + pgdatfree <= total_high_wmark)) { scan_balance =SCAN_ANON ; goto out; }@@ -2077,7 +2109,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg, file =lruvec_lru_size (lruvec,LRU_ACTIVE_FILE ) +lruvec_lru_size (lruvec,LRU_INACTIVE_FILE ); -spin_lock_irq (zone_lru_lock (zone)); +spin_lock_irq (&pgdat->lru_lock);if (unlikely (reclaim_stat->recent_scanned[0 ] > anon /4 )) { reclaim_stat->recent_scanned[0 ] /=2 ; reclaim_stat->recent_rotated[0 ] /=2 ;@@ -2098,7 +2130,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg, fp = file_prio * (reclaim_stat->recent_scanned[1 ] +1 ); fp /= reclaim_stat->recent_rotated[1 ] +1 ; -spin_unlock_irq (zone_lru_lock (zone)); +spin_unlock_irq (&pgdat->lru_lock); fraction[0 ] = ap; fraction[1 ] = fp;@@ -2352,9 +2384,9 @@ 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 =zone_page_state (zone,NR_INACTIVE_FILE ); + inactive_lru_pages =node_page_state (zone->zone_pgdat,NR_INACTIVE_FILE );if (get_nr_swap_pages () >0 ) - inactive_lru_pages +=zone_page_state (zone,NR_INACTIVE_ANON ); + inactive_lru_pages +=node_page_state (zone->zone_pgdat,NR_INACTIVE_ANON );if (sc->nr_reclaimed < pages_for_compaction && inactive_lru_pages > pages_for_compaction)return true;@@ -2554,7 +2586,7 @@ static void shrink_zones(struct zonelist *zonelist, struct scan_control *sc)continue ;if (sc->priority !=DEF_PRIORITY && - !zone_reclaimable (zone)) + !pgdat_reclaimable (zone->zone_pgdat))continue ;/* Let kswapd poll it */ /* @@ -2692,7 +2724,7 @@ static bool pfmemalloc_watermark_ok(pg_data_t *pgdat)for (i =0 ; i <=ZONE_NORMAL ; i++) { zone = &pgdat->node_zones[i];if (!populated_zone (zone) || -zone_reclaimable_pages (zone) ==0 ) +pgdat_reclaimable_pages (pgdat) ==0 )continue ; pfmemalloc_reserve +=min_wmark_pages (zone);@@ -3000,7 +3032,7 @@ static bool pgdat_balanced(pg_data_t *pgdat, int order, int classzone_idx)* DEF_PRIORITY. Effectively, it considers them balanced so * they must be considered balanced here as well! */ -if (!zone_reclaimable (zone)) { +if (!pgdat_reclaimable (zone->zone_pgdat)) { balanced_pages += zone->managed_pages;continue ; }@@ -3063,6 +3095,7 @@ static bool kswapd_shrink_zone(struct zone *zone, {unsigned long balance_gap;bool lowmem_pressure; +struct pglist_data *pgdat = zone->zone_pgdat;/* Reclaim above the high watermark. */ sc->nr_to_reclaim =max (SWAP_CLUSTER_MAX ,high_wmark_pages (zone));@@ -3087,7 +3120,8 @@ static bool kswapd_shrink_zone(struct zone *zone,shrink_zone (zone, sc,zone_idx (zone) == classzone_idx); -clear_bit (ZONE_WRITEBACK , &zone->flags); +/* TODO: ANOMALY */ +clear_bit (PGDAT_WRITEBACK , &pgdat->flags);/* * If a zone reaches its high watermark, consider it to be no longer @@ -3095,10 +3129,10 @@ static bool kswapd_shrink_zone(struct zone *zone,* BDIs but as pressure is relieved, speculatively avoid congestion * waits. */ -if (zone_reclaimable (zone) && +if (pgdat_reclaimable (zone->zone_pgdat) &&zone_balanced (zone, sc->order, false,0 , classzone_idx)) { -clear_bit (ZONE_CONGESTED , &zone->flags); -clear_bit (ZONE_DIRTY , &zone->flags); +clear_bit (PGDAT_CONGESTED , &pgdat->flags); +clear_bit (PGDAT_DIRTY , &pgdat->flags); }return sc->nr_scanned >= sc->nr_to_reclaim;@@ -3157,7 +3191,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)continue ;if (sc.priority !=DEF_PRIORITY && - !zone_reclaimable (zone)) + !pgdat_reclaimable (zone->zone_pgdat))continue ;/* @@ -3184,9 +3218,11 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)/* * If balanced, clear the dirty and congested * flags +* +* TODO: ANOMALY */ -clear_bit (ZONE_CONGESTED , &zone->flags); -clear_bit (ZONE_DIRTY , &zone->flags); +clear_bit (PGDAT_CONGESTED , &zone->zone_pgdat->flags); +clear_bit (PGDAT_DIRTY , &zone->zone_pgdat->flags); } }@@ -3216,7 +3252,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)continue ;if (sc.priority !=DEF_PRIORITY && - !zone_reclaimable (zone)) + !pgdat_reclaimable (zone->zone_pgdat))continue ; sc.nr_scanned =0 ;@@ -3612,8 +3648,8 @@ 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_lru =zone_page_state (zone,NR_INACTIVE_FILE ) + -zone_page_state (zone,NR_ACTIVE_FILE ); +unsigned long file_lru =node_page_state (zone->zone_pgdat,NR_INACTIVE_FILE ) + +node_page_state (zone->zone_pgdat,NR_ACTIVE_FILE );/* * It's possible for there to be more file mapped pages than @@ -3716,7 +3752,7 @@ int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) zone_page_state(zone, NR_SLAB_RECLAIMABLE) <= zone->min_slab_pages)return ZONE_RECLAIM_FULL ; -if (!zone_reclaimable (zone)) +if (!pgdat_reclaimable (zone->zone_pgdat))return ZONE_RECLAIM_FULL ;/* @@ -3795,7 +3831,7 @@ void check_move_unevictable_pages(struct page **pages, int nr_pages) zone = pagezone;spin_lock_irq (zone_lru_lock (zone)); } - lruvec =mem_cgroup_page_lruvec (page, zone); + lruvec =mem_cgroup_page_lruvec (page, zone->zone_pgdat);if (!PageLRU (page) || !PageUnevictable (page))continue ;mm/vmstat.c +25
-22@@ -936,11 +936,8 @@ const char * const vmstat_text[] = {/* enum zone_stat_item countes */ "nr_free_pages" ,"nr_alloc_batch" , -"nr_inactive_anon" , -"nr_active_anon" , -"nr_inactive_file" , -"nr_active_file" , -"nr_unevictable" , +"nr_zone_anon_lru" , +"nr_zone_file_lru" ,"nr_mlock" ,"nr_anon_pages" , "nr_mapped",@@ -956,12 +953,9 @@ const char * const vmstat_text[] = {"nr_vmscan_write" ,"nr_vmscan_immediate_reclaim" ,"nr_writeback_temp" , -"nr_isolated_anon" , -"nr_isolated_file" ,"nr_shmem" ,"nr_dirtied" ,"nr_written" , -"nr_pages_scanned" , #if IS_ENABLED(CONFIG_ZSMALLOC) "nr_zspages", #endif@@ -981,6 +975,16 @@ const char * const vmstat_text[] = {"nr_shmem_pmdmapped" ,"nr_free_cma" , +/* Node-based counters */ +"nr_inactive_anon" , +"nr_active_anon" , +"nr_inactive_file" , +"nr_active_file" , +"nr_unevictable" , +"nr_isolated_anon" , +"nr_isolated_file" , +"nr_pages_scanned" , +/* enum writeback_stat_item counters */ "nr_dirty_threshold" , "nr_dirty_background_threshold",@@ -1002,11 +1006,11 @@ const char * const vmstat_text[] = {"pgmajfault" ,"pglazyfreed" , - TEXTS_FOR_ZONES("pgrefill") - TEXTS_FOR_ZONES("pgsteal_kswapd") - TEXTS_FOR_ZONES("pgsteal_direct") - TEXTS_FOR_ZONES("pgscan_kswapd") - TEXTS_FOR_ZONES("pgscan_direct") +"pgrefill" , +"pgsteal_kswapd" , +"pgsteal_direct" , +"pgscan_kswapd" , +"pgscan_direct" ,"pgscan_direct_throttle" , #ifdef CONFIG_NUMA@@ -1434,7 +1438,7 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,"\n min %lu" "\n low %lu" "\n high %lu" -"\n scanned %lu" +"\n node_scanned %lu" "\n spanned %lu" "\n present %lu" "\n managed %lu",@@ -1442,13 +1446,13 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,min_wmark_pages (zone),low_wmark_pages (zone),high_wmark_pages (zone), -zone_page_state (zone,NR_PAGES_SCANNED ), +node_page_state (zone->zone_pgdat,NR_PAGES_SCANNED ), zone->spanned_pages, zone->present_pages, zone->managed_pages);for (i =0 ; i <NR_VM_ZONE_STAT_ITEMS ; i++) -seq_printf (m,"\n %-12s %lu" , vmstat_text[i], +seq_printf (m,"\n %-12s %lu" , vmstat_text[i],zone_page_state (zone, i)); seq_printf(m,@@ -1478,12 +1482,12 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,#endif }seq_printf (m, -"\n all_unreclaimable: %u" -"\n start_pfn: %lu" -"\n inactive_ratio: %u" , - !zone_reclaimable (zone), +"\n node_unreclaimable: %u" +"\n start_pfn: %lu" +"\n node_inactive_ratio: %u" , + !pgdat_reclaimable (zone->zone_pgdat), zone->zone_start_pfn, - zone->inactive_ratio); + zone->zone_pgdat->inactive_ratio);seq_putc (m,'\n' ); }@@ -1574,7 +1578,6 @@ static int vmstat_show(struct seq_file *m, void *arg) {unsigned long *l = arg;unsigned long off = l - (unsigned long *)m->private; -seq_printf (m,"%s %lu\n" , vmstat_text[off], *l);return 0 ; }mm/workingset.c +2
-3@@ -355,8 +355,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 ); }/* -- 2.6.4
Re: [PATCH 03/34] mm, vmscan: move LRU lists to node
Quoted 19 lines · James Hogan
Quoted 3 lines
Signed-off-by Mel Gorman <[email protected]>Acked-by Johannes Weiner <[email protected]>Acked-by Vlastimil Babka <[email protected]>This breaks boot on metag architecture:
Oops: err 0007 (Data access general read/write fault) addr 00233008 [#1]It appears to be in
node_page_state_snapshot()(viapgdat_reclaimable()), and have come viamm_init. Here's the relevant bit of the backtrace:node_page_state_snapshot@0x4009c884(enum node_stat_item item = ???, struct pglist_data * pgdat = ???) + 0x48 pgdat_reclaimable(struct pglist_data * pgdat = 0x402517a0) show_free_areas(unsigned int filter = 0) + 0x2cc show_mem(unsigned int filter = 0) + 0x18 mm_init@0x4025c3d4() start_kernel() + 0x204
Quoted 8 lines
__per_cpu_offset[0] ==
0x233000(close to bad addr),pgdat->per_cpu_nodestats= NULL. andsetup_per_cpu_pageset()definitely hasn't been called yet (mm_initis called beforesetup_per_cpu_pageset()).Any ideas what the correct solution is (and why presumably others haven't seen the same issue on other architectures?).
metag calls show_mem in mem_init() before the pagesets are initialised. What's surprising is that it worked for the zone stats as it appears that calling zone_reclaimable() from that context should also have broken. Did anything change recently that would have avoided the zone->pageset dereference in zone_reclaimable() before?
The easiest option would be to not call show_mem from arch code until after the pagesets are setup.
Signature · 2 lines
Mel Gorman SUSE Labs
Re: [PATCH 03/34] mm, vmscan: move LRU lists to node
Quoted 25 lines · Mel Gorman
Quoted 24 lines · James Hogan
Quoted 3 lines
Signed-off-by Mel Gorman <[email protected]>Acked-by Johannes Weiner <[email protected]>Acked-by Vlastimil Babka <[email protected]>This breaks boot on metag architecture:
Oops: err 0007 (Data access general read/write fault) addr 00233008 [#1]It appears to be in
node_page_state_snapshot()(viapgdat_reclaimable()), and have come viamm_init. Here's the relevant bit of the backtrace:node_page_state_snapshot@0x4009c884(enum node_stat_item item = ???, struct pglist_data * pgdat = ???) + 0x48 pgdat_reclaimable(struct pglist_data * pgdat = 0x402517a0) show_free_areas(unsigned int filter = 0) + 0x2cc show_mem(unsigned int filter = 0) + 0x18 mm_init@0x4025c3d4() start_kernel() + 0x204__per_cpu_offset[0] ==
0x233000(close to bad addr),pgdat->per_cpu_nodestats= NULL. andsetup_per_cpu_pageset()definitely hasn't been called yet (mm_initis called beforesetup_per_cpu_pageset()).
Quoted 5 lines
Quoted 3 lines
Any ideas what the correct solution is (and why presumably others haven't seen the same issue on other architectures?).
metag calls
show_meminmem_init()before the pagesets are initialised.
Indeed, I didn't spot yesterday evening that this appears to be different to other arches.
Quoted 4 lines
What's surprising is that it worked for the zone stats as it appears that calling
zone_reclaimable()from that context should also have broken. Did anything change recently that would have avoided thezone->pagesetdereference inzone_reclaimable()before?
It appears that zone_pcp_init() was already setting zone->pageset to &boot_pageset, via paging_init():
zone_pcp_init@0x40265d54(struct zone * zone = ???)
free_area_init_core@0x40265c18(struct pglist_data * pgdat = ???) + 0x138
free_area_init_node(int nid = 0, unsigned long * zones_size = ???, unsigned long node_start_pfn = ???, unsigned long * zholes_size = ???) + 0x1a0 free_area_init_nodes(unsigned long * max_zone_pfn = ???) + 0x440paging_init(unsigned long mem_end = 0x4fe00000) + 0x378setup_arch(char ** cmdline_p = 0x4024e038) + 0x2b8start_kernel() + 0x54
setup_arch() is called prior to mm_init(), which explains why it wasn't crashing before.
Quoted 2 lines
The easiest option would be to not call
show_memfrom arch code until after the pagesets are setup.
Since no other arches seem to do show_mem earily during boot like metag, and doing so doesn't really add much value, I'm happy to remove it anyway.
However could your change break other things and need fixing anyway?
Thanks!
James
Re: [PATCH 03/34] mm, vmscan: move LRU lists to node
Quoted 8 lines · James Hogan
Quoted 4 lines
What's surprising is that it worked for the zone stats as it appears that calling
zone_reclaimable()from that context should also have broken. Did anything change recently that would have avoided thezone->pagesetdereference inzone_reclaimable()before?It appears that
zone_pcp_init()was already settingzone->pagesetto&boot_pageset, viapaging_init():
/me slaps self
Of course.
Quoted 7 lines
Quoted 2 lines
The easiest option would be to not call
show_memfrom arch code until after the pagesets are setup.Since no other arches seem to do
show_memearily during boot like metag, and doing so doesn't really add much value, I'm happy to remove it anyway.
Thanks. Can I assume you'll merge such a patch or should I roll one?
Quoted 2 lines
However could your change break other things and need fixing anyway?
Not that I'm aware of. There would have to be a node-based stat that has meaning that early in boot to have an effect. If one happened to added then it would need fixing but until then the complexity is unnecessary.
Signature · 2 lines
Mel Gorman SUSE Labs
Re: [PATCH 03/34] mm, vmscan: move LRU lists to node
Quoted 17 lines · Mel Gorman
Quoted 8 lines · James Hogan
Quoted 4 lines
What's surprising is that it worked for the zone stats as it appears that calling
zone_reclaimable()from that context should also have broken. Did anything change recently that would have avoided thezone->pagesetdereference inzone_reclaimable()before?It appears that
zone_pcp_init()was already settingzone->pagesetto&boot_pageset, viapaging_init():/me slaps self
Of course.
Quoted 3 lines
Quoted 2 lines
The easiest option would be to not call
show_memfrom arch code until after the pagesets are setup.
Quoted 6 lines
Quoted 4 lines
Since no other arches seem to do
show_memearily during boot like metag, and doing so doesn't really add much value, I'm happy to remove it anyway.Thanks. Can I assume you'll merge such a patch or should I roll one?
Yep, I'll take care of it.
Quoted 7 lines
Quoted 3 lines
However could your change break other things and need fixing anyway?
Not that I'm aware of. There would have to be a node-based stat that has meaning that early in boot to have an effect. If one happened to added then it would need fixing but until then the complexity is unnecessary.
Okay, thanks for the help,
Cheers
James
Hello Mel,
Quoted 4 lines · Mel Gorman
Minor changes this time
Changelog since v8
This is the latest version of a series that moves LRUs from the zones to
I'm afraid this is a bit incomplete...
I had troubles in rebasing the compaction-enabled zone_reclaim feature (now node_reclaim) to the node model. That is because compaction is still zone based, and so I would need to do a loop of compaction calls (for each zone in the node), but what's the point? Movable memory can always go anywhere, can't it? So it would be better to compact across the whole node without care of the zone boundaries. Then if the classzone_idx passed to compaction is not for the highest classzone, it'll do zone_reclaim and focus itself on the lower zones (but it can still cross the zone boundaries among those lower zones).
No matter how I tweak my code it doesn't make much sense to do a manual loop and leave compaction unable to cross zone boundaries. Is anybody working to complete this work to make compaction work on node basis instead of zone basis? Or am I missing something for why compaction scan "lowpfn, highpfn" starting positions cannot possibly cross zone boundaries?
I'm also uncertain what's the meaning now of zonelist_order=z (default setting) considering it'll always behave like zone_order=n anyway... On the same lines, I'm also uncertain of the meaning of the zonelist in the first place and why it's not a "nodelist + classzone_idx". Why is there still a zonelist_order=z default setting and a zonelist_order option in the first place, and a zonelist instead of a nodelist?
I use zonelist_order=n on my NUMA systems and I always liked the LRU to be per-node (despite it uses more CPU when you allocate from a lower classzone as you need to skip the pages of the higher zones not contained in the classzone_idx). So to be clear I'm not against this work (I tend to believe there are more pros than cons), but to port some code to the node model in the right way, I'd need to do too much work myself on the compaction side.
Also note, the main security left that allows this change to work stable is in the lowmem reserve ratio feature in the page allocator that prevents lower classzones to be completely filled by non movable allocations from higher classzones (i.e. pagetables). As there's no priority anymore to start shrinking from the higher zone of the classzone_idx of the allocation (especially effective logic if using zonelist_order=z which happens to be the default, even though I almost always use zonelist_order=n which in fact already behaved much closer to the new behavior). The removal of the bias against the highest zone to me is the biggest cons in terms of stability in the corner cases, overall but I believe the security of the lowmem reserve ratio should suffice.
I also expect this work to make negligible difference for those systems where DMA32 and DMA zones don't exist or are tiny, as the node:zone relation is practically already 1:1 there. I believe this actually will help more in systems where the DMA32 zone is relevant if compared to the total memory size (as long as there are not too many DMA32 allocations from pci32 devices, and the zone exists just in case, for an lowmem allocation once in a while). So this isn't a change for the long run, it'll be more noticeable on low end systems or highmem 32bit systems, and it's going to be a noop if you've got a terabytes of RAM (perhaps some pointer dereference is avoided, but that difference should get not measurable).
On a side note the compaction enabled node_reclaim that makes node_reclaim fully effective with THP on, works better with zonelist_order=z too, so it should work even better with the node model that practically makes zonelist_order=z impossible to achieve any longer (which also shows it was a bad default and it was good idea to manually set it to =n :). It's just the compaction zone model that forces me to write a for-each-zone loop that isn't ideal and it would defeat the purpose of the node model as far as compaction is concerned.
Thanks,
Andrea
--
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 1 line · Andrea Arcangeli
Hello Mel,
Hi Andrea,
Quoted 10 lines · Mel Gorman
Quoted 4 lines
Minor changes this time
Changelog since v8
This is the latest version of a series that moves LRUs from the zones toI'm afraid this is a bit incomplete...
I had troubles in rebasing the compaction-enabled
zone_reclaimfeature (nownode_reclaim) to the node model.
What's that? Never head of this before, but sounds scary :) I thought that zone_reclaim itself was rather discouraged nowadays, not a big candidate for further improvement.,,
Quoted 4 lines
That is because compaction is
still zone based, and so I would need to do a loop of compaction calls (for each zone in the node), but what's the point? Movable memory can always go anywhere, can't it?
Hm I'm not so sure. Are all movable allocations highmem? For example Joonsoo mentions in his ZONE_CMA patchset "blockdev file cache page [...] usually has __GFP_MOVABLE but not __GFP_HIGHMEM and __GFP_USER". Now we also have Minchan's infrastructure for arbitrary driver compaction, so those will be movable, but potentially still restricted to e.g. DMA32...
Vlastimil
--
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 · Vlastimil Babka
What's that? Never head of this before, but sounds scary :) I thought that
zone_reclaimitself was rather discouraged nowadays, not a big candidate for further improvement.,,
It's some fix that I tried to push upstream but wasn't merged. I kept maintaining it because I got customers bugreport about THP causing regressions to node_reclaim.
Hard NUMA bindings would solve that but apparently there are apps that prefers no memory binding to allow flexible spillover, and they only use CPU bindings only but with a strong NUMA bias provided by node_reclaim, by shrinking the cache (and only the cache).
In any case it was a regression caused by THP because compaction wasn't invoked. Note zone_reclaim has a synchronous more aggressive option that blocks for write back if needed, so invoking direct compaction there is sure ok, if it's asked on demand.
As usual it's always a tradeoff between long live and short lived allocation so if you reserve a system for computations and you know your allocation are very long lived it make perfect sense to be aggressive if you tune for it.
zone_reclaim or synchronous direct compaction are obviously bad defaults for general purpose default settings, it doesn't mean it should be impossible to tune a system for a certain workload to run optimal.
Quoted 6 lines
Hm I'm not so sure. Are all movable allocations highmem? For example Joonsoo mentions in his
ZONE_CMApatchset "blockdev file cache page [...] usually has__GFP_MOVABLEbut not__GFP_HIGHMEMand__GFP_USER". Now we also have Minchan's infrastructure for arbitrary driver compaction, so those will be movable, but potentially still restricted to e.g. DMA32...
One option is to forbid such corner cases... and VM_WARN_ON (not a typo :) available in my tree) if __GFP_MOVABLE is passed on lower classzones.
The other option would be to have a per-classzone lowpfn, highpnf scan pointers. That has some cons but hey this whole thing is a tradeoff isn't it?
It's about the fact we're optimizing for less frequent lowmem allocations so we can as well provide a worse compaction for lowmem (by reducing the MOVABLE memory restricted to lower classzones like mentioned above), but leverage the node model to have a more powerful that crosses all zone boundaries, when the GFP_HIGHUSER is used.
I don't see why the tradeoff is valid when it comes to the LRU but not valid when it comes to compaction and then I've to do a blind loop of (for-each-zone-in-the-node-in-reverse { compact_zone_order(zone) }) which works worse than before and works worse than a zone-boundary-less compaction based on the node model.
--
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 10 lines · Andrea Arcangeli
Hello Mel,
Quoted 4 lines · Mel Gorman
Minor changes this time
Changelog since v8
This is the latest version of a series that moves LRUs from the zones toI'm afraid this is a bit incomplete...
Compaction is not the same as LRU management.
Quoted 2 lines
I had troubles in rebasing the compaction-enabled
zone_reclaimfeature (nownode_reclaim) to the node model.
I'm not familiar with this although from the name, I can guess what it's doing -- migrating pages from lowmem instead of reclaiming.
Quoted 4 lines
That is because compaction is
still zone based, and so I would need to do a loop of compaction calls (for each zone in the node), but what's the point? Movable memory can always go anywhere, can't it?
That is not guaranteed. At the time of migration, it is unknown if the original allocation had addressing limitations or not. I did not audit the address-limited allocations to see if any of them allow migration.
The filesystems would be the ones that need careful auditing. There are some places that add lowmem pages to the LRU but far less obvious if any of them would successfully migrate.
I'm not familiar with the specifics of the series you're working on but as compaction was zone-based, you'd have to loop across the zones whether the LRU is node or zone based. Even if cross-zone compaction was allowed, it does not make a difference how the LRUs are managed.
Historically, the possibility that pages being compacted were address-limited was the first reason didn't compact across zones. The other was that it could introduce page aging problems. For example, migrating DMA32 to a small NORMAL potentially allowed the page to be reclaimed prematurely by reclaim. That is less of a concern with node-lru.
Quoted 2 lines
So it would be better to compact across
the whole node without care of the zone boundaries.
That is likely true as long as migration is always towards higher address.
Quoted 9 lines
Then if the
classzone_idxpassed to compaction is not for the highest classzone, it'll dozone_reclaimand focus itself on the lower zones (but it can still cross the zone boundaries among those lower zones).No matter how I tweak my code it doesn't make much sense to do a manual loop and leave compaction unable to cross zone boundaries. Is anybody working to complete this work to make compaction work on node basis instead of zone basis?
Not that I'm aware of but compaction across zones is not directly related to LRU management.
Quoted 4 lines
Or am I missing something for why
compaction scan "lowpfn, highpfn" starting positions cannot possibly cross zone boundaries?
An audit of all additions to the LRU that are address-limited allocations is required to determine if any of those pages can migrate.
Quoted 3 lines
I'm also uncertain what's the meaning now of zonelist_order=z (default setting) considering it'll always behave like zone_order=n anyway...
I'm not sure I understand. The zone allocation preference has the same meaning as it always had.
Quoted 3 lines
On the same lines, I'm also uncertain of the meaning of the
zonelist in the first place and why it's not a "nodelist +classzone_idx". Why is there still a zonelist_order=z default setting
On 64-bit, the default order is NODE. Are you using 32-bit NUMA systems?
Quoted 3 lines
and a
zonelist_orderoption in the first place, and a zonelist instead of a nodelist?
The zonelist ordering is still required to satisfy address-limited allocation requests. If it wasn't, free pages could be managed on a per-node basis.
Quoted 8 lines
I use zonelist_order=n on my NUMA systems and I always liked the LRU to be per-node (despite it uses more CPU when you allocate from a lower classzone as you need to skip the pages of the higher zones not contained in the
classzone_idx). So to be clear I'm not against this work (I tend to believe there are more pros than cons), but to port some code to the node model in the right way, I'd need to do too much work myself on the compaction side.
Compaction working across zones would be nice to have unconditionally. It's ortogonal to whether LRUs are managed per-node or not.
Quoted 4 lines
Also note, the main security left that allows this change to work stable is in the lowmem reserve ratio feature in the page allocator that prevents lower classzones to be completely filled by non movable allocations from higher classzones (i.e. pagetables). As there's no
Quoted 9 lines
priority anymore to start shrinking from the higher zone of the
classzone_idxof the allocation (especially effective logic if using zonelist_order=z which happens to be the default, even though I almost always use zonelist_order=n which in fact already behaved much closer to the new behavior). The removal of the bias against the highest zone to me is the biggest cons in terms of stability in the corner cases, overall but I believe the security of the lowmem reserve ratio should suffice.
It's expected that the lowmem reserve ratio will suffice with the corner case of lowmem-restricted allocations potentially having to sacn more.
Quoted 12 lines
I also expect this work to make negligible difference for those systems where DMA32 and DMA zones don't exist or are tiny, as the node:zone relation is practically already 1:1 there. I believe this actually will help more in systems where the DMA32 zone is relevant if compared to the total memory size (as long as there are not too many DMA32 allocations from pci32 devices, and the zone exists just in case, for an lowmem allocation once in a while). So this isn't a change for the long run, it'll be more noticeable on low end systems or highmem 32bit systems, and it's going to be a noop if you've got a terabytes of RAM (perhaps some pointer dereference is avoided, but that difference should get not measurable).
32-bit systems with large highmem zones are expected to be a rarity. It was a different story 10 years ago. A system with terabytes of RAM is not going to be 32-bit.
Quoted 9 lines
On a side note the compaction enabled
node_reclaimthat makesnode_reclaimfully effective with THP on, works better with zonelist_order=z too, so it should work even better with the node model that practically makes zonelist_order=z impossible to achieve any longer (which also shows it was a bad default and it was good idea to manually set it to =n :). It's just the compaction zone model that forces me to write a for-each-zone loop that isn't ideal and it would defeat the purpose of the node model as far as compaction is concerned.
Compacting across zones was/is a problem regardless of how the LRU is managed.
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 1 line · Mel Gorman
Compaction is not the same as LRU management.
Sure but compaction is invoked by reclaim and if reclaim is node-wide, it makes more sense if compaction would be node-wide as well.
Otherwise what you compact? Just the higher zone, or all of them?
Quoted 7 lines
That is not guaranteed. At the time of migration, it is unknown if the original allocation had addressing limitations or not. I did not audit the address-limited allocations to see if any of them allow migration.
The filesystems would be the ones that need careful auditing. There are some places that add lowmem pages to the LRU but far less obvious if any of them would successfully migrate.
True but that's a tradeoff. This whole patchset is about optimizing the common case of allocations from the highest possible classzone_idx, as if a system has no older hardware, the lowmem classzone_idx allocations practically never happens.
If that tradeoff is valid, retaining migrability of memory allocated not with the highest classzone_idx is an optimization that goes in the opposite direction.
Retaining such "optimization" means increasing the likelihood of succeeding high order allocations from lower zones yes, but it screws with the main concept of:
reclaim node wide at high order -> failure to allocate -> compaction node wide
So if the tradeoff works for reclaim_node I don't see why we should "optimize" for the opposite case in compaction.
Quoted 1 line
That is likely true as long as migration is always towards higher address.
Well with a node-wide LRU we got rid of any "towards higher address" bias. So why to worry about these concepts for high order allocations provided by compaction, if order 0 allocations provided purely by shrink_node won't care at all about such a concept any longer?
It sounds backwards to even worry about "towards higher address" in compaction which is only relevant to provide high order allocations, when the zero order 4kb allocations will not care at all to go "towards higher address" anymore.
Quoted 2 lines
An audit of all additions to the LRU that are address-limited allocations is required to determine if any of those pages can migrate.
Agreed.
Either that or the pageblock needs to be marked with the classzone_idx that it can tolerate. And a per-allocation-classzone highpfn,lowpfn markers needs to be added, instead of being global.
Quoted 2 lines
I'm not sure I understand. The zone allocation preference has the same meaning as it always had.
What I mean is zonelist is like:
=n
[ node0->zone0, node0->zone1, node1->zone0, node1->zone1 ]
or:
=z
[ node0->zone0, node1->zone0, node0->zone1, node1->zone1 ]
So why to call in order (first case above):
1 shrink_node(node0->zone0->node, allocation_classzone_idx /* to limit */) 2 shrink_node(node0->zone1->node, allocation_classzone_idx /* to limit */) 3 shrink_node(node1->zone0->node, allocation_classzone_idx /* to limit */) 4 shrink_node(node1->zone1->node, allocation_classzone_idx /* to limit */)
When in fact 1 and 2 are doing the exact same thing? And 3, 4 are doing the same thing as well? All it matters is the classzone_idx, the zonelist looks irrelevant and an unnecessary repetition.
It's possible I missed something in the code, perhaps I misunderstand how shrink_node is invoked through the zonelist.
This zonelist vs nodelist issue however is orthogonal to the per-zone vs per-node compaction issue discussed earlier.
Quoted 1 line
On 64-bit, the default order is NODE. Are you using 32-bit NUMA systems?
Ah that changed in 3.16 but my grub cmdlines didn't change since then... Good that the default is =n for 64bit indeed.
Quoted 2 lines
The zonelist ordering is still required to satisfy address-limited allocation requests. If it wasn't, free pages could be managed on a per-node basis.
But you pass the node, not the zone, to the shrink_node function, the whole point I'm making is that the "address-limiting" is provided by the classzone_idx alone with your change, not by the zonelist anymore.
static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
There's no zone pointer in "scan control". There's the reclaim_idx (aka classzone_idx, would have been more clear to call it classzone_idx).
Then when isolating you do:
if (page_zonenum(page) > sc->reclaim_idx) {Confirming the limiting factor comes from reclaim_idx (i.e. allocation_classzone_idx).
Again I may be missing something in the code...
Quoted 2 lines
Compacting across zones was/is a problem regardless of how the LRU is managed.
It is a separate problem to make it work, but wanting to making compaction work node-wide is very much a side effect of shrink_node not going serially into zones but going node-wide at all times. Hence it doesn't make sense anymore to only compact a single zone before invoking shrink_node again.
--
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 6 lines · Andrea Arcangeli
Quoted 1 line · Mel Gorman
Compaction is not the same as LRU management.
Sure but compaction is invoked by reclaim and if reclaim is node-wide, it makes more sense if compaction would be node-wide as well.
It might be desirable but it's not necessarily effective. Reclaim/compaction was always, at best, a heuristic that replaced lumpy-reclaim.
Quoted 2 lines
Otherwise what you compact? Just the higher zone, or all of them?
Right now, all of them taking into account whether the compaction is likely to succeed.
Quoted 4 lines
Quoted 4 lines
That is not guaranteed. At the time of migration, it is unknown if the original allocation had addressing limitations or not. I did not audit the address-limited allocations to see if any of them allow migration.
Quoted 9 lines
Quoted 3 lines
The filesystems would be the ones that need careful auditing. There are some places that add lowmem pages to the LRU but far less obvious if any of them would successfully migrate.
True but that's a tradeoff. This whole patchset is about optimizing the common case of allocations from the highest possible
classzone_idx, as if a system has no older hardware, the lowmemclasszone_idxallocations practically never happens.
I'll have to take your word for it. It still is the case that the highest zone is preferred for allocations but the timing will be different due to when reclaim is triggered and what is reclaimed.
As long as it is reclaiming, the page age will still be priority. Unless the LRU is almost perfectly interleaves between zones, the effect of node-reclaim will be that there is a likelihood that reclaim/compaction will succeed for at least one zone with similar success rates to zone reclaim.
Quoted 8 lines
If that tradeoff is valid, retaining migrability of memory allocated not with the highest
classzone_idxis an optimization that goes in the opposite direction.Retaining such "optimization" means increasing the likelihood of succeeding high order allocations from lower zones yes, but it screws with the main concept of:
Quoted 8 lines
reclaim node wide at high order -> failure to allocate -> compaction node wideSo if the tradeoff works for
reclaim_nodeI don't see why we should "optimize" for the opposite case in compaction.Quoted 1 line
That is likely true as long as migration is always towards higher address.
Well with a node-wide LRU we got rid of any "towards higher address"
The allocation preferences of the zonelist continue to favour higher zones. If anything, there is a stronger preference because zone-lru used the fair-zone allocation policy to interleave pages between zones to avoid page age inversion problems with smaller sized high zones.
Quoted 4 lines
bias. So why to worry about these concepts for high order allocations provided by compaction, if order 0 allocations provided purely by
shrink_nodewon't care at all about such a concept any longer?
At worst, reclaim/compaction is slighly weakened. As the reclaim is in LRU order, reclaim/compaction will still make progress for at least one zone at a time.
Quoted 5 lines
It sounds backwards to even worry about "towards higher address" in compaction which is only relevant to provide high order allocations, when the zero order 4kb allocations will not care at all to go "towards higher address" anymore.
Towards higher addresses in compaction is an implementation detail when it's not going across zones. Specifically, it was the easiest way to avoid using the same pageblocks as both migration sources and targets.
Quoted 9 lines
Quoted 2 lines
An audit of all additions to the LRU that are address-limited allocations is required to determine if any of those pages can migrate.
Agreed.
Either that or the pageblock needs to be marked with the
classzone_idxthat it can tolerate. And a per-allocation-classzone highpfn,lowpfn markers needs to be added, instead of being global.
That would be somewhat severe. A single address-restricted allocation would prevent any pages in that pageblock migrating out of the zone. The classzone_idx could only be cleared when the entire pageblock was freed.
Quoted 13 lines
Quoted 2 lines
I'm not sure I understand. The zone allocation preference has the same meaning as it always had.
What I mean is zonelist is like:
=n
[ node0->zone0, node0->zone1, node1->zone0, node1->zone1 ]or:
=z
Quoted 9 lines
[ node0->zone0, node1->zone0, node0->zone1, node1->zone1 ]So why to call in order (first case above):
1 shrink_node(node0->zone0->node, allocation_classzone_idx /* to limit */) 2 shrink_node(node0->zone1->node, allocation_classzone_idx /* to limit */) 3 shrink_node(node1->zone0->node, allocation_classzone_idx /* to limit */) 4 shrink_node(node1->zone1->node, allocation_classzone_idx /* to limit */)
For =n in the direct reclaim case, there is a check to see if the pgdat has changed when reclaming in zonelist order. 1 will call shrink_node, 2 will skip, 3 will shrink_node, 4 will skip.
For =z, shrink_node will be called multiple times but it's also not the default case. If it is a problem then direct reclaim would need to use a bitmask of nodes shrunk during a zonelist traversal.
Quoted 3 lines
It's possible I missed something in the code, perhaps I misunderstand how
shrink_nodeis invoked through the zonelist.
Look for this bit
/*
* 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;
Quoted 7 lines
Quoted 2 lines
The zonelist ordering is still required to satisfy address-limited allocation requests. If it wasn't, free pages could be managed on a per-node basis.
But you pass the node, not the zone, to the
shrink_nodefunction, the whole point I'm making is that the "address-limiting" is provided by theclasszone_idxalone with your change, not by the zonelist anymore.
Quoted 6 lines
static bool
shrink_node(pg_data_t *pgdat, struct scan_control *sc)There's no zone pointer in "scan control". There's the
reclaim_idx(akaclasszone_idx, would have been more clear to call itclasszone_idx).
There is no need for a zone pointer as the reclaim_idx is sufficient. In the node-ordered case, the node will be shrunk once based on the restrictions of reclaim_idx.
Quoted 8 lines
Quoted 2 lines
Compacting across zones was/is a problem regardless of how the LRU is managed.
It is a separate problem to make it work, but wanting to making compaction work node-wide is very much a side effect of
shrink_nodenot going serially into zones but going node-wide at all times. Hence it doesn't make sense anymore to only compact a single zone before invokingshrink_nodeagain.
Calling shrink_node will increase the chance of a single zone successfully compacting. It's not guaranteed to succeed but then again, it never was.
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 07/34] mm, vmscan: make kswapd reclaim in terms of nodes
In reply to Mel GormanQuoted 17 lines
Patch "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
opgdat_balanceddisappears 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.
Quoted 3 lines
Signed-off-by Mel Gorman <[email protected]>Acked-by Johannes Weiner <[email protected]>Acked-by Vlastimil Babka <[email protected]>
This patch seems to hurt FA_DUMP functionality. This behaviour is not seen on v4.7 but only after this patch.
So when a kernel on a multinode machine with memblock_reserve() such that most of the nodes have zero available memory, kswapd seems to be consuming 100% of the time.
This is independent of CONFIG_DEFERRED_STRUCT_PAGE, i.e this problem is seen even with parallel page struct initialization disabled.
top - 13:48:52 up 1:07, 3 users, load average: 15.25, 15.32, 21.18
Tasks: 11080 total, 16 running, 11064 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 2.7 sy, 0.0 ni, 97.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 15929941+total, 8637824 used, 15843563+free, 2304 buffers KiB Swap: 91898816 total, 0 used, 91898816 free. 1381312 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 10824 root 20 0 0 0 0 R 100.000 0.000 65:30.76 kswapd2 10837 root 20 0 0 0 0 R 100.000 0.000 65:31.17 kswapd15 10823 root 20 0 0 0 0 R 97.059 0.000 65:30.85 kswapd1 10825 root 20 0 0 0 0 R 97.059 0.000 65:31.10 kswapd3 10826 root 20 0 0 0 0 R 97.059 0.000 65:31.18 kswapd4 10827 root 20 0 0 0 0 R 97.059 0.000 65:31.08 kswapd5 10828 root 20 0 0 0 0 R 97.059 0.000 65:30.91 kswapd6 10829 root 20 0 0 0 0 R 97.059 0.000 65:31.17 kswapd7 10830 root 20 0 0 0 0 R 97.059 0.000 65:31.17 kswapd8 10831 root 20 0 0 0 0 R 97.059 0.000 65:31.18 kswapd9 10832 root 20 0 0 0 0 R 97.059 0.000 65:31.12 kswapd10 10833 root 20 0 0 0 0 R 97.059 0.000 65:31.19 kswapd11 10834 root 20 0 0 0 0 R 97.059 0.000 65:31.13 kswapd12 10835 root 20 0 0 0 0 R 97.059 0.000 65:31.09 kswapd13 10836 root 20 0 0 0 0 R 97.059 0.000 65:31.18 kswapd14 277155 srikar 20 0 16960 13760 3264 R 52.941 0.001 0:00.37 top
top - 13:48:55 up 1:07, 3 users, load average: 15.23, 15.32, 21.15
Tasks: 11080 total, 16 running, 11064 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 1.0 sy, 0.0 ni, 99.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 15929941+total, 8637824 used, 15843563+free, 2304 buffers KiB Swap: 91898816 total, 0 used, 91898816 free. 1381312 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 10836 root 20 0 0 0 0 R 100.000 0.000 65:33.39 kswapd14 10823 root 20 0 0 0 0 R 100.000 0.000 65:33.05 kswapd1 10824 root 20 0 0 0 0 R 100.000 0.000 65:32.96 kswapd2 10825 root 20 0 0 0 0 R 100.000 0.000 65:33.30 kswapd3 10826 root 20 0 0 0 0 R 100.000 0.000 65:33.38 kswapd4 10827 root 20 0 0 0 0 R 100.000 0.000 65:33.28 kswapd5 10828 root 20 0 0 0 0 R 100.000 0.000 65:33.11 kswapd6 10829 root 20 0 0 0 0 R 100.000 0.000 65:33.37 kswapd7 10830 root 20 0 0 0 0 R 100.000 0.000 65:33.37 kswapd8 10831 root 20 0 0 0 0 R 100.000 0.000 65:33.38 kswapd9 10832 root 20 0 0 0 0 R 100.000 0.000 65:33.32 kswapd10 10833 root 20 0 0 0 0 R 100.000 0.000 65:33.39 kswapd11 10834 root 20 0 0 0 0 R 100.000 0.000 65:33.33 kswapd12 10835 root 20 0 0 0 0 R 100.000 0.000 65:33.29 kswapd13 10837 root 20 0 0 0 0 R 100.000 0.000 65:33.37 kswapd15 277155 srikar 20 0 17536 14912 3264 R 9.091 0.001 0:00.57 top 1092 root rt 0 0 0 0 S 0.455 0.000 0:00.08 watchdog/178
Please see that there is no used swap space. However 15 kswapd threads corresponding to 15 out of the 16 nodes are running full throttle. The only node 0 has memory, other nodes memory is fully reserved.
git bisect output
I tried git bisect between v4.7 and v4.8-rc3 filtered to mm/vmscan.c
# bad: [d7f05528eedb047efe2288cff777676b028747b6] mm, vmscan: account for skipped pages as a partial scan # good: [b1123ea6d3b3da25af5c8a9d843bd07ab63213f4] mm: balloon: use general non-lru movable page feature git bisect start 'HEAD' 'b1123ea6' '--' 'mm/vmscan.c'
# bad: [c4a25635b60d08853a3e4eaae3ab34419a36cfa2] mm: move vmscan writes and file write accounting to the node git bisect bad c4a25635b60d08853a3e4eaae3ab34419a36cfa2
# bad: [38087d9b0360987a6db46c2c2c4ece37cd048abe] mm, vmscan: simplify the logic deciding whether kswapd sleeps git bisect bad 38087d9b0360987a6db46c2c2c4ece37cd048abe
# good: [b2e18757f2c9d1cdd746a882e9878852fdec9501] mm, vmscan: begin reclaiming pages on a per-node basis git bisect good b2e18757f2c9d1cdd746a882e9878852fdec9501
# bad: [1d82de618ddde0f1164e640f79af152f01994c18] mm, vmscan: make kswapd reclaim in terms of nodes git bisect bad 1d82de618ddde0f1164e640f79af152f01994c18
# good: [f7b60926ebc05944f73d93ffaf6690503b796a88] mm, vmscan: have kswapd only scan based on the highest requested zone git bisect good f7b60926ebc05944f73d93ffaf6690503b796a88
# first bad commit: [1d82de618ddde0f1164e640f79af152f01994c18] mm, vmscan: make kswapd reclaim in terms of nodes
Here is perf top output on the kernel where kswapd is hogging cpu.
- 93.50% 0.01% [kernel] [k] kswapd
- kswapd
- 114.31% shrink_node
- 111.51% shrink_node_memcg
- pgdat_reclaimable
- 95.51% pgdat_reclaimable_pages
- 86.34% pgdat_reclaimable_pages
- 6.69% _find_next_bit.part.0
- 2.47% find_next_bit
- 14.46% pgdat_reclaimable 1.13% _find_next_bit.part.0
+ 0.30% find_next_bit
- 2.38% shrink_slab
- super_cache_count
- 0
- __list_lru_count_one.isra.1 _raw_spin_lock
- 28.04% pgdat_reclaimable
- 23.97% pgdat_reclaimable_pages
- 21.66% pgdat_reclaimable_pages
- 1.69% _find_next_bit.part.0 0.63% find_next_bit
- 3.70% pgdat_reclaimable
0.29% _find_next_bit.part.0
- 16.33% zone_balanced
- zone_watermark_ok_safe
- 14.86% zone_watermark_ok_safe 1.15% _find_next_bit.part.0 0.31% find_next_bit
- 2.72% prepare_kswapd_sleep
- zone_balanced
- zone_watermark_ok_safe zone_watermark_ok_safe
- 80.72% 10.51% [kernel] [k] pgdat_reclaimable
- 140.49% pgdat_reclaimable
- 138.40% pgdat_reclaimable_pages
- 125.10% pgdat_reclaimable_pages
- 9.71% _find_next_bit.part.0
- 3.59% find_next_bit
1.64% _find_next_bit.part.0
+ 0.44% find_next_bit
- 21.03% ret_from_kernel_thread
kthread
- kswapd
- 16.75% shrink_node shrink_node_memcg
- 4.28% pgdat_reclaimable pgdat_reclaimable
- 69.17% 62.48% [kernel] [k] pgdat_reclaimable_pages
- 145.91% ret_from_kernel_thread kthread
- 15.61% pgdat_reclaimable_pages
- 11.33% _find_next_bit.part.0
- 4.19% find_next_bit
- 66.18% 0.01% [kernel] [k] shrink_node
- shrink_node
- 157.54% shrink_node_memcg
- pgdat_reclaimable
- 134.94% pgdat_reclaimable_pages
- 121.99% pgdat_reclaimable_pages
- 9.46% _find_next_bit.part.0
- 3.49% find_next_bit
- 20.44% pgdat_reclaimable 1.59% _find_next_bit.part.0
+ 0.42% find_next_bit
- 3.37% shrink_slab
- super_cache_count
- 0
- __list_lru_count_one.isra.1 _raw_spin_lock
- 64.56% 0.03% [kernel] [k] shrink_node_memcg
- shrink_node_memcg
- pgdat_reclaimable
- 138.31% pgdat_reclaimable_pages
- 125.04% pgdat_reclaimable_pages
- 9.69% _find_next_bit.part.0
- 3.58% find_next_bit
- 20.95% pgdat_reclaimable
1.63% _find_next_bit.part.0
+ 0.43% find_next_bit
53.73% 0.00% [kernel] [k] kthread
53.73% 0.00% [kernel] [k] ret_from_kernel_thread
- 11.04% 10.04% [kernel] [k] zone_watermark_ok_safe
- 146.80% ret_from_kernel_thread kthread
- kswapd
- 125.81% zone_balanced zone_watermark_ok_safe
- 20.97% prepare_kswapd_sleep zone_balanced zone_watermark_ok_safe
- 14.55% zone_watermark_ok_safe
11.38% _find_next_bit.part.0
3.06% find_next_bit
- 11.03% 0.00% [kernel] [k] zone_balanced
- zone_balanced
- zone_watermark_ok_safe
145.84% zone_watermark_ok_safe
11.31% _find_next_bit.part.0
3.04% find_next_bitSignature · 2 lines
Thanks and Regards Srikar Dronamraju
Re: [PATCH 07/34] mm, vmscan: make kswapd reclaim in terms of nodes
Quoted 21 lines · Srikar Dronamraju
Quoted 17 lines
Patch "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
opgdat_balanceddisappears 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.Quoted 3 lines
Signed-off-by Mel Gorman <[email protected]>Acked-by Johannes Weiner <[email protected]>Acked-by Vlastimil Babka <[email protected]>
Quoted 7 lines
This patch seems to hurt
FA_DUMPfunctionality. This behaviour is not seen on v4.7 but only after this patch.So when a kernel on a multinode machine with
memblock_reserve()such that most of the nodes have zero available memory, kswapd seems to be consuming 100% of the time.
Why is FA_DUMP specifically the trigger? If the nodes have zero available memory then is the zone_populated() check failing when FA_DUMP is enabled? If so, that would both allow kswapd to wake and stay awake.
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 07/34] mm, vmscan: make kswapd reclaim in terms of nodes
Quoted 4 lines
Quoted 4 lines
This patch seems to hurt
FA_DUMPfunctionality. This behaviour is not seen on v4.7 but only after this patch.
Quoted 9 lines
Quoted 4 lines
So when a kernel on a multinode machine with
memblock_reserve()such that most of the nodes have zero available memory, kswapd seems to be consuming 100% of the time.Why is
FA_DUMPspecifically the trigger? If the nodes have zero available memory then is thezone_populated()check failing whenFA_DUMPis enabled? If so, that would both allow kswapd to wake and stay awake.
The trigger is memblock_reserve() for the complete node memory. And this is exactly what FA_DUMP does. Here again the node has memory but its all reserved so there is no free memory in the node.
Did you mean populated_zone() when you said zone_populated or have I mistaken? populated_zone() does return 1 since it checks for zone->present_pages.
Here is revelant log from the dmesg log at boot
ppc64_pft_size = 0x26 phys_mem_size = 0x1e4600000000 dcache_bsize = 0x80 icache_bsize = 0x80 cpu_features = 0x27fc7aec18500249 possible = 0x3fffffff18500649 always = 0x0000000018100040
cpu_user_features = 0xdc0065c2 0xef000000mmu_features = 0x7c000001firmware_features = 0x00000003c45bfc57htab_hash_mask = 0x7fffffff
-----------------------------------------------------
Node 0 Memory: 0x0-0x1fb50000000 Node 1 Memory: 0x1fb50000000-0x3fa90000000 Node 2 Memory: 0x3fa90000000-0x5f9b0000000 Node 3 Memory: 0x5f9b0000000-0x76850000000 Node 4 Memory: 0x76850000000-0x95020000000 Node 5 Memory: 0x95020000000-0xb37f0000000 Node 6 Memory: 0xb37f0000000-0xd1fc0000000 Node 7 Memory: 0xd1fc0000000-0xf0790000000 Node 8 Memory: 0xf0790000000-0x10ef60000000 Node 9 Memory: 0x10ef60000000-0x12d730000000 Node 10 Memory: 0x12d730000000-0x14bf00000000 Node 11 Memory: 0x14bf00000000-0x16a6d0000000 Node 12 Memory: 0x16a6d0000000-0x188ea0000000 Node 13 Memory: 0x188ea0000000-0x1a7660000000 Node 14 Memory: 0x1a7660000000-0x1c5e30000000 Node 15 Memory: 0x1c5e30000000-0x1e4600000000 numa: Initmem setup node 0 [mem 0x00000000-0x1fb4fffffff] numa: NODE_DATA [mem 0x1837fe23680-0x1837fe2d37f] numa: Initmem setup node 1 [mem 0x1fb50000000-0x3fa8fffffff] numa: NODE_DATA [mem 0x1837fa19980-0x1837fa2367f] numa: NODE_DATA(1) on node 0 numa: Initmem setup node 2 [mem 0x3fa90000000-0x5f9afffffff] numa: NODE_DATA [mem 0x1837f60fc80-0x1837f61997f] numa: NODE_DATA(2) on node 0 numa: Initmem setup node 3 [mem 0x5f9b0000000-0x7684fffffff] numa: NODE_DATA [mem 0x1837f205f80-0x1837f20fc7f] numa: NODE_DATA(3) on node 0 numa: Initmem setup node 4 [mem 0x76850000000-0x9501fffffff] numa: NODE_DATA [mem 0x1837ef1c280-0x1837ef25f7f] numa: NODE_DATA(4) on node 0 numa: Initmem setup node 5 [mem 0x95020000000-0xb37efffffff] numa: NODE_DATA [mem 0x1837eb42580-0x1837eb4c27f] numa: NODE_DATA(5) on node 0 numa: Initmem setup node 6 [mem 0xb37f0000000-0xd1fbfffffff] numa: NODE_DATA [mem 0x1837e778880-0x1837e78257f] numa: NODE_DATA(6) on node 0 numa: Initmem setup node 7 [mem 0xd1fc0000000-0xf078fffffff] numa: NODE_DATA [mem 0x1837e39eb80-0x1837e3a887f] numa: NODE_DATA(7) on node 0 numa: Initmem setup node 8 [mem 0xf0790000000-0x10ef5fffffff] numa: NODE_DATA [mem 0x1837dfc4e80-0x1837dfceb7f] numa: NODE_DATA(8) on node 0 numa: Initmem setup node 9 [mem 0x10ef60000000-0x12d72fffffff] numa: NODE_DATA [mem 0x1837dbeb180-0x1837dbf4e7f] numa: NODE_DATA(9) on node 0 numa: Initmem setup node 10 [mem 0x12d730000000-0x14beffffffff] numa: NODE_DATA [mem 0x1837d811480-0x1837d81b17f] numa: NODE_DATA(10) on node 0 numa: Initmem setup node 11 [mem 0x14bf00000000-0x16a6cfffffff] numa: NODE_DATA [mem 0x1837d437780-0x1837d44147f] numa: NODE_DATA(11) on node 0 numa: Initmem setup node 12 [mem 0x16a6d0000000-0x188e9fffffff] numa: NODE_DATA [mem 0x1837d05da80-0x1837d06777f] numa: NODE_DATA(12) on node 0 numa: Initmem setup node 13 [mem 0x188ea0000000-0x1a765fffffff] numa: NODE_DATA [mem 0x1837cc83d80-0x1837cc8da7f] numa: NODE_DATA(13) on node 0 numa: Initmem setup node 14 [mem 0x1a7660000000-0x1c5e2fffffff] numa: NODE_DATA [mem 0x1837c8aa080-0x1837c8b3d7f] numa: NODE_DATA(14) on node 0 numa: Initmem setup node 15 [mem 0x1c5e30000000-0x1e45ffffffff] numa: NODE_DATA [mem 0x1837c4d0380-0x1837c4da07f] numa: NODE_DATA(15) on node 0
Section 99194 and 99199 (node 0) have a circular dependency on usemap and pgdat allocations node 1 must be removed before remove section 99193
node 1 must be removed before remove section 99194
node 2 must be removed before remove section 99193
node 4 must be removed before remove section 99193
node 8 must be removed before remove section 99193
node 13 must be removed before remove section 99193
PCI host bridge /pci@800000020000032 ranges:
MEM 0x00003fd480000000..0x00003fd4feffffff -> 0x0000000080000000
MEM 0x0000329000000000..0x0000329fffffffff -> 0x0003d29000000000
PCI host bridge /pci@800000020000164 ranges:
MEM 0x00003fc2e0000000..0x00003fc2efffffff -> 0x00000000e0000000
MEM 0x0000305800000000..0x0000305bffffffff -> 0x0003d05800000000
PPC64 nvram contains 15360 bytes
Top of RAM: 0x1e4600000000, Total RAM: 0x1e4600000000
Memory hole size: 0MB
Zone ranges:
DMA [mem 0x0000000000000000-0x00001e45ffffffff] DMA32 empty Normal empty Movable zone start for each node Early memory node ranges node 0: [mem 0x0000000000000000-0x000001fb4fffffff] node 1: [mem 0x000001fb50000000-0x000003fa8fffffff] node 2: [mem 0x000003fa90000000-0x000005f9afffffff] node 3: [mem 0x000005f9b0000000-0x000007684fffffff] node 4: [mem 0x0000076850000000-0x000009501fffffff] node 5: [mem 0x0000095020000000-0x00000b37efffffff] node 6: [mem 0x00000b37f0000000-0x00000d1fbfffffff] node 7: [mem 0x00000d1fc0000000-0x00000f078fffffff] node 8: [mem 0x00000f0790000000-0x000010ef5fffffff] node 9: [mem 0x000010ef60000000-0x000012d72fffffff] node 10: [mem 0x000012d730000000-0x000014beffffffff] node 11: [mem 0x000014bf00000000-0x000016a6cfffffff] node 12: [mem 0x000016a6d0000000-0x0000188e9fffffff] node 13: [mem 0x0000188ea0000000-0x00001a765fffffff] node 14: [mem 0x00001a7660000000-0x00001c5e2fffffff] node 15: [mem 0x00001c5e30000000-0x00001e45ffffffff]
Initmem setup node 0 [mem 0x0000000000000000-0x000001fb4fffffff] On node 0 totalpages: 33247232
DMA zone: 32468 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 33247232 pages, LIFO batch:1
Initmem setup node 1 [mem 0x000001fb50000000-0x000003fa8fffffff] On node 1 totalpages: 33505280
DMA zone: 32720 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 33505280 pages, LIFO batch:1
Initmem setup node 2 [mem 0x000003fa90000000-0x000005f9afffffff] On node 2 totalpages: 33497088
DMA zone: 32712 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 33497088 pages, LIFO batch:1
Initmem setup node 3 [mem 0x000005f9b0000000-0x000007684fffffff] On node 3 totalpages: 24027136
DMA zone: 23464 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 24027136 pages, LIFO batch:1
Initmem setup node 4 [mem 0x0000076850000000-0x000009501fffffff] On node 4 totalpages: 31969280
DMA zone: 31220 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 31969280 pages, LIFO batch:1
Initmem setup node 5 [mem 0x0000095020000000-0x00000b37efffffff] On node 5 totalpages: 31969280
DMA zone: 31220 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 31969280 pages, LIFO batch:1
Initmem setup node 6 [mem 0x00000b37f0000000-0x00000d1fbfffffff] On node 6 totalpages: 31969280
DMA zone: 31220 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 31969280 pages, LIFO batch:1
Initmem setup node 7 [mem 0x00000d1fc0000000-0x00000f078fffffff] On node 7 totalpages: 31969280
DMA zone: 31220 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 31969280 pages, LIFO batch:1
Initmem setup node 8 [mem 0x00000f0790000000-0x000010ef5fffffff] On node 8 totalpages: 31969280
DMA zone: 31220 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 31969280 pages, LIFO batch:1
Initmem setup node 9 [mem 0x000010ef60000000-0x000012d72fffffff] On node 9 totalpages: 31969280
DMA zone: 31220 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 31969280 pages, LIFO batch:1
Initmem setup node 10 [mem 0x000012d730000000-0x000014beffffffff] On node 10 totalpages: 31969280
DMA zone: 31220 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 31969280 pages, LIFO batch:1
Initmem setup node 11 [mem 0x000014bf00000000-0x000016a6cfffffff] On node 11 totalpages: 31969280
DMA zone: 31220 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 31969280 pages, LIFO batch:1
Initmem setup node 12 [mem 0x000016a6d0000000-0x0000188e9fffffff] On node 12 totalpages: 31969280
DMA zone: 31220 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 31969280 pages, LIFO batch:1
Initmem setup node 13 [mem 0x0000188ea0000000-0x00001a765fffffff] On node 13 totalpages: 31965184
DMA zone: 31216 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 31965184 pages, LIFO batch:1
Initmem setup node 14 [mem 0x00001a7660000000-0x00001c5e2fffffff] On node 14 totalpages: 31969280
DMA zone: 31220 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 31969280 pages, LIFO batch:1
Initmem setup node 15 [mem 0x00001c5e30000000-0x00001e45ffffffff] On node 15 totalpages: 31969280
DMA zone: 31220 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 31969280 pages, LIFO batch:1
Signature · 8 lines
Thanks and Regards Srikar Dronamraju -- 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 07/34] mm, vmscan: make kswapd reclaim in terms of nodes
Quoted 14 lines · Srikar Dronamraju
Quoted 4 lines
Quoted 4 lines
This patch seems to hurt
FA_DUMPfunctionality. This behaviour is not seen on v4.7 but only after this patch.Quoted 9 lines
Quoted 4 lines
So when a kernel on a multinode machine with
memblock_reserve()such that most of the nodes have zero available memory, kswapd seems to be consuming 100% of the time.Why is
FA_DUMPspecifically the trigger? If the nodes have zero available memory then is thezone_populated()check failing whenFA_DUMPis enabled? If so, that would both allow kswapd to wake and stay awake.
Quoted 8 lines
The trigger is
memblock_reserve()for the complete node memory. And this is exactly whatFA_DUMPdoes. Here again the node has memory but its all reserved so there is no free memory in the node.Did you mean
populated_zone()when you saidzone_populatedor have I mistaken?populated_zone()does return 1 since it checks forzone->present_pages.
Yes, I meant populated_zone(). Using present pages may have hidden a long-lived corner case as it was unexpected that an entire node would be reserved. The old code happened to survive *probably* because pgdat_reclaimable would look false and kswapd checks for pgdat being balanced would happen to do the right thing in this case.
Can you check if something like this works?
include/linux/mmzone.h +1 -1
@@ -830,7 +830,7 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);static inline int populated_zone (struct zone *zone) { -return (!!zone->present_pages); +return (!!zone->managed_pages); }extern int movable_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>
Srikar Dronamraju
Tested-byRe: [PATCH 07/34] mm, vmscan: make kswapd reclaim in terms of nodes
Quoted 23 lines
Quoted 8 lines
The trigger is
memblock_reserve()for the complete node memory. And this is exactly whatFA_DUMPdoes. Here again the node has memory but its all reserved so there is no free memory in the node.Did you mean
populated_zone()when you saidzone_populatedor have I mistaken?populated_zone()does return 1 since it checks forzone->present_pages.Yes, I meant
populated_zone(). Using present pages may have hidden a long-lived corner case as it was unexpected that an entire node would be reserved. The old code happened to survive *probably* becausepgdat_reclaimablewould look false and kswapd checks for pgdat being balanced would happen to do the right thing in this case.Can you check if something like this works?
include/linux/mmzone.h +0
-0
include/linux/mmzone.h unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long); · line 836
Quoted 8 lines
include/linux/mmzone.h +1
-1@@ -830,7 +830,7 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);static inline int populated_zone (struct zone *zone) { -return (!!zone->present_pages); +return (!!zone->managed_pages); }extern int movable_zone;
This indeed fixes the problem.
Please add my
--
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 07/34] mm, vmscan: make kswapd reclaim in terms of nodes
Quoted 4 lines · Srikar Dronamraju
This indeed fixes the problem.
Please add myTested-by Srikar Dronamraju <[email protected]>
Ok, thanks. Unfortunately we cannot do a wide conversion like this because some users of populated_zone() really meant to check for present_pages. In all cases, the expectation was that reserved pages would be tiny but fadump messes that up. Can you verify this also works please?
---8<---
mm, vmscan: Only allocate and reclaim from zones with pages managed by the buddy allocator
Firmware Assisted Dump (FA_DUMP) on ppc64 reserves substantial amounts of memory when booting a secondary kernel. Srikar Dronamraju reported that multiple nodes may have no memory managed by the buddy allocator but still return true for populated_zone().
Commit 1d82de618ddd ("mm, vmscan: make kswapd reclaim in terms of nodes") was reported to cause kswapd to spin at 100% CPU usage when fadump was enabled. The old code happened to deal with the situation of a populated node with zero free pages by co-incidence but the current code tries to reclaim populated zones without realising that is impossible.
We cannot just convert populated_zone() as many existing users really need to check for present_pages. This patch introduces a managed_zone() helper and uses it in the few cases where it is critical that the check is made for managed pages -- zonelist constuction and page reclaim.
--- include/linux/mmzone.h | 11 +++++++++-- mm/page_alloc.c | 4 ++-- mm/vmscan.c | 22 +++++++++++----------- 3 files changed, 22 insertions(+), 15 deletions(-)
include/linux/mmzone.h +9 -2
@@ -828,9 +828,16 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);*/ #define zone_idx (zone) ((zone) - (zone)->zone_pgdat->node_zones) -static inline int populated_zone (struct zone *zone) +/* Returns true if a zone has pages managed by the buddy allocator */ +static inline bool managed_zone (struct zone *zone) { -return (!!zone->present_pages); +return zone->managed_pages; +} + +/* Returns true if a zone has memory */ +static inline bool populated_zone (struct zone *zone) +{ +return zone->present_pages; }extern int movable_zone;
mm/page_alloc.c +2 -2
@@ -4405,7 +4405,7 @@ static int build_zonelists_node(pg_data_t *pgdat, struct zonelist *zonelist, do { zone_type--; zone = pgdat->node_zones + zone_type; - if (populated_zone(zone)) { + if (managed_zone(zone)) { zoneref_set_zone(zone, &zonelist->_zonerefs[nr_zones++]); check_highest_zone(zone_type);
@@ -4643,7 +4643,7 @@ static void build_zonelists_in_zone_order(pg_data_t *pgdat, int nr_nodes)for (j =0 ; j < nr_nodes; j++) { node = node_order[j]; z = &NODE_DATA (node)->node_zones[zone_type]; -if (populated_zone (z)) { +if (managed_zone (z)) {zoneref_set_zone (z, &zonelist->_zonerefs[pos++]);check_highest_zone (zone_type);
mm/vmscan.c +11 -11
@@ -1665,7 +1665,7 @@ static bool inactive_reclaimable_pages(struct lruvec *lruvec,for (zid = sc->reclaim_idx; zid >=0 ; zid--) { zone = &pgdat->node_zones[zid]; -if (!populated_zone (zone)) +if (!managed_zone (zone))continue ; if (zone_page_state_snapshot(zone, NR_ZONE_LRU_BASE +
@@ -2036,7 +2036,7 @@ static bool inactive_list_is_low(struct lruvec *lruvec, bool file,struct zone *zone = &pgdat->node_zones[zid];unsigned long inactive_zone, active_zone; -if (!populated_zone (zone)) +if (!managed_zone (zone))continue ; inactive_zone = zone_page_state(zone,
@@ -2171,7 +2171,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg,for (z =0 ; z <MAX_NR_ZONES ; z++) {struct zone *zone = &pgdat->node_zones[z]; -if (!populated_zone (zone)) +if (!managed_zone (zone))continue ; total_high_wmark +=high_wmark_pages (zone);
@@ -2508,7 +2508,7 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat,/* If compaction would go ahead or the allocation would succeed, stop */ for (z =0 ; z <= sc->reclaim_idx; z++) {struct zone *zone = &pgdat->node_zones[z]; -if (!populated_zone (zone)) +if (!managed_zone (zone))continue ;switch (compaction_suitable (zone, sc->order,0 , sc->reclaim_idx)) {
@@ -2835,7 +2835,7 @@ static bool pfmemalloc_watermark_ok(pg_data_t *pgdat)for (i =0 ; i <=ZONE_NORMAL ; i++) { zone = &pgdat->node_zones[i]; -if (!populated_zone (zone) || +if (!managed_zone (zone) ||pgdat_reclaimable_pages (pgdat) ==0 )continue ;
@@ -3136,7 +3136,7 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, int classzone_idx)for (i =0 ; i <= classzone_idx; i++) {struct zone *zone = pgdat->node_zones + i; -if (!populated_zone (zone)) +if (!managed_zone (zone))continue ;if (!zone_balanced (zone, order, classzone_idx))
@@ -3164,7 +3164,7 @@ static bool kswapd_shrink_node(pg_data_t *pgdat, sc->nr_to_reclaim =0 ;for (z =0 ; z <= sc->reclaim_idx; z++) { zone = pgdat->node_zones + z; -if (!populated_zone (zone)) +if (!managed_zone (zone))continue ; sc->nr_to_reclaim +=max (high_wmark_pages (zone),SWAP_CLUSTER_MAX );
@@ -3237,7 +3237,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)if (buffer_heads_over_limit) {for (i =MAX_NR_ZONES -1 ; i >=0 ; i--) { zone = pgdat->node_zones + i; -if (!populated_zone (zone)) +if (!managed_zone (zone))continue ; sc.reclaim_idx = i;
@@ -3257,7 +3257,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)*/ for (i = classzone_idx; i >=0 ; i--) { zone = pgdat->node_zones + i; -if (!populated_zone (zone)) +if (!managed_zone (zone))continue ;if (zone_balanced (zone, sc.order, classzone_idx))
@@ -3503,7 +3503,7 @@ void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx)pg_data_t *pgdat;int z; -if (!populated_zone (zone)) +if (!managed_zone (zone))return ;if (!cpuset_zone_allowed (zone,GFP_KERNEL | __GFP_HARDWALL))
@@ -3517,7 +3517,7 @@ void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx)/* Only wake kswapd if all zones are unbalanced */ for (z =0 ; z <= classzone_idx; z++) { zone = pgdat->node_zones + z; -if (!populated_zone (zone)) +if (!managed_zone (zone))continue ;if (zone_balanced (zone, order, 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>
Re: [PATCH 07/34] mm, vmscan: make kswapd reclaim in terms of nodes
Quoted 26 lines · Mel Gorman
Quoted 4 lines · Srikar Dronamraju
This indeed fixes the problem.
Please add myTested-by Srikar Dronamraju <[email protected]>Ok, thanks. Unfortunately we cannot do a wide conversion like this because some users of
populated_zone()really meant to check forpresent_pages. In all cases, the expectation was that reserved pages would be tiny but fadump messes that up. Can you verify this also works please?---8<---
mm, vmscan: Only allocate and reclaim from zones with pages managed by the buddy allocatorFirmware Assisted Dump (
FA_DUMP) on ppc64 reserves substantial amounts of memory when booting a secondary kernel. Srikar Dronamraju reported that multiple nodes may have no memory managed by the buddy allocator but still return true forpopulated_zone().Commit
1d82de618ddd("mm, vmscan: make kswapd reclaim in terms of nodes") was reported to cause kswapd to spin at 100% CPU usage when fadump was enabled. The old code happened to deal with the situation of a populated node with zero free pages by co-incidence but the current code tries to reclaim populated zones without realising that is impossible.
Quoted 4 lines
We cannot just convert
populated_zone()as many existing users really need to check forpresent_pages. This patch introduces amanaged_zone()helper and uses it in the few cases where it is critical that the check is made for managed pages -- zonelist constuction and page reclaim.
OK, the patch makes sense to me. I am not happy about two very similar functions, to be honest though. managed vs. present checks will be quite subtle and it is not entirely clear when to use which one. I agree that the reclaim path is the most critical one so the patch seems OK to me. At least from a quick glance it should help with the reported issue so feel free to add
I expect we might want to turn other places as well but they are far from critical. I would appreciate some lead there and stick a clarifying comment
[...]
include/linux/mmzone.h unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long); · line 831
Quoted 2 lines
include/linux/mmzone.h +1
-1-static inline int populated_zone (struct zone *zone) +/* Returns true if a zone has pages managed by the buddy allocator */
/*
* Returns true if a zone has pages managed by the buddy allocator.
* All the reclaim decisions have to use this function rather than
* populated_zone(). If the whole zone is reserved then we can easily
* end up with populated_zone() && !managed_zone().
*/
What do you think?
Quoted 11 lines
include/linux/mmzone.h +8
-1+static inline bool managed_zone (struct zone *zone) { -return (!!zone->present_pages); +return zone->managed_pages; +} + +/* Returns true if a zone has memory */ +static inline bool populated_zone (struct zone *zone) +{ +return zone->present_pages; }
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 07/34] mm, vmscan: make kswapd reclaim in terms of nodes
Quoted 8 lines · Michal Hocko
Quoted 4 lines
We cannot just convert
populated_zone()as many existing users really need to check forpresent_pages. This patch introduces amanaged_zone()helper and uses it in the few cases where it is critical that the check is made for managed pages -- zonelist constuction and page reclaim.OK, the patch makes sense to me. I am not happy about two very similar functions, to be honest though. managed vs. present checks will be quite subtle and it is not entirely clear when to use which one.
In the vast majority of cases, the distinction is irrelevant. The patch only updates the places where it really matters to minimise any confusion.
Quoted 1 line
Acked-by Michal Hocko <[email protected]>
Thanks.
Quoted 9 lines
/*
* Returns true if a zone has pages managed by the buddy allocator.
* All the reclaim decisions have to use this function rather than
*populated_zone(). If the whole zone is reserved then we can easily
* end up withpopulated_zone()&& !managed_zone().
*/What do you think?
This makes a lot of sense. I've updated the patch and will await a test from Srikar before reposting.
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 07/34] mm, vmscan: make kswapd reclaim in terms of nodes
In reply to Mel GormanQuoted 13 lines
mm, vmscan: Only allocate and reclaim from zones with pages managed by the buddy allocator
Firmware Assisted Dump (
FA_DUMP) on ppc64 reserves substantial amounts of memory when booting a secondary kernel. Srikar Dronamraju reported that multiple nodes may have no memory managed by the buddy allocator but still return true forpopulated_zone().Commit
1d82de618ddd("mm, vmscan: make kswapd reclaim in terms of nodes") was reported to cause kswapd to spin at 100% CPU usage when fadump was enabled. The old code happened to deal with the situation of a populated node with zero free pages by co-incidence but the current code tries to reclaim populated zones without realising that is impossible.
Quoted 4 lines
We cannot just convert
populated_zone()as many existing users really need to check forpresent_pages. This patch introduces amanaged_zone()helper and uses it in the few cases where it is critical that the check is made for managed pages -- zonelist constuction and page reclaim.
one nit
s/constuction/construction/
Quoted 1 line
Verified that it works fine.
Signature · 8 lines
Thanks and Regards Srikar Dronamraju -- 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>