From: Suren Baghdasaryan <surenb@google.com>
To: akpm@linux-foundation.org
Cc: david@redhat.com, lorenzo.stoakes@oracle.com,
Liam.Howlett@oracle.com, vbabka@suse.cz,
alexandru.elisei@arm.com, peterx@redhat.com, sj@kernel.org,
rppt@kernel.org, mhocko@suse.com, corbet@lwn.net,
axboe@kernel.dk, viro@zeniv.linux.org.uk, brauner@kernel.org,
hch@infradead.org, jack@suse.cz, willy@infradead.org,
m.szyprowski@samsung.com, robin.murphy@arm.com,
hannes@cmpxchg.org, zhengqi.arch@bytedance.com,
shakeel.butt@linux.dev, axelrasmussen@google.com,
yuanchu@google.com, weixugc@google.com, minchan@kernel.org,
surenb@google.com, linux-mm@kvack.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
iommu@lists.linux.dev
Subject: [PATCH 0/8] Guaranteed CMA
Date: Thu, 9 Oct 2025 18:19:43 -0700 [thread overview]
Message-ID: <20251010011951.2136980-1-surenb@google.com> (raw)
Guaranteed CMA (GCMA) is designed to improve utilization of reserved
memory carveouts without compromising their advantages of:
1. Guaranteed success of allocation (as long as total allocation size is
below the size of the reservation.
2. Low allocation latency.
The idea is that carved out memory when not used for its primary purpose
can be donated and used as an extension of the pagecache and any donated
folio can be taken back at any moment with minimal latency and guaranteed
success.
To achieve this, GCMA needs to use memory that is not addressable by the
kernel (can't be pinned) and that contains content that can be discarded.
To provide such memory we reintroduce cleancache idea [1] with two major
changes. New implementation:
1. Avoids intrusive hooks into filesystem code, limiting them to two hooks
for filesystem mount/unmount events and a hook for bdev invalidation.
2. Manages inode to folio association and handles pools of donated folios
inside cleancache itself, freeing backends of this burden.
Cleancache provides a simple interface to its backends which lets them
donate folios to cleancache, take a folio back for own use and return the
folio back to cleancache when not needed.
With cleancache in place, GCMA becomes a thin layer linking CMA allocator
to cleancache, which allows existing CMA API to be used for continuous
memory allocations with additional guarantees listed above.
The limitation of GCMA is that its donated memory can be used only to
extend file-backed pagecache. Note that both CMA and GCMA can be used
at the same time.
Accounting for folios allocated from GCMA is implemented the same way as
for CMA. The reasoning is that both CMA and GCMA use reserved memory for
contiguous allocations with the only difference in how that memory gets
donated while not in use. CMA donates its memory to the system for movable
allocations with expectation that it will be returned when it is needed.
GCMA donatest its memory to cleancache with the same expectation. Once CMA
or GCMA use that memory for contiguous allocation, the difference between
them disappears, therefore accounting at that point should not differ.
The patchset borrows some ideas and code from previous implementations of
the cleancache and GCMA [2] as well as Android's reference patchset [3]
implemented by Minchan Kim and used by many Android vendors.
[1] https://elixir.bootlin.com/linux/v5.16.20/source/Documentation/vm/cleancache.rst
[2] https://lore.kernel.org/lkml/1424721263-25314-1-git-send-email-sj38.park@gmail.com/
[3] https://android-review.googlesource.com/q/topic:%22gcma_6.12%22
Patchset is based on mm-new.
Minchan Kim (1):
mm: introduce GCMA
Suren Baghdasaryan (7):
mm: implement cleancache
mm/cleancache: add cleancache LRU for folio aging
mm/cleancache: readahead support
mm/cleancache: add sysfs interface
mm/tests: add cleancache kunit test
add cleancache documentation
mm: integrate GCMA with CMA using dt-bindings
Documentation/mm/cleancache.rst | 112 +++
MAINTAINERS | 13 +
block/bdev.c | 6 +
fs/super.c | 3 +
include/linux/cleancache.h | 84 +++
include/linux/cma.h | 11 +-
include/linux/fs.h | 6 +
include/linux/gcma.h | 36 +
include/linux/pagemap.h | 1 +
kernel/dma/contiguous.c | 11 +-
mm/Kconfig | 40 ++
mm/Kconfig.debug | 13 +
mm/Makefile | 4 +
mm/cleancache.c | 1144 +++++++++++++++++++++++++++++++
mm/cleancache_sysfs.c | 209 ++++++
mm/cleancache_sysfs.h | 58 ++
mm/cma.c | 37 +-
mm/cma.h | 1 +
mm/cma_sysfs.c | 10 +
mm/filemap.c | 26 +
mm/gcma.c | 231 +++++++
mm/readahead.c | 55 ++
mm/tests/Makefile | 6 +
mm/tests/cleancache_kunit.c | 425 ++++++++++++
mm/truncate.c | 4 +
mm/vmscan.c | 1 +
26 files changed, 2534 insertions(+), 13 deletions(-)
create mode 100644 Documentation/mm/cleancache.rst
create mode 100644 include/linux/cleancache.h
create mode 100644 include/linux/gcma.h
create mode 100644 mm/cleancache.c
create mode 100644 mm/cleancache_sysfs.c
create mode 100644 mm/cleancache_sysfs.h
create mode 100644 mm/gcma.c
create mode 100644 mm/tests/Makefile
create mode 100644 mm/tests/cleancache_kunit.c
base-commit: 70478cb9da6fc4e7b987219173ba1681d5f7dd3d
--
2.51.0.740.g6adb054d12-goog
next reply other threads:[~2025-10-10 1:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-10 1:19 Suren Baghdasaryan [this message]
2025-10-10 1:19 ` [PATCH 1/8] mm: implement cleancache Suren Baghdasaryan
2025-10-10 1:31 ` Andrew Morton
2025-10-10 1:42 ` Suren Baghdasaryan
2025-10-10 2:39 ` Matthew Wilcox
2025-10-10 14:53 ` Suren Baghdasaryan
2025-10-10 21:17 ` kernel test robot
2025-10-10 21:42 ` Suren Baghdasaryan
2025-10-13 6:44 ` Christoph Hellwig
2025-10-13 15:43 ` Suren Baghdasaryan
2025-10-10 1:19 ` [PATCH 2/8] mm/cleancache: add cleancache LRU for folio aging Suren Baghdasaryan
2025-10-10 1:19 ` [PATCH 3/8] mm/cleancache: readahead support Suren Baghdasaryan
2025-10-10 1:19 ` [PATCH 4/8] mm/cleancache: add sysfs interface Suren Baghdasaryan
2025-10-10 1:19 ` [PATCH 5/8] mm/tests: add cleancache kunit test Suren Baghdasaryan
2025-10-11 2:57 ` kernel test robot
2025-10-11 21:47 ` Suren Baghdasaryan
2025-10-10 1:19 ` [PATCH 6/8] add cleancache documentation Suren Baghdasaryan
2025-10-10 20:20 ` SeongJae Park
2025-10-10 22:09 ` Suren Baghdasaryan
2025-10-10 1:19 ` [PATCH 7/8] mm: introduce GCMA Suren Baghdasaryan
2025-10-10 21:11 ` SeongJae Park
2025-10-10 22:05 ` Suren Baghdasaryan
2025-10-10 1:19 ` [PATCH 8/8] mm: integrate GCMA with CMA using dt-bindings Suren Baghdasaryan
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=20251010011951.2136980-1-surenb@google.com \
--to=surenb@google.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=alexandru.elisei@arm.com \
--cc=axboe@kernel.dk \
--cc=axelrasmussen@google.com \
--cc=brauner@kernel.org \
--cc=corbet@lwn.net \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=hch@infradead.org \
--cc=iommu@lists.linux.dev \
--cc=jack@suse.cz \
--cc=linux-block@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=m.szyprowski@samsung.com \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=peterx@redhat.com \
--cc=robin.murphy@arm.com \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=sj@kernel.org \
--cc=vbabka@suse.cz \
--cc=viro@zeniv.linux.org.uk \
--cc=weixugc@google.com \
--cc=willy@infradead.org \
--cc=yuanchu@google.com \
--cc=zhengqi.arch@bytedance.com \
/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