From: Hirotaka Yamagata <hiro@pisnp.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-api@vger.kernel.org, "Liam R. Howlett" <liam@infradead.org>,
Lorenzo Stoakes <ljs@kernel.org>,
David Hildenbrand <david@kernel.org>,
Chris Li <chrisl@kernel.org>, Kairui Song <kasong@tencent.com>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-fsdevel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
cgroups@vger.kernel.org, John Stultz <jstultz@google.com>,
Minchan Kim <minchan@kernel.org>,
Alexandre Marciano Gimenez <raging@google.com>,
Tatsuyuki Ishi <ishitatsuyuki@google.com>
Subject: [RFC PATCH v1 0/4] mm: port MADV_VOLATILE and MADV_NONVOLATILE to v7.3-rc1
Date: Mon, 30 Nov 2026 17:34:03 +0900 [thread overview]
Message-ID: <20261130083407.2669584-1-hiro@pisnp.net> (raw)
This RFC series revives and modernizes the volatile ranges patchset
originally proposed by John Stultz and Minchan Kim [1].
Volatile ranges allow userspace caches holding regenerable data (such as
decoded image bitmaps or other private caches) to mark private anonymous
memory as safe for the kernel to discard under memory pressure,
bypassing swap. Such ranges are marked via madvise(MADV_VOLATILE).
Before reusing the buffer, userspace calls madvise(MADV_NONVOLATILE),
which unmarks the range and returns 1 if any pages in the range were
purged while volatile (or 0 if all pages remained intact).
Unlike MADV_FREE, which silently zero-fills dropped pages on re-access,
calling MADV_NONVOLATILE before reuse gives userspace deterministic
notification of whether cached data was lost without having to touch
every page.
If userspace instead accesses a purged page while the range is still
volatile, the fault raises SIGBUS; after MADV_NONVOLATILE, the next
access to it maps a zero page. Zero-filling on fault was considered,
but this series chooses SIGBUS to catch missing MADV_NONVOLATILE calls
and partially purged reads instead of silently seeing zeros, and to
keep the optimistic read model from earlier series possible so readers
can skip per-access MADV_NONVOLATILE/MADV_VOLATILE calls.
Volatile pages share the regular anon LRU, so currently they are not
purged when swap is disabled or full. Two alternatives were considered,
but neither was satisfactory:
- Keeping volatile pages on a separate LRU: changes eviction order and
creates balancing issues against page cache and swap.
- Keeping a linked list of volatile pages only, in addition to the anon
LRU: allows scanning for volatile pages cheaply when swap is full, but
making pages volatile then requires scanning, which is expensive.
As a future extension, finer-grained purge reporting could avoid
regenerating an entire large buffer when only part of it was purged.
Within madvise(2), up to 31 bits of a positive int return value could
encode a coarse mask over N equal sub-ranges; configurable granularity
or an arbitrary-length bitmap would instead call for a dedicated syscall
taking an output bitmap pointer (similar to mincore(2)).
Key changes from the earlier v14 series [1]:
- Use PTE markers (PTE_MARKER_PURGED) instead of consuming a swap type.
- Defer purging in shrink_folio_list() until after checking references
(immediately before folio_alloc_swap()), allowing frequently accessed
volatile pages to age normally via LRU/MGLRU.
- Port VMA handling to Maple Tree and modern folio APIs.
- Add a PGPURGE vmstat/memcg counter and a tracepoint.
This series was evaluated with Chromium patched to back discardable
memory with MADV_VOLATILE/MADV_NONVOLATILE, running the
multiwindow-memory-stress benchmark from chromium/web-tests (30 tabs
across 5 windows alongside 4 background Chromium instances in an 8 GiB
VM with 8 GiB swap). Backing decoded image caches with volatile ranges
reduced the software image decode count per run by 18.0% and total
software image decode time per run by 24.9%
(Renderer4.ImageDecodeTaskDurationUs.Software). Under slab_nomerge,
VMA-related slab overhead (vm_area_struct, anon_vma_chain, anon_vma,
maple_node) was +228 KiB mean (+1.55%, ~0.003% of ~7.2 GiB total
Chromium PSS) and +76 KiB peak (+0.42%).
[1] https://lore.kernel.org/lkml/1398806483-19122-1-git-send-email-john.stultz@linaro.org/
("[PATCH 0/4] Volatile Ranges (v14 - madvise reborn edition!)")
Hirotaka Yamagata (4):
mm: introduce VM_VOLATILE and MADV_VOLATILE/MADV_NONVOLATILE VMA
handling
mm: add PTE_MARKER_PURGED and TTU_PURGE for purged volatile pages
mm/volatile: purge volatile anonymous folios during reclaim
mm/volatile: add PGPURGE vmstat counter and purge tracepoint
MAINTAINERS | 2 +
fs/proc/task_mmu.c | 1 +
include/linux/leafops.h | 14 ++
include/linux/mm.h | 12 +
include/linux/mm_inline.h | 5 +-
include/linux/mvolatile.h | 48 ++++
include/linux/rmap.h | 1 +
include/linux/swapops.h | 18 +-
include/linux/vm_event_item.h | 1 +
include/trace/events/mmflags.h | 7 +
include/trace/events/vmscan.h | 24 ++
include/uapi/asm-generic/mman-common.h | 3 +
mm/Makefile | 2 +-
mm/khugepaged.c | 17 ++
mm/madvise.c | 29 +++
mm/memcontrol.c | 1 +
mm/memory.c | 5 +
mm/mprotect.c | 6 +-
mm/mseal.c | 20 ++
mm/mvolatile.c | 311 +++++++++++++++++++++++++
mm/rmap.c | 14 ++
mm/vmscan.c | 14 ++
mm/vmstat.c | 1 +
23 files changed, 550 insertions(+), 6 deletions(-)
create mode 100644 include/linux/mvolatile.h
create mode 100644 mm/mvolatile.c
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
--
2.56.0.611.g1030f0b940-goog
next reply other threads:[~2026-11-30 8:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 8:34 Hirotaka Yamagata [this message]
2026-11-30 8:34 ` [RFC PATCH v1 1/4] mm: introduce VM_VOLATILE and MADV_VOLATILE/MADV_NONVOLATILE VMA handling Hirotaka Yamagata
2026-11-30 8:34 ` [RFC PATCH v1 2/4] mm: add PTE_MARKER_PURGED and TTU_PURGE for purged volatile pages Hirotaka Yamagata
2026-11-30 8:34 ` [RFC PATCH v1 3/4] mm/volatile: purge volatile anonymous folios during reclaim Hirotaka Yamagata
2026-11-30 8:34 ` [RFC PATCH v1 4/4] mm/volatile: add PGPURGE vmstat counter and purge tracepoint Hirotaka Yamagata
2026-11-30 10:39 ` [RFC PATCH v1 0/4] mm: port MADV_VOLATILE and MADV_NONVOLATILE to v7.3-rc1 David Hildenbrand (Arm)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261130083407.2669584-1-hiro@pisnp.net \
--to=hiro@pisnp.net \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=cgroups@vger.kernel.org \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=ishitatsuyuki@google.com \
--cc=jstultz@google.com \
--cc=kasong@tencent.com \
--cc=liam@infradead.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mhocko@kernel.org \
--cc=minchan@kernel.org \
--cc=raging@google.com \
--cc=roman.gushchin@linux.dev \
--cc=rostedt@goodmis.org \
--cc=shakeel.butt@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox