Skip to content

Move LRU page reclaim from zones to nodes v6

Mel Gorman linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest27 patches 42 repliesIn review

Changelog since v5 from the cover letter

o Rebase and adjust to changes

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/27mm, vmstat: Add infrastructure for per-node vmstatsdrivers/base/node.c include/linux/mmzone.h include/linux/vmstat.h +3 more+404 -744 replies
2/27mm, vmscan: Move lru_lock to the nodeDocumentation/cgroup-v1/memcg_test.txt Documentation/cgroup-v1/memory.txt include/linux/mm_types.h +11 more+74 -683 replies
3/27mm, vmscan: Move LRU lists to nodearch/tile/mm/pgtable.c drivers/base/node.c drivers/staging/android/lowmemorykiller.c +25 more+361 -2931 reply
4/27mm, vmscan: Begin reclaiming pages on a per-node basismm/vmscan.c+47 -251 reply
5/27mm, vmscan: Have kswapd only scan based on the highest requested zonemm/vmscan.c+2 -52 replies
6/27mm, vmscan: Make kswapd reclaim in terms of nodesmm/vmscan.c+101 -1911 reply
7/27mm, vmscan: Remove balance gapmm/vmscan.c+8 -111 reply
8/27mm, vmscan: Simplify the logic deciding whether kswapd sleepsinclude/linux/mmzone.h mm/memory_hotplug.c mm/page_alloc.c +1 more+46 -453 replies
9/27mm, vmscan: By default have direct reclaim only shrink once per nodemm/vmscan.c+11 -91 reply
10/27mm, vmscan: Clear congestion, dirty and need for compaction on a per-node basismm/vmscan.c+12 -122 replies
11/27mm: vmscan: Do not reclaim from kswapd if there is any eligible zonemm/vmscan.c+19 -131 reply
12/27mm, vmscan: Make shrink_node decisions more node-centricinclude/linux/memcontrol.h include/linux/mmzone.h include/linux/swap.h +4 more+54 -442 replies
13/27mm, memcg: Move memcg limit enforcement from zones to nodesinclude/linux/memcontrol.h include/linux/swap.h mm/memcontrol.c +2 more+110 -1442 replies
14/27mm, workingset: Make working set detection node-awareinclude/linux/mmzone.h include/linux/vmstat.h mm/vmstat.c +1 more+24 -422 replies
15/27mm, page_alloc: Consider dirtyable memory in terms of nodesinclude/linux/mmzone.h include/linux/writeback.h mm/page-writeback.c +1 more+67 -671 reply
16/27mm: Move page mapped accounting to the nodearch/tile/mm/pgtable.c drivers/base/node.c fs/proc/meminfo.c +5 more+21 -202 replies
17/27mm: Rename NR_ANON_PAGES to NR_ANON_MAPPEDdrivers/base/node.c fs/proc/meminfo.c include/linux/mmzone.h +2 more+8 -81 reply
18/27mm: Move most file-based accounting to the nodearch/s390/appldata/appldata_mem.c arch/tile/mm/pgtable.c drivers/base/node.c +17 more+103 -1111 reply
19/27mm: Move vmscan writes and file write accounting to the nodeinclude/linux/mmzone.h include/trace/events/writeback.h mm/page-writeback.c +2 more+15 -151 reply
20/27mm, vmscan: Update classzone_idx if buffer_heads_over_limitmm/vmscan.c+3 -11 reply
21/27mm, vmscan: Only wakeup kswapd once per node for the requested classzonemm/vmscan.c+11 -22 replies
22/27mm: Convert zone_reclaim to node_reclaiminclude/linux/mmzone.h include/linux/swap.h include/linux/topology.h +5 more+77 -691 reply
23/27mm, vmscan: Add classzone information to tracepointsinclude/trace/events/vmscan.h mm/vmscan.c+20 -121 reply
24/27mm, page_alloc: Remove fair zone allocation policyinclude/linux/mmzone.h mm/internal.h mm/page_alloc.c +1 more+2 -802 replies
25/27mm: page_alloc: Cache the last node whose dirty limit is reachedmm/page_alloc.c+11 -21 reply
26/27mm: vmstat: Replace __count_zone_vm_events with a zone id equivalentinclude/linux/vmstat.h mm/page_alloc.c+3 -41 reply
27/27mm: vmstat: Account per-zone stalls and pages skipped during reclaiminclude/linux/vm_event_item.h mm/huge_memory.c mm/vmscan.c +1 more+33 -81 reply

Reviews trailers per patch

22 of 27 patches have a Reviewed-by or Acked-by.

PatchJohannes WeinerVlastimil Babka
1/27A-b A-b
2/27A-b A-b
3/27A-b
4/27
5/27A-b
6/27A-b A-b
7/27A-b
8/27A-b
9/27A-b A-b
10/27
11/27A-b
12/27
13/27
14/27A-b A-b
15/27A-b
16/27A-b
17/27A-b
18/27A-b
19/27A-b
20/27A-b
21/27
22/27A-b
23/27A-b
24/27A-b
25/27A-b
26/27A-b
27/27A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/27] Move LRU page reclaim from zones to nodes v6

This is only lightly tested as I've had stability problems during boot that have nothing to do with the series. It's based on mmots as of June 6th. Very little has changed with the big exception of "mm, vmscan:
Move LRU lists to node" because it had to adapt to per-zone changes in should_reclaim_retry and compaction_zonelist_suitable.

Changelog since v5
o Rebase and adjust to changes

Changelog since v4
o Rebase on top of v3 of page allocator optimisation series

Changelog since v3
o Rebase on top of the page allocator optimisation series
o Remove RFC tag

This is the latest version of a series that moves LRUs from the zones to the node that is based upon 4.6-rc3 plus the page allocator optimisation series. Conceptually, this is simple but there are a lot of details. Some of the broad motivations for this are;

1. The residency of a page partially depends on what zone the page was allocated from. This is partially combatted by the fair zone allocation policy but that is a partial solution that introduces overhead in the page allocator paths.

2. Currently, reclaim on node 0 behaves slightly different to node 1. For example, direct reclaim scans in zonelist order and reclaims even if the zone is over the high watermark regardless of the age of pages in that LRU. Kswapd on the other hand starts reclaim on the highest unbalanced zone. A difference in distribution of file/anon pages due to when they were allocated results can result in a difference in again. While the fair zone allocation policy mitigates some of the problems here, the page reclaim results on a multi-zone node will always be different to a single-zone node.
it was scheduled on as a result.

3. kswapd and the page allocator scan zones in the opposite order to avoid interfering with each other but it's sensitive to timing. This mitigates the page allocator using pages that were allocated very recently in the ideal case but it's sensitive to timing. When kswapd is allocating from lower zones then it's great but during the rebalancing of the highest zone, the page allocator and kswapd interfere with each other. It's worse if the highest zone is small and difficult to balance.

4. slab shrinkers are node-based which makes it harder to identify the exact relationship between slab reclaim and LRU reclaim.

The reason we have zone-based reclaim is that we used to have large highmem zones in common configurations and it was necessary to quickly find ZONE_NORMAL pages for reclaim. Today, this is much less of a concern as machines with lots of memory will (or should) use 64-bit kernels. Combinations of 32-bit hardware and 64-bit hardware are rare. Machines that do use highmem should have relatively low highmem:lowmem ratios than we worried about in the past.

Conceptually, moving to node LRUs should be easier to understand. The page allocator plays fewer tricks to game reclaim and reclaim behaves similarly on all nodes.

The series got basic testing this time on a UMA machine. The page allocator microbenchmark highlights the gain from removing the fair zone allocation policy

                                           4.7.0-rc2                  4.7.0-rc2
                                      mmotm-20160606               nodelru-v6r2
Min      total-odr0-1               500.00 (  0.00%)           475.00 (  5.00%)
Min      total-odr0-2               358.00 (  0.00%)           343.00 (  4.19%)
Min      total-odr0-4               292.00 (  0.00%)           279.00 (  4.45%)
Min      total-odr0-8               253.00 (  0.00%)           242.00 (  4.35%)
Min      total-odr0-16              275.00 (  0.00%)           226.00 ( 17.82%)
Min      total-odr0-32              225.00 (  0.00%)           215.00 (  4.44%)
Min      total-odr0-64              219.00 (  0.00%)           210.00 (  4.11%)
Min      total-odr0-128             216.00 (  0.00%)           207.00 (  4.17%)
Min      total-odr0-256             243.00 (  0.00%)           246.00 ( -1.23%)
Min      total-odr0-512             276.00 (  0.00%)           265.00 (  3.99%)
Min      total-odr0-1024            290.00 (  0.00%)           287.00 (  1.03%)
Min      total-odr0-2048            303.00 (  0.00%)           296.00 (  2.31%)
Min      total-odr0-4096            312.00 (  0.00%)           310.00 (  0.64%)
Min      total-odr0-8192            320.00 (  0.00%)           308.00 (  3.75%)
Min      total-odr0-16384           320.00 (  0.00%)           308.00 (  3.75%)
Min      total-odr1-1               737.00 (  0.00%)           707.00 (  4.07%)
Min      total-odr1-2               547.00 (  0.00%)           521.00 (  4.75%)
Min      total-odr1-4               620.00 (  0.00%)           418.00 ( 32.58%)
Min      total-odr1-8               386.00 (  0.00%)           367.00 (  4.92%)
Min      total-odr1-16              361.00 (  0.00%)           340.00 (  5.82%)
Min      total-odr1-32              352.00 (  0.00%)           328.00 (  6.82%)
Min      total-odr1-64              345.00 (  0.00%)           324.00 (  6.09%)
Min      total-odr1-128             347.00 (  0.00%)           328.00 (  5.48%)
Min      total-odr1-256             347.00 (  0.00%)           329.00 (  5.19%)
Min      total-odr1-512             354.00 (  0.00%)           332.00 (  6.21%)
Min      total-odr1-1024            355.00 (  0.00%)           337.00 (  5.07%)
Min      total-odr1-2048            358.00 (  0.00%)           345.00 (  3.63%)
Min      total-odr1-4096            360.00 (  0.00%)           346.00 (  3.89%)
Min      total-odr1-8192            360.00 (  0.00%)           347.00 (  3.61%)

A basic IO benchmark based on varying numbers of dd running in parallel showed nothing interesting other than differences in what zones were scanned due to the fair zone allocation policy being removed.

This series is not without its hazards. There are at least three areas that I'm concerned with even though I could not reproduce any problems in that area.

1. Reclaim/compaction is going to be affected because the amount of reclaim is no longer targetted at a specific zone. Compaction works on a per-zone basis so there is no guarantee that reclaiming a few THP's worth page pages will have a positive impact on compaction success rates.

2. The Slab/LRU reclaim ratio is affected because the frequency the shrinkers are called is now different. This may or may not be a problem but if it is, it'll be because shrinkers are not called enough and some balancing is required.

3. The anon/file reclaim ratio may be affected. Pages about to be dirtied are distributed between zones and the fair zone allocation policy used to do something very similar for anon. The distribution is now different but not necessarily in any way that matters but it's still worth bearing in mind.

 Documentation/cgroup-v1/memcg_test.txt    |   4 +-
 Documentation/cgroup-v1/memory.txt        |   4 +-
 arch/s390/appldata/appldata_mem.c         |   2 +-
 arch/tile/mm/pgtable.c                    |  18 +-
 drivers/base/node.c                       |  73 +--
 drivers/staging/android/lowmemorykiller.c |  12 +-
 fs/fs-writeback.c                         |   4 +-
 fs/fuse/file.c                            |   8 +-
 fs/nfs/internal.h                         |   2 +-
 fs/nfs/write.c                            |   2 +-
 fs/proc/meminfo.c                         |  14 +-
 include/linux/backing-dev.h               |   2 +-
 include/linux/memcontrol.h                |  30 +-
 include/linux/mm_inline.h                 |   2 +-
 include/linux/mm_types.h                  |   2 +-
 include/linux/mmzone.h                    | 157 +++---
 include/linux/swap.h                      |  15 +-
 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             |  40 +-
 include/trace/events/writeback.h          |  10 +-
 kernel/power/snapshot.c                   |  10 +-
 kernel/sysctl.c                           |   4 +-
 mm/backing-dev.c                          |  15 +-
 mm/compaction.c                           |  39 +-
 mm/filemap.c                              |  14 +-
 mm/huge_memory.c                          |  33 +-
 mm/internal.h                             |  11 +-
 mm/memcontrol.c                           | 235 ++++-----
 mm/memory-failure.c                       |   4 +-
 mm/memory_hotplug.c                       |   7 +-
 mm/mempolicy.c                            |   2 +-
 mm/migrate.c                              |  35 +-
 mm/mlock.c                                |  12 +-
 mm/page-writeback.c                       | 124 +++--
 mm/page_alloc.c                           | 271 +++++-----
 mm/page_idle.c                            |   4 +-
 mm/rmap.c                                 |  15 +-
 mm/shmem.c                                |  12 +-
 mm/swap.c                                 |  66 +--
 mm/swap_state.c                           |   4 +-
 mm/util.c                                 |   4 +-
 mm/vmscan.c                               | 829 +++++++++++++++---------------
 mm/vmstat.c                               | 374 +++++++++++---
 mm/workingset.c                           |  52 +-
 47 files changed, 1489 insertions(+), 1217 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>