|
|
Log in / Subscribe / Register

hot page swap to zram, cold page swap to swapfile directly

From:  Lincheng Yang <lincheng.yang-AT-transsion.corp-partner.google.com>
To:  akpm-AT-linux-foundation.org, rostedt-AT-goodmis.org, mhiramat-AT-kernel.org, willy-AT-infradead.org, hughd-AT-google.com, peterx-AT-redhat.com, mike.kravetz-AT-oracle.com, jgg-AT-ziepe.ca, surenb-AT-google.com, steven.price-AT-arm.com, pasha.tatashin-AT-soleen.com, kirill.shutemov-AT-linux.intel.com, yuanchu-AT-google.com, david-AT-redhat.com, mathieu.desnoyers-AT-efficios.com, dhowells-AT-redhat.com, shakeelb-AT-google.com, pcc-AT-google.com, tytso-AT-mit.edu, 42.hyeyoo-AT-gmail.com, vbabka-AT-suse.cz, catalin.marinas-AT-arm.com, lrh2000-AT-pku.edu.cn, ying.huang-AT-intel.com, mhocko-AT-suse.com, vishal.moola-AT-gmail.com, yosryahmed-AT-google.com, findns94-AT-gmail.com, neilb-AT-suse.de
Subject:  [RFC PATCH 0/5] hot page swap to zram, cold page swap to swapfile directly
Date:  Sun, 08 Oct 2023 17:59:19 +0800
Message-ID:  <20231008095924.1165106-1-lincheng.yang@transsion.com>
Cc:  linux-kernel-AT-vger.kernel.org, linux-mm-AT-kvack.org, wanbin.wang-AT-transsion.com, chunlei.zhuang-AT-transsion.com, jinsheng.zhao-AT-transsion.com, jiajun.ling-AT-transsion.com, dongyun.liu-AT-transsion.com, Lincheng Yang <lincheng.yang-AT-transsion.com>
Archive-link:  Article

Hi All,

We team developed a feature in Android linux v4.19 that can directly swapout
cold pages to the swapfile device and hot pages to the ZRAM device. This can
reduce the lag when writing back cold pages to backing-dev through ZRAM when
there is a lot of memory pressure, saving the ZRAM compression/decompression
process. Especially for low-end Android devices, low CPU frequency and small
memory.

Currently, Android uses the GKI strategy. We cannot directly modify the Linux
kernel to support this feature. We can only support it through the hook vendor.
However, this feature involves too many modifications. Google TAM suggested
that we push this feature to the Linux community.

The main changes are as follows:
[PATCH 2/5]: Set the hot and cold status for each page.
             If it is a cold page, it is swapout to the swapfile directly.
             If it is a hot page, it is swapout to the ZRAM device.
[PATCH 3/5]: When a VMA has many hot pages, predict that the VMA is hot,
             so that all anonymous pages of this VMA are hot and are only
             swapout to the ZRAM device.
[PATCH 4/5]: When user space uses madvise/process_madvise(MADV_PAGEOUT),
             swapout to the swapfile device directly.
[PATCH 5/5]: When the storage life of the external storage device is too
             low or the amount of daily writes to swapfile is too high,
             the user turns off swapout hot/cold page to the swapfile
             device and can only swapout to the ZRAM device.

This series is based on linux v6.5, this is just porting the core function to
linux v6.5.

If similar function already exists in the kernel, please let me know and give
it a shout, also comments and suggestions are welcome.

Thanks,
Lincheng Yang


Lincheng Yang (5):
  mm/swap_slots: cleanup swap slot cache
  mm: introduce hot and cold anon page flags
  mm: add VMA hot flag
  mm: add page implyreclaim flag
  mm/swapfile: add swapfile_write_enable interface

 fs/proc/task_mmu.c             |   3 +
 include/linux/mm.h             |  32 +++++++
 include/linux/mm_types.h       |   2 +
 include/linux/mm_types_task.h  |  10 +++
 include/linux/mmzone.h         |   1 +
 include/linux/page-flags.h     |   9 ++
 include/linux/swap.h           |   8 +-
 include/linux/swap_slots.h     |   2 +-
 include/trace/events/mmflags.h |   6 +-
 mm/filemap.c                   |   2 +
 mm/madvise.c                   |   7 +-
 mm/memory.c                    |  44 ++++++++++
 mm/migrate.c                   |   6 ++
 mm/rmap.c                      |   3 +
 mm/shmem.c                     |   2 +-
 mm/swap.h                      |   4 +-
 mm/swap_slots.c                | 133 +++++++++++++++++-----------
 mm/swap_state.c                |   4 +-
 mm/swapfile.c                  | 153 +++++++++++++++++++++++++++++++--
 mm/vmscan.c                    |  22 ++++-
 20 files changed, 384 insertions(+), 69 deletions(-)

--
2.34.1



Copyright © 2023, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds