From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from PH0PR06CU001.outbound.protection.outlook.com (mail-westus3azon11011045.outbound.protection.outlook.com [40.107.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F130C25B1DA for ; Thu, 29 Jan 2026 14:41:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.208.45 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769697678; cv=fail; b=mW176WoHfENBGLhjBXKoOkUGydBfjRzFaJ9AhrO+s8SNY/Rc+sqbPRWHknQEd5S6IyAKwJD1XkQCRNXzm84U6kBI+THLhUX8M0nlCr84YMk2zWAU/LPbGLA81ehY4moVdailevXprOPuMGuOxJIhZlwLrVagXw+COacbR2iEzII= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769697678; c=relaxed/simple; bh=x0VxocfH074Gqh6+TuyyoL2xQtzOolCgjrs2WtwDRvs=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=PrA+bIX6t3QUEMNIYZBQpBCkIorrzgSPhjYicYi+rZTfo0PLnOf7TW0RPjC+ckxga2hxHZfaQPDYrLM8YmClcj0fzKtdZRc3fI86in/rXb03FRA1zzljGxUZ/PuCMcfUZNtAHJHbBQ5bCXZVvu46And34gEHuwuXakWNW76bKtc= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=j+47W0EN; arc=fail smtp.client-ip=40.107.208.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="j+47W0EN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Udmk6K+5DN4Kt/mssoE2dy7EwagTln29Z0hgqr7yJK/nM/lmtFzIIRX60SVphXvK2+XgHNoAPvTX9YjY/2lJ2Xv94pxya8iWZZS+I4P+ygRHdrF9aK78paCXvFx1bLocGxT4O5jYGcMiP/I6Kx8XyJXpRMJzfhY6kPlvxvy5oTZXwShlwMDAbvd6I09JothjZZneWGuF3M/ehmK5qsuYVPtXUNDGYcRHczliuAGHX05UEzrY8ff/7gKHAhXjGqtVFsF5mSPEWV65S9X81egH0/32EwJ3y3pKWJcVr5lOgvdResg3bPOuG8TGEamfLXTyv+xxCZg6a3kaugaJ090PIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gWcx+pEPLyFB649tRgKtEMqLbPr4LdLvvcxvtRJQM/M=; b=QSBbteVW6g5Zh9oafPuOehcjqXy3LkqcJ3j1tUja7fG1vVA4SO2FHBD28JQh7P0PlcM04veuFRyiaygQXsLnY4/tNTOMCUxIH6g6n8rY0/0xUHyDmkbdXzNFccxem2Z/NLqXZucmRGnLojU0BT51eajifG3VHDVx5nqQ20mV9dDwpeKqhn0c82GszggEwnXykRjK16TmU46CNA2YObeCdJDKCyuSNBta9Ew3fQMrd57OWGyER03tydURF2QRCNm2WtFjoD/sASe0zZghIaw8yU9+maCbOA0zB1V98Q3Y8Ranj2IqydY8Kg/9M5L8RQTsoRf2oewmYS7H+BhwUTT2+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gWcx+pEPLyFB649tRgKtEMqLbPr4LdLvvcxvtRJQM/M=; b=j+47W0ENCJFNE9xgoTWYG4QYjM40+T8isFaABs6L4GFrR9GFbE6wYHBOx6aX+5FODrul+MiEl/1laz0brfIrxI0GMVvePmUIWe0hEWi8ZIaW5DSFY34TyCnYV8EIWg55Q0KlX/9AHsPEuRUUu86IKyDHL1JyY/4YWARvClfcDZU= Received: from SJ0PR05CA0088.namprd05.prod.outlook.com (2603:10b6:a03:332::33) by DM4PR12MB5820.namprd12.prod.outlook.com (2603:10b6:8:64::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9564.8; Thu, 29 Jan 2026 14:41:10 +0000 Received: from MWH0EPF000971E7.namprd02.prod.outlook.com (2603:10b6:a03:332:cafe::7a) by SJ0PR05CA0088.outlook.office365.com (2603:10b6:a03:332::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9587.4 via Frontend Transport; Thu, 29 Jan 2026 14:41:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by MWH0EPF000971E7.mail.protection.outlook.com (10.167.243.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9564.3 via Frontend Transport; Thu, 29 Jan 2026 14:41:09 +0000 Received: from BLR-L-BHARARAO.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 29 Jan 2026 08:41:00 -0600 From: Bharata B Rao To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , Bharata B Rao Subject: [RFC PATCH v5 00/10] mm: Hot page tracking and promotion infrastructure Date: Thu, 29 Jan 2026 20:10:33 +0530 Message-ID: <20260129144043.231636-1-bharata@amd.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E7:EE_|DM4PR12MB5820:EE_ X-MS-Office365-Filtering-Correlation-Id: 60e3f4b8-e5f2-45b7-4cfc-08de5f44713b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|7416014|376014|36860700013|13003099007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?Vi9oN3d3L1kvS3ZNb2N3V01iRzBMa1h0YW11VmJjaGdqUXhtaXlqMm00U3Rj?= =?utf-8?B?Smx0czlHTU9wNnlYNzhBdXBIalR6SGVEMTFsOEdKeVhGMUJFelc2U1dQWUxL?= =?utf-8?B?YXdJSFo3RnhMMlNMYklyWDRnbFlqdVVURHAyWUVRa1pUcVluVStXMHQ4d1dq?= =?utf-8?B?THMvKy9mWW9UTHBPamlHSHowLzBTQ1JTK3E3Z1ZRZHdFU1NxdHUzR210Lyta?= =?utf-8?B?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ZaUM3QmFlSmVEaDIrNzB2YVl1?= =?utf-8?B?TDVLS0t5Tm1nMGxiMjBrOVkxVHRVRFJxYnFjM2hncStTKzltRE54Rzd3M1pa?= =?utf-8?B?OHkzbnQwaWRvY01pNGhiTjFZUW9MNDA1RG5pNnJiV3N6N0g2N20wRURiYUdn?= =?utf-8?B?aWZVTUh3VVpyeWMzZWROM25wL0hIM0xMQ3hRbTBpeHkyMVZPMEV2L2hrV3RI?= =?utf-8?B?TFVFdFFBVkNFTCt4WWpsVVp4N0ZRPT0=?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(7416014)(376014)(36860700013)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2026 14:41:09.3969 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60e3f4b8-e5f2-45b7-4cfc-08de5f44713b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000971E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5820 Hi, This is v5 of pghot, a hot-page tracking and promotion subsystem. The major change in v5 is reducing the default hotness record size to 1 byte per PFN and adding an optional precision mode (CONFIG_PGHOT_PRECISE) that uses 4 bytes per PFN. This patchset introduces a new subsystem for hot page tracking and promotion (pghot) with the following goals: - Unify hot page detection from multiple sources like hint faults, page table scans, hardware hints (AMD IBS). - Decouple detection from migration. - Centralize promotion logic via per-lower-tier-node kmigrated kernel thread. - Move promotion rate‑limiting and related logic used by numa_balancing=2 (current NUMA balancing–based promotion) from the scheduler to pghot for broader reuse. Currently, multiple kernel subsystems detect page accesses independently. This patchset consolidates accesses from these mechanisms by providing: - A common API for reporting page accesses. - Shared infrastructure for tracking hotness at PFN granularity. - Per-lower-tier-node kernel threads for promoting pages. Here is a brief summary of how this subsystem works: - Tracks frequency and last access time. - Additionally, the accessing NUMA node ID (NID) for each recorded access is also tracked in the precision mode. - These hotness parameters are maintained in a per-PFN hotness record within the existing mem_section data structure. - In default mode, one byte (u8) is used for hotness record. 5 bits are used to store time and bucketing scheme is used to represent a total access time up to 4s with HZ=1000. Default toptier NID (0) is used as the target for promotion which can be changed via debugfs tunable. - In precision mode, 4 bytes (u32) are used for each hotness record. 14 bits are used to store time which can represent around 16s with HZ=1000. - Classifies pages as hot based on configurable thresholds. - Pages classified as hot are marked as ready for migration using the ready bit. Both modes use MSB of the hotness record as ready bit. - Per-lower-tier-node kmigrated threads periodically scan the PFNs of lower-tier nodes, checking for the migration-ready bit to perform batched migrations. Interval between successive scans and batching value are configurable via debugfs tunables. Memory overhead --------------- Default mode: 1 byte per lower-tier PFN. For a 1TB lower-tier memory this amounts to 256MB overhead (assuming 4K pages) Precision mode: 4 bytes per lower-tier PFN. For a 1TB of lower memory this amounts to 1G overhead. Bit layout of hotness record ---------------------------- Default mode - Bits 0-1: Frequency (2bits, 4 access samples) - Bits 2-6: Bucketed time (5bits, up to 4s with HZ=1000) - Bit 7: Migration ready bit Precision mode - Bits 0-9: Target NID (10 bits) - Bits 10-12: Frequency (3bits, 8 access samples) - Bits 13-26: Time (14bits, up to 16s with HZ=1000) - Bits 27-30: Reserved - Bit 31: Migration ready bit Integrated sources ------------------ 1. IBS - Instruction Based Sampling, hardware based sampling mechanism present on AMD CPUs. 2. klruscand - PTE‑A bit scanning built on MGLRU’s walk helpers. 3. NUMA Balancing (Tiering mode) 4. folio_mark_accessed() - Page cache access tracking (unmapped page cache pages) Changes in v5 ============= - Significant reduction in memory overhead for storing per-PFN hotness data - Two modes of operation (default and precision mode). The code which is specific to each implementation is moved to its own individual file. - Many bug fixes, code cleanups and code reorganization. Results ======= TODO: Will post benchmark nubmers as reply to this patchset soon. This v5 patchset applies on top of upstream commit 4941a17751c9 and can be fetched from: https://github.com/AMDESE/linux-mm/tree/bharata/pghot-rfcv5 v4: https://lore.kernel.org/linux-mm/20251206101423.5004-1-bharata@amd.com/ v3: https://lore.kernel.org/linux-mm/20251110052343.208768-1-bharata@amd.com/ v2: https://lore.kernel.org/linux-mm/20250910144653.212066-1-bharata@amd.com/ 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/ Bharata B Rao (7): mm: migrate: Allow misplaced migration without VMA mm: Hot page tracking and promotion mm: pghot: Precision mode for pghot mm: sched: move NUMA balancing tiering promotion to pghot x86: ibs: In-kernel IBS driver for memory access profiling x86: ibs: Enable IBS profiling for memory accesses mm: pghot: Add folio_mark_accessed() as hotness source Gregory Price (1): migrate: Add migrate_misplaced_folios_batch() Kinsey Ho (2): mm: mglru: generalize page table walk mm: klruscand: use mglru scanning for page promotion Documentation/admin-guide/mm/pghot.txt | 89 +++++ arch/x86/events/amd/ibs.c | 10 + arch/x86/include/asm/entry-common.h | 3 + arch/x86/include/asm/hardirq.h | 2 + arch/x86/include/asm/msr-index.h | 16 + arch/x86/mm/Makefile | 1 + arch/x86/mm/ibs.c | 349 +++++++++++++++++ include/linux/migrate.h | 6 + include/linux/mmzone.h | 26 ++ include/linux/pghot.h | 142 +++++++ include/linux/vm_event_item.h | 26 ++ kernel/sched/debug.c | 1 - kernel/sched/fair.c | 152 +------- mm/Kconfig | 46 +++ mm/Makefile | 7 + mm/huge_memory.c | 26 +- mm/internal.h | 4 + mm/klruscand.c | 110 ++++++ mm/memory.c | 31 +- mm/migrate.c | 41 +- mm/mm_init.c | 10 + mm/pghot-default.c | 73 ++++ mm/pghot-precise.c | 70 ++++ mm/pghot-tunables.c | 196 ++++++++++ mm/pghot.c | 505 +++++++++++++++++++++++++ mm/swap.c | 8 + mm/vmscan.c | 181 ++++++--- mm/vmstat.c | 26 ++ 28 files changed, 1917 insertions(+), 240 deletions(-) create mode 100644 Documentation/admin-guide/mm/pghot.txt 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-default.c create mode 100644 mm/pghot-precise.c create mode 100644 mm/pghot-tunables.c create mode 100644 mm/pghot.c -- 2.34.1