Skip to content

mm/damon/core: detect internal variation above max_nr_regions/2

SJ Park damon linux-kselftest linux-mm lkml 1 version Applied

Status from this message: [merged mm-stable] mm-damon-tests-core-kunit-test-split-above-max_nr_regions-2.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first

  1. v3 Latest2 patches 1 replyApplied 2/2

Changes in v3 from the cover letter

- v2: https://lore.kernel.org/[email protected]
- Collect R-b: from SJ.
- Rebase to latest mm-new.

Patches in v3 All 2 applied

#Subject and filesSizeRepliesApplied
1/2mm/damon/core: split a fraction of regions when nr_regions exceeds max/2mm/damon/core.c+44 -51 replyApplied
2/2mm/damon/tests/core-kunit: test split above max_nr_regions/2mm/damon/tests/core-kunit.h+64 -00 repliesApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchSJ Park
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/2] mm/damon/core: detect internal variation above max_nr_regions/2

kdamond_split_regions() bails out early when nr_regions is already above max_nr_regions / 2. A large region that picks up new internal variation after that point never gets split, so we lose visibility into its hot/cold structure.

We hit this with damon-paddr on hugepage workloads and damon-vaddr on processes that mmap a large anonymous range.

Example with max_nr_regions == 1500. A target ends up with 799 small hot/cold regions plus one big region (an earlier merge collapsed a uniformly-accessed range into a single piece):

H:hot
C:cold

      r1     r2     r3                 r800
    HHHHHH|CCCCCC|HHHHHH|...|HHHHHH..........................|

    nr_regions = 800  >  max_nr_regions / 2 = 750

Now a cold subarea shows up inside r800:

r1 r2 r3 r800
HHHHHH|CCCCCC|HHHHHH|...|HHHHHH........CCCCCC.............|

The small regions can't merge with each other (their access counts differ), so budget never frees up. r800 can't be split because nr_regions > max_nr_regions / 2 returns early. The cold subarea stays invisible.

Patch 1 keeps refining on this path: when nr_regions is above max_nr_regions / 2 but still under the maximum, it splits a fraction of the regions instead of returning. The fraction shrinks as the remaining budget shrinks, so the count approaches max_nr_regions smoothly. A useless split is undone by the next merge cycle.

Patch 2 adds a KUnit test for the case where nr_regions is already above max_nr_regions / 2.

Thanks to SJ for the suggestion to drive the split fraction from the remaining budget rather than an age-based filter.

Changes from v2
- v2: https://lore.kernel.org/[email protected]
- Collect R-b: from SJ.
- Rebase to latest mm-new.
Changes from v1
- v1: https://lore.kernel.org/damon/[email protected]/
- Some feedback from SJ.

Jiayuan Chen (2):
mm/damon/core: split a fraction of regions when nr_regions exceeds

    max/2

mm/damon/tests/core-kunit: test split above max_nr_regions/2

 mm/damon/core.c             | 49 +++++++++++++++++++++++++---
 mm/damon/tests/core-kunit.h | 64 +++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+), 5 deletions(-)

base-commit: 86100fb7e27ebb5da22fc8a2810eebcf8cc897e8

Signature · 1 line
2.47.3