Skip to content

RFC Accelerate page migration and use memcg for PMEM management

Zi Yan linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest25 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/25mm: migrate: Change migrate_mode to support combination migration modes.fs/aio.c fs/f2fs/data.c fs/hugetlbfs/inode.c +7 more+34 -320 replies
2/25mm: migrate: Add mode parameter to support future page copy routines.fs/aio.c fs/f2fs/data.c fs/hugetlbfs/inode.c +5 more+20 -130 replies
3/25mm: migrate: Add a multi-threaded page migration function.include/linux/highmem.h mm/Makefile mm/copy_page.c+132 -00 replies
4/25mm: migrate: Add copy_page_multithread into migrate_pages.include/linux/migrate_mode.h include/uapi/linux/mempolicy.h mm/migrate.c+22 -100 replies
5/25mm: migrate: Add vm.accel_page_copy in sysfs to control page copy acceleration.kernel/sysctl.c mm/migrate.c+17 -00 replies
6/25mm: migrate: Make the number of copy threads adjustable via sysctl.kernel/sysctl.c mm/copy_page.c+10 -10 replies
7/25mm: migrate: Add copy_page_dma to use DMA Engine to copy pages.include/linux/highmem.h include/linux/sched/sysctl.h kernel/sysctl.c +1 more+314 -00 replies
8/25mm: migrate: Add copy_page_dma into migrate_page_copy.include/linux/migrate_mode.h include/uapi/linux/mempolicy.h mm/migrate.c+23 -100 replies
9/25mm: migrate: Add copy_page_lists_dma_always to support copy a list of pages.mm/copy_page.c mm/internal.h+170 -00 replies
10/25mm: migrate: copy_page_lists_mt() to copy a page list using multi-threads.mm/copy_page.c mm/internal.h+125 -00 replies
11/25mm: migrate: Add concurrent page migration into move_pages syscall.include/linux/migrate.h include/linux/migrate_mode.h include/uapi/linux/mempolicy.h +1 more+542 -90 replies
12/25exchange pages: new page migration mechanism: exchange_pages()include/linux/exchange.h include/linux/ksm.h mm/Makefile +2 more+660 -00 replies
13/25exchange pages: add multi-threaded exchange pages.mm/Makefile mm/exchange.c mm/exchange_page.c +1 more+245 -50 replies
14/25exchange pages: concurrent exchange pages.include/linux/exchange.h mm/exchange.c mm/exchange_page.c+399 -10 replies
15/25exchange pages: exchange anonymous page and file-backed page.mm/exchange.c mm/internal.h mm/migrate.c+241 -580 replies
16/25exchange page: Add THP exchange support.include/linux/exchange.h mm/exchange.c mm/migrate.c+60 -170 replies
17/25exchange page: Add exchange_page() syscall.arch/x86/entry/syscalls/syscall_64.tbl include/linux/syscalls.h mm/exchange.c+352 -00 replies
18/25memcg: Add per node memory usage&max stats in memcg.include/linux/cgroup-defs.h include/linux/memcontrol.h mm/memcontrol.c+148 -00 replies
19/25mempolicy: add MPOL_F_MEMCG flag, enforcing memcg memory limit.include/uapi/linux/mempolicy.h mm/mempolicy.c+38 -10 replies
20/25memory manage: Add memory manage syscall.arch/x86/entry/syscalls/syscall_64.tbl include/linux/sched/coredump.h include/linux/syscalls.h +5 more+121 -10 replies
21/25mm: move update_lru_sizes() to mm_inline.h for broader use.include/linux/mm_inline.h mm/vmscan.c+23 -230 replies
22/25memory manage: active/inactive page list manipulation in memcg.include/uapi/linux/mempolicy.h mm/internal.h mm/memory_manage.c +1 more+184 -760 replies
23/25memory manage: page migration based page manipulation between NUMA nodes.mm/memory_manage.c+275 -00 replies
24/25memory manage: limit migration batch size.kernel/sysctl.c mm/memory_manage.c+48 -200 replies
25/25memory manage: use exchange pages to memory manage to improve throughput.mm/memory_manage.c+173 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 00/25] Accelerate page migration and use memcg for PMEM management

From: Zi Yan <[email protected]>

Thanks to Dave Hansen's patches, which make PMEM as part of memory as NUMA nodes. How to use PMEM along with normal DRAM remains an open problem. There are several patchsets posted on the mailing list, proposing to use page migration to move pages between PMEM and DRAM using Linux page replacement policy [1,2,3]. There are some important problems not addressed in these patches:
1. The page migration in Linux does not provide high enough throughput for us to fully exploit PMEM or other use cases.
2. Linux page replacement is running too infrequent to distinguish hot and cold pages.

I am trying to attack the problems with this patch series. This is not a final solution, but I would like to gather more feedback and comments from the mailing list.

Page migration throughput problem
====

For example, in my recent email [4], I gave the page migration throughput numbers for different page migrations, none of which can achieve > 2.5GB/s throughput (the throughput is measured around kernel functions: migrate_pages() and migrate_page_copy()):

                             |  migrate_pages() |    migrate_page_copy()
migrating single 4KB page:   |  0.312GB/s       |   1.385GB/s
migrating 512 4KB pages:     |  0.854GB/s       |   1.983GB/s
migrating single 2MB THP:    |  2.387GB/s       |   2.481GB/s

In reality, microbenchmarks show that Intel PMEM can provide ~65GB/s read throughput and ~16GB/s write throughput [5], which are much higher than the throughput achieved by Linux page migration.

In addition, it is also desirable to use page migration to move data between high-bandwidth memory and DRAM, like IBM Summit, which exposes high-performance GPU memories as NUMA nodes [6]. This requires even higher page migration throughput.

In this patch series, I propose four different ways of improving page migration throughput (mostly on 2MB THP migration):
1. multi-threaded page migration: Patch 03 to 06.
2. DMA-based (using Intel IOAT DMA) page migration: Patch 07 and 08.
3. concurrent (batched) page migration: Patch 09, 10, and 11.
4. exchange pages: Patch 12 to 17. (This is a repost of part of [7])

Here are some throughput numbers showing clear throughput improvements on a two-socket NUMA machine with two Xeon E5-2650 v3 @ 2.30GHz and a 19.2GB/s bandwidth QPI link (the same machine as mentioned in [4]):

                                    |  migrate_pages() |   migrate_page_copy()
=> migrating single 2MB THP         |  2.387GB/s       |   2.481GB/s
 2-thread single THP migration      |  3.478GB/s       |   3.704GB/s
 4-thread single THP migration      |  5.474GB/s       |   6.054GB/s
 8-thread single THP migration      |  7.846GB/s       |   9.029GB/s
16-thread single THP migration      |  7.423GB/s       |   8.464GB/s
16-ch. DMA single THP migration     |  4.322GB/s       |   4.536GB/s
 2-thread 16-THP migration          |  3.610GB/s       |   3.838GB/s
 2-thread 16-THP batched migration  |  4.138GB/s       |   4.344GB/s
 4-thread 16-THP migration          |  6.385GB/s       |   7.031GB/s
 4-thread 16-THP batched migration  |  7.382GB/s       |   8.072GB/s
 8-thread 16-THP migration          |  8.039GB/s       |   9.029GB/s
 8-thread 16-THP batched migration  |  9.023GB/s       |   10.056GB/s
16-thread 16-THP migration          |  8.137GB/s       |   9.137GB/s
16-thread 16-THP batched migration  |  9.907GB/s       |   11.175GB/s
 1-thread 16-THP exchange           |  4.135GB/s       |   4.225GB/s
 2-thread 16-THP batched exchange   |  7.061GB/s       |   7.325GB/s
 4-thread 16-THP batched exchange   |  9.729GB/s       |   10.237GB/s
 8-thread 16-THP batched exchange   |  9.992GB/s       |   10.533GB/s
16-thread 16-THP batched exchange   |  9.520GB/s       |   10.056GB/s
=> migrating 512 4KB pages          |  0.854GB/s       |   1.983GB/s
 1-thread 512-4KB batched exchange  |  1.271GB/s       |   3.433GB/s
 2-thread 512-4KB batched exchange  |  1.240GB/s       |   3.190GB/s
 4-thread 512-4KB batched exchange  |  1.255GB/s       |   3.823GB/s
 8-thread 512-4KB batched exchange  |  1.336GB/s       |   3.921GB/s
16-thread 512-4KB batched exchange  |  1.334GB/s       |   3.897GB/s

Concerns were raised on how to avoid CPU resource competition between page migration and user applications and have power awareness. Daniel Jordan recently posted a multi-threaded ktask patch series could be a solution [8].

Infrequent page list update problem
====

Current page lists are updated by calling shrink_list() when memory pressure comes, which might not be frequent enough to keep track of hot and cold pages. Because all pages are on active lists at the first time shrink_list() is called and the reference bit on the pages might not reflect the up to date access status of these pages. But we also do not want to periodically shrink the global page lists, which adds unnecessary overheads to the whole system. So I propose to actively shrink page lists on the memcg we are interested in.

Patch 18 to 25 add a new system call to shrink page lists on given application's memcg and migrate pages between two NUMA nodes. It isolates the impact from the rest of the system. To share DRAM among different applications, Patch 18 and 19 add per-node memcg size limit, so you can limit the memory usage for particular NUMA node(s).

Patch structure
====
1. multi-threaded page migration: Patch 01 to 06.
2. DMA-based (using Intel IOAT DMA) page migration: Patch 07 and 08.
3. concurrent (batched) page migration: Patch 09, 10, and 11.
4. exchange pages: Patch 12 to 17. (This is a repost of part of [7])
5. per-node size limit in memcg: Patch 18 and 19.
6. actively shrink page lists and perform page migration in given memcg: Patch 20 to 25.

Any comment is welcome.

[1]: https://lore.kernel.org/linux-mm/[email protected]/
[2]: https://lore.kernel.org/linux-mm/[email protected]/
[3]: https://lore.kernel.org/linux-mm/[email protected]/
[4]: https://lore.kernel.org/linux-mm/[email protected]/
[5]: https://www.storagereview.com/supermicro_superserver_with_intel_optane_dc_persistent_memory_first_look_review
[6]: https://www.ibm.com/thought-leadership/summit-supercomputer/
[7]: https://lore.kernel.org/linux-mm/[email protected]/
[8]: https://lore.kernel.org/linux-mm/[email protected]/

Zi Yan (25):
mm: migrate: Change migrate_mode to support combination migration
modes.
mm: migrate: Add mode parameter to support future page copy routines.
mm: migrate: Add a multi-threaded page migration function.
mm: migrate: Add copy_page_multithread into migrate_pages.
mm: migrate: Add vm.accel_page_copy in sysfs to control page copy
acceleration.
mm: migrate: Make the number of copy threads adjustable via sysctl.
mm: migrate: Add copy_page_dma to use DMA Engine to copy pages.
mm: migrate: Add copy_page_dma into migrate_page_copy.
mm: migrate: Add copy_page_lists_dma_always to support copy a list of
pages.
mm: migrate: copy_page_lists_mt() to copy a page list using
multi-threads.
mm: migrate: Add concurrent page migration into move_pages syscall. exchange pages: new page migration mechanism: exchange_pages() exchange pages: add multi-threaded exchange pages. exchange pages: concurrent exchange pages.
exchange pages: exchange anonymous page and file-backed page. exchange page: Add THP exchange support.
exchange page: Add exchange_page() syscall.
memcg: Add per node memory usage&max stats in memcg.
mempolicy: add MPOL_F_MEMCG flag, enforcing memcg memory limit. memory manage: Add memory manage syscall.
mm: move update_lru_sizes() to mm_inline.h for broader use. memory manage: active/inactive page list manipulation in memcg. memory manage: page migration based page manipulation between NUMA
nodes.
memory manage: limit migration batch size.
memory manage: use exchange pages to memory manage to improve
throughput.

 arch/x86/entry/syscalls/syscall_64.tbl |    2 +
 fs/aio.c                               |   12 +-
 fs/f2fs/data.c                         |    6 +-
 fs/hugetlbfs/inode.c                   |    4 +-
 fs/iomap.c                             |    4 +-
 fs/ubifs/file.c                        |    4 +-
 include/linux/cgroup-defs.h            |    1 +
 include/linux/exchange.h               |   27 +
 include/linux/highmem.h                |    3 +
 include/linux/ksm.h                    |    4 +
 include/linux/memcontrol.h             |   67 ++
 include/linux/migrate.h                |   12 +-
 include/linux/migrate_mode.h           |    8 +
 include/linux/mm_inline.h              |   21 +
 include/linux/sched/coredump.h         |    1 +
 include/linux/sched/sysctl.h           |    3 +
 include/linux/syscalls.h               |   10 +
 include/uapi/linux/mempolicy.h         |    9 +-
 kernel/sysctl.c                        |   47 +
 mm/Makefile                            |    5 +
 mm/balloon_compaction.c                |    2 +-
 mm/compaction.c                        |   22 +-
 mm/copy_page.c                         |  708 +++++++++++++++
 mm/exchange.c                          | 1560 ++++++++++++++++++++++++++++++++
 mm/exchange_page.c                     |  228 +++++
 mm/internal.h                          |  113 +++
 mm/ksm.c                               |   35 +
 mm/memcontrol.c                        |   80 ++
 mm/memory_manage.c                     |  649 +++++++++++++
 mm/mempolicy.c                         |   38 +-
 mm/migrate.c                           |  621 ++++++++++++-
 mm/vmscan.c                            |  115 +--
 mm/zsmalloc.c                          |    2 +-
 33 files changed, 4261 insertions(+), 162 deletions(-)
 create mode 100644 include/linux/exchange.h
 create mode 100644 mm/copy_page.c
 create mode 100644 mm/exchange.c
 create mode 100644 mm/exchange_page.c
 create mode 100644 mm/memory_manage.c

--
2.7.4