[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250910144653.212066-1-bharata@amd.com>
Date: Wed, 10 Sep 2025 20:16:45 +0530
From: Bharata B Rao <bharata@....com>
To: <linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>
CC: <Jonathan.Cameron@...wei.com>, <dave.hansen@...el.com>,
<gourry@...rry.net>, <hannes@...xchg.org>, <mgorman@...hsingularity.net>,
<mingo@...hat.com>, <peterz@...radead.org>, <raghavendra.kt@....com>,
<riel@...riel.com>, <rientjes@...gle.com>, <sj@...nel.org>,
<weixugc@...gle.com>, <willy@...radead.org>, <ying.huang@...ux.alibaba.com>,
<ziy@...dia.com>, <dave@...olabs.net>, <nifan.cxl@...il.com>,
<xuezhengchu@...wei.com>, <yiannis@...corp.com>, <akpm@...ux-foundation.org>,
<david@...hat.com>, <byungchul@...com>, <kinseyho@...gle.com>,
<joshua.hahnjy@...il.com>, <yuanchu@...gle.com>, <balbirs@...dia.com>,
<alok.rathore@...sung.com>, Bharata B Rao <bharata@....com>
Subject: [RFC PATCH v2 0/8] mm: Hot page tracking and promotion infrastructure
Hi,
This patchset introduces a new subsystem for hot page tracking
and promotion (pghot) that consolidates memory access information
from various sources and enables centralized promotion of hot
pages across memory tiers.
Currently, multiple kernel subsystems detect page accesses
independently. For eg.
- NUMA Balancing via hint faults
- MGLRU via page table scanning for PTE A bit
This patchset consolidates the accesses from these mechanisms by
providing a common API for reporting page accesses and a shared
infrastructure for tracking hotness at PFN granularity and per-node
kernel threads for promoting pages.
Here is a brief summary of how this subsystem works:
- Tracks frequency, last access time and accessing node as
part of each access record.
- Maintains per-PFN access records in hash lists.
- Classifies pages as hot based on configurable thresholds.
- Uses per-toptier-node max-heaps to prioritize hot pages for promotion.
- Launches per-toptier-node kpromoted threads to perform batched
migrations.
When different subsystems report page accesses via the API
introduced by this new subsystem, a record for each such page
is stored in hash lists (hashed by PFN value). In addition to
the PFN and target_nid, the hotness record includes parameters
like frequency and time of access from which the hotness is
derived. Repeated reporting of access on the same PFN will result
in updating of hotness information. When the hotness of a
record (as updated during reporting of access) crosses a threshold,
the record becomes part of a max heap data structure. Records
in the max heap are arranged based on the hotness and hence
the top elements of the heap will correspond to the hottest
pages. There will be one such heap for each toptier node so
that per-toptier-node kpromoted thread can easily extract the
top N records from its own heap and perform batched migration.
Three page hotness sources have been integrated with pghot
subsystem on experimental basis:
1. IBS
2. klruscand (based on MGLRU page table walks)
3. NUMA Balancing (mode 2).
Changes in v2
=============
- Moved migration rate-limiting and dynamic threshold logic from
NUMA Balancing subsystem to pghot. With this, the logic to
classify a page as hot resembles more closely to the existing
mechanism.
- Converted NUMA Balancing mode 2 to just detect accesses through
NUMA hint faults and delegate rest of the processing (hot page
classification and promotion) to pghot.
- Packed the three parameters required for hot page tracking
(nid, frequency and timestamp) into a single u32 for space
efficiency.
- Misc cleanups and refactoring.
This v2 patchset applies on top of upstream commit 8742b2d8935f and
can be fetched from:
https://github.com/AMDESE/linux-mm/tree/bharata/kpromoted-rfcv2
v1: https://lore.kernel.org/linux-mm/20250814134826.154003-1-bharata@amd.com/
v0: https://lore.kernel.org/linux-mm/20250306054532.221138-1-bharata@amd.com/
TODOs
=====
- Memory allocation: High volume of allocations and frees (millions)
from atomic context needs evaluation.
- Memory overhead: The amount of data needed for tracking hotness is
also a concern.
- Integrate Kscand[1], the PTE A bit based approach that Raghavendra KT
is working upon, so that Kscand acts as temperature sources and
uses pghot for hot page heuristics and promotion.
- Heap pruning: Consider adding heap pruning mechanism for periodic
cleaning of cold records.
- Address Ying Huang's comment about merging migrate_misplaced_folio()
and migrate_misplaced_folios_batch() and correctly handling memcg
stats counting properly in the latter.
- Testing: Light functional testing done; performance benchmarking and
stress testing will follow in the next iterations.
Any feedback is welcome!
Bharata B Rao (5):
mm: migrate: Allow misplaced migration without VMA too
mm: Hot page tracking and promotion
x86: ibs: In-kernel IBS driver for memory access profiling
x86: ibs: Enable IBS profiling for memory accesses
mm: sched: Move hot page promotion from NUMAB=2 to kpromoted
Gregory Price (1):
migrate: implement migrate_misplaced_folios_batch
Kinsey Ho (2):
mm: mglru: generalize page table walk
mm: klruscand: use mglru scanning for page promotion
arch/x86/events/amd/ibs.c | 11 +
arch/x86/include/asm/entry-common.h | 3 +
arch/x86/include/asm/hardirq.h | 2 +
arch/x86/include/asm/ibs.h | 9 +
arch/x86/include/asm/msr-index.h | 16 +
arch/x86/mm/Makefile | 3 +-
arch/x86/mm/ibs.c | 343 +++++++++++++++
include/linux/migrate.h | 6 +
include/linux/mmzone.h | 16 +
include/linux/pghot.h | 98 +++++
include/linux/vm_event_item.h | 26 ++
kernel/sched/fair.c | 149 +------
mm/Kconfig | 19 +
mm/Makefile | 2 +
mm/internal.h | 4 +
mm/klruscand.c | 118 +++++
mm/memory.c | 32 +-
mm/migrate.c | 36 +-
mm/mm_init.c | 10 +
mm/pghot.c | 648 ++++++++++++++++++++++++++++
mm/vmscan.c | 176 ++++++--
mm/vmstat.c | 26 ++
22 files changed, 1535 insertions(+), 218 deletions(-)
create mode 100644 arch/x86/include/asm/ibs.h
create mode 100644 arch/x86/mm/ibs.c
create mode 100644 include/linux/pghot.h
create mode 100644 mm/klruscand.c
create mode 100644 mm/pghot.c
[1] Kscand - https://lore.kernel.org/linux-mm/20250814153307.1553061-1-raghavendra.kt@amd.com/
--
2.34.1
Powered by blists - more mailing lists