Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Krishna Iyer <kiyer@crusoe.ai>
To: SeongJae Park <sj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	damon@lists.linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, Krishna Iyer <kiyer@crusoe.ai>
Subject: [PATCH 0/6] mm/damon: support access monitoring of hugetlb-backed memory
Date: Sat, 29 Aug 2026 22:14:01 -0700	[thread overview]
Message-ID: <20260830051407.50008-1-kiyer@crusoe.ai> (raw)

On virtualization hosts, most system memory is often backed by
hugetlbfs.  On our production hosts, for example, ~95% of RAM is 1 GiB
hugetlb pages backing guest memory.  DAMON's physical address space
monitoring cannot produce a useful access signal for such memory, for
two layered reasons.

First, it is blind to hugetlb folios.  Every access check starts at
damon_get_folio(), which rejects folios that are not on the LRU lists,
and hugetlb folios are managed outside of the LRU by design.  As a
result, all hugetlb-backed memory is silently reported as never
accessed.

Second, even once hugetlb folios are visible, access-bit-based sampling
under-reports hot memory.  DAMON deliberately clears accessed bits
without TLB flushes to keep the overhead low, so accesses served from
cached translations do not walk the page tables and never re-set the
bit.  With 1 GiB mappings, translations effectively never leave the
TLBs, pinning the observed access rate to the TLB-refill rate: a
saturating guest is indistinguishable from a nearly idle one.

Patches 1-3 address the visibility problem.  The first patch moves
damon_hugetlb_mkold() from vaddr to ops-common as a preparation.  The
second patch teaches the folio mkold/young rmap walkers to handle
hugetlb folios, aging the huge PTE and notifying secondary MMUs across
the whole huge page size; the secondary MMU notification is what
surfaces guest-side (e.g., KVM/EPT) accessed bits.  The third patch
adds damon_get_folio_incl_hugetlb() and uses it from the paddr
monitoring primitives only.  DAMOS action appliers such as
DAMON_RECLAIM and DAMON_LRU_SORT keep the LRU-only lookup and are
behaviorally unchanged.

Patches 4-6 address the intensity problem with a new default-off
monitoring context option, 'aging_flush'.  When set, access bit
clearing for monitoring uses the flushing primitives
(mmu_notifier_clear_flush_young() and TLB-flushing PTE/PMD/hugetlb
aging) so that the next access is guaranteed to re-set the accessed
bit.  The option is exposed via the DAMON sysfs interface (patch 5) and
as a DAMON_STAT module parameter (patch 6).  With the option unset, the
behavior is identical to before this series.

Evaluation on an Intel EPT host running a 944 GiB guest with an 842 GiB
in-guest memory workload (masim):

  configuration          estimated access rate    idle -> load
                         idle -> load (GB/s)      separation
  stock                  0.08 -> 0.21             none (guest memory
                                                  invisible)
  patches 1-3            1.70 -> 1.96             1.2x
  full series, flush on  1.21 -> 5.34             4.4x

With aging_flush set, the estimated hot footprint covers ~82% of the
actual working set size, compared to ~40% without flushing, where the
signal mostly reflects the ambient TLB-refill rate rather than guest
accesses.  kdamond CPU consumption stays approximately 0%, and the
worst-case flush overhead measured is below 0.1%, which is acceptable
for hosts that opt in.

Per Documentation/process/generated-content.rst, this series was
developed with the assistance of an AI coding assistant (Anthropic
Claude, via Claude Code).  The assistant helped draft the code and
changelogs, and performed the rebase of the series from its original
6.17-based development tree onto mm-new, including merge conflict
resolution against recent DAMON changes.  All changes were reviewed by
the human submitter, who takes full responsibility for the
contribution.

The series as posted here was regression-tested on its base commit
with a full x86_64 kernel build (no new W=1 warnings in mm/damon), the
DAMON kunit suite (41/41 passing) and the DAMON selftests (15/15
passing) on a kernel booted with virtme-ng.  Functional validation
(the evaluation above, ftrace verification that the flag switches the
notifier variants, and enable/disable stress testing) was performed by
the submitter on production-like hosts running the 6.17-based backport
of this series.

Krishna Iyer (6):
  mm/damon: move damon_hugetlb_mkold() from vaddr to ops-common
  mm/damon/ops-common: handle hugetlb folios in folio mkold/young rmap
    walkers
  mm/damon/paddr: support hugetlb folios in access monitoring
  mm/damon: support flush-assisted access bit clearing for monitoring
  mm/damon/sysfs: support aging_flush
  mm/damon/stat: support aging_flush

 include/linux/damon.h |   2 +
 mm/damon/core.c       |   2 +
 mm/damon/ops-common.c | 154 ++++++++++++++++++++++++++++++++++++------
 mm/damon/ops-common.h |  18 ++++-
 mm/damon/paddr.c      |  11 +--
 mm/damon/stat.c       |   6 ++
 mm/damon/sysfs.c      |  29 ++++++++
 mm/damon/vaddr.c      |  46 +++----------
 8 files changed, 203 insertions(+), 65 deletions(-)


base-commit: d2aad7fdcda7ae8a726926f2d6de7fe9e8ee7563
-- 
2.54.0



             reply	other threads:[~2026-08-30  5:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30  5:14 Krishna Iyer [this message]
2026-08-30  5:14 ` [PATCH 1/6] mm/damon: move damon_hugetlb_mkold() from vaddr to ops-common Krishna Iyer
2026-08-30 16:33   ` SJ Park
2026-08-30  5:14 ` [PATCH 2/6] mm/damon/ops-common: handle hugetlb folios in folio mkold/young rmap walkers Krishna Iyer
2026-08-30 16:48   ` SJ Park
2026-08-30  5:14 ` [PATCH 3/6] mm/damon/paddr: support hugetlb folios in access monitoring Krishna Iyer
2026-08-30 17:12   ` SJ Park
2026-08-30  5:14 ` [PATCH 4/6] mm/damon: support flush-assisted access bit clearing for monitoring Krishna Iyer
2026-08-30  5:14 ` [PATCH 5/6] mm/damon/sysfs: support aging_flush Krishna Iyer
2026-08-30  5:14 ` [PATCH 6/6] mm/damon/stat: " Krishna Iyer
2026-08-30 18:04 ` [PATCH 0/6] mm/damon: support access monitoring of hugetlb-backed memory SJ Park

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=20260830051407.50008-1-kiyer@crusoe.ai \
    --to=kiyer@crusoe.ai \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sj@kernel.org \
    /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