From nobody Mon Feb 9 03:45:35 2026 Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012033.outbound.protection.outlook.com [40.107.209.33]) (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 A0094316904 for ; Thu, 29 Jan 2026 14:46:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.209.33 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769697969; cv=fail; b=sj8g9SnpEco55LFceWJpM0OZA40ZpqCMAc3g87VB3kZMmsPveutQW+0FOLyzgOSMqzshsUu4FtiCratS6NwwmX6TkA/bmohv1D3rB3g9APGywf+6Z+y+4Ny6X5PNSZAyHV74xqX74Qfj8dF1pGdqBK1WbyIdzZlswTp1yuvF5hI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769697969; c=relaxed/simple; bh=XS6pk5J+a0qXGZvgW2jCuVCOHOrjXyn52ljMbtDLsQ8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xp/Zf+D2f+VDUBWoh6x50hgFpOPY/oGaplrZgHMPC89gxN4cGgwV2cSNJvqKJSlvCj0ZUzXOp2tmdfDligS5jl3rqyIgWUrGQiBORtGCRvq2ePcsOs5p1WEImukRLmvqRsOl3Ir9+SstikwoUoLdMqFOm3UdAkP+j3/90INsmlg= 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=IRkbbFDC; arc=fail smtp.client-ip=40.107.209.33 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="IRkbbFDC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=er++v9Evjxy3uB05dS1RlRa4mVBkc3dsS7gS6uLshufmPrrCN+xuQ3Tzfg6CZWzrmtL+UV6dtoEzBVGVDI0KMIweIvvbcs+ft66pkkUwTd9txKKwOotnw2UPoIKTdVyxQPyE0ymwii91+AnB0HOj9CEV4K6HtaIWnSNk0OR+MWMK2msZ4YxbH0hts3rdaCjn0yqxPVu9cJOibjfEJtbF0GitsBzDbFgrBSgS64bwLpS+LEK7b/665czoqgpu7paEU8/X9Z7ADhTGT2N6gZLXQ2DUGVk8fDeT9Iebf5M95s4dDWxiwmauCYzXG47dT1hW+614F77yA0a/SBUuQLFI2g== 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=rUzm6Hs5+cDmiHjR7KYrOgazFoFm5vKrZX+/+4jyRck=; b=f3d27apH01IuJQMtWcuCGYTY2TnOjoKbQKWPjTDJ8hkmZ+W8uyCMYbMOT+2PksUwK3Y38kPyGs1rY/ST9szXY3zBA3QUh2z/HttCiRRK3G8ilRTN4pASVe2JtFh2o//C7cc5vSEwoos7k9Z3yTtVfFc55BRnDUrbzCb9OA+p+wgRubwlezO9KmygLecWOS4Tcpr/rlOmecsnmZP5+oKQnpE/Ytg1Kj9caACUCbprhTxvqZf/v7aFSzoSibPIwvkC6Y+GKaX71Nqbfv2AGxPNK0Dpx/ot2d//h1Y9sJfpkvlhnv711xsv0jCjTygPh3pgNAeQoC/VFxUKt9Dul2kyIw== 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=rUzm6Hs5+cDmiHjR7KYrOgazFoFm5vKrZX+/+4jyRck=; b=IRkbbFDCn4MOizfQitHnOvhpB5ws6/9wRbNeClJaPcYQgBik9+WlyLHdTwsm60935sxzb7N7o763Doh2MOuNwljxGd8VX7n0/lZxXLw6QZU1cdbQtiRZ16FnBMMOpF1fkBxOVeCKKxnbRsl+j4E4AMgjWV1GPmnXuHwhEJrjYC0= Received: from BN0PR04CA0106.namprd04.prod.outlook.com (2603:10b6:408:ec::21) by SA3PR12MB9198.namprd12.prod.outlook.com (2603:10b6:806:39f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.14; Thu, 29 Jan 2026 14:45:57 +0000 Received: from BN2PEPF000055E0.namprd21.prod.outlook.com (2603:10b6:408:ec:cafe::af) by BN0PR04CA0106.outlook.office365.com (2603:10b6:408:ec::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.16 via Frontend Transport; Thu, 29 Jan 2026 14:45:28 +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 BN2PEPF000055E0.mail.protection.outlook.com (10.167.245.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9587.0 via Frontend Transport; Thu, 29 Jan 2026 14:45:54 +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:45:47 -0600 From: Bharata B Rao To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , Bharata B Rao Subject: [RFC PATCH v5 10/10] mm: pghot: Add folio_mark_accessed() as hotness source Date: Thu, 29 Jan 2026 20:10:43 +0530 Message-ID: <20260129144043.231636-11-bharata@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260129144043.231636-1-bharata@amd.com> References: <20260129144043.231636-1-bharata@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: BN2PEPF000055E0:EE_|SA3PR12MB9198:EE_ X-MS-Office365-Filtering-Correlation-Id: 5028aa15-3d37-4d69-e51e-08de5f451b61 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?qFce0gvOTFTkT7ztL/buvPlWPFEQyLGlkKKSoo/6bRV4aLlyURb3ZuMSc5RN?= =?us-ascii?Q?L7H64cyxi9b7lxT9C1uSa9bKRN0GSdstTOUX1L3Nfgcdwu2Bf4Opv6rurMu7?= =?us-ascii?Q?uT9JQBArjIgWeUlGqbQuGConerHo32j9hTgxOGe2Vo4XK+fKo8rzyfIfL+JY?= =?us-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gzxLYVsXsVBlmgwPDX0xyYn3M/gnfXp?= =?us-ascii?Q?sAhe23bS8Y6ML0b32jWHpeytv1fyc9tRvJH6ljhTW67/Gn+oPLeereLmz4J/?= =?us-ascii?Q?9vdpWXWEREdWcIQ3JYI+VyO/aZ0BE4Isr3JDr3oAzMmdHZVl2/RFUIc6UY8L?= =?us-ascii?Q?MK8pJvY6Ol/dGYEAR4xvlUq+EaVT6MVsBt6q5yUaFmrpOfpxEqGG7p2J5gBC?= =?us-ascii?Q?8Jp+5jCbrodYaNbeWlhLZLSTMc9VXxQEh+RhdIpbxPwFMvOb47SXlU1JTc45?= =?us-ascii?Q?GY9eUB533Su6EHsHIVM25XuKmSjx90mj0m7fQUdlCTFhtmq6Itby6tyxzom+?= =?us-ascii?Q?Kz2ugVpBiKL0ykwtQxEggzcziN1qhRPmYYMrcwFlnO7CnUQwZrHcewH3Z+LM?= =?us-ascii?Q?ymWr6xfRSYebWKTHVXJ3P75Z/G4qtNe2hgmoYD8ny1EKgDpedS8MRXE9sE8Y?= =?us-ascii?Q?j9arJ2+7/SsuEa34mAUwrsFAZ0d8YI5mNUZrb3FaNkc7MhG7rkCvi7JHaYD4?= =?us-ascii?Q?0G2WUmXY15OJd/nti6M9N3bSrS2Vy6wBsmbQHj2Y1u7EVn38B9cxIF0MbGjt?= =?us-ascii?Q?mD4xygcczW/wSw4RZZpfueYP631EpBq0a8jw7LxgLozH3y6dOeqDQiLHxAC6?= =?us-ascii?Q?uswEtw=3D=3D?= 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)(7416014)(376014)(1800799024)(36860700013)(82310400026)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2026 14:45:54.9547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5028aa15-3d37-4d69-e51e-08de5f451b61 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: BN2PEPF000055E0.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9198 Content-Type: text/plain; charset="utf-8" Unmapped page cache pages that end up in lower tiers don't get promoted easily. There were attempts to identify such pages and get them promoted as part of NUMA Balancing earlier [1]. The same idea is taken forward here by using folio_mark_accessed() as a source of hotness. Lower tier accesses from folio_mark_accessed() are reported to pghot sub-system for hotness tracking and subsequent promotion. TODO: Need a better naming for this hotness source. Need to better understand/evaluate the overhead of hotness info collection from this path. [1] https://lore.kernel.org/linux-mm/20250411221111.493193-1-gourry@gourry.= net/ Signed-off-by: Bharata B Rao --- Documentation/admin-guide/mm/pghot.txt | 7 ++++++- include/linux/pghot.h | 5 +++++ include/linux/vm_event_item.h | 1 + mm/pghot-tunables.c | 7 +++++++ mm/pghot.c | 6 ++++++ mm/swap.c | 8 ++++++++ mm/vmstat.c | 1 + 7 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/mm/pghot.txt b/Documentation/admin-g= uide/mm/pghot.txt index b329e692ef89..c8eb61064247 100644 --- a/Documentation/admin-guide/mm/pghot.txt +++ b/Documentation/admin-guide/mm/pghot.txt @@ -23,9 +23,10 @@ Path: /sys/kernel/debug/pghot/ - 0: Hardware hints (value 0x1) - 1: Page table scan (value 0x2) - 2: Hint faults (value 0x4) + - 3: folio_mark_accessed (value 0x8) - Default: 0 (disabled) - Example: - # echo 0x7 > /sys/kernel/debug/pghot/enabled_sources + # echo 0xf > /sys/kernel/debug/pghot/enabled_sources Enables all sources. =20 2. **target_nid** @@ -82,3 +83,7 @@ Path: /proc/vmstat 4. **pghot_recorded_hintfaults** - Number of recorded accesses reported by NUMA Balancing based hotness source. + +5. **pghot_recorded_fma** + - Number of recorded accesses reported by folio_mark_accessed() + hotness source. diff --git a/include/linux/pghot.h b/include/linux/pghot.h index 603791183102..8cf9dfb5365a 100644 --- a/include/linux/pghot.h +++ b/include/linux/pghot.h @@ -19,6 +19,7 @@ enum pghot_src { PGHOT_HW_HINTS, PGHOT_PGTABLE_SCAN, PGHOT_HINT_FAULT, + PGHOT_FMA, }; =20 #ifdef CONFIG_PGHOT @@ -36,6 +37,7 @@ void pghot_debug_init(void); DECLARE_STATIC_KEY_FALSE(pghot_src_hwhints); DECLARE_STATIC_KEY_FALSE(pghot_src_pgtscans); DECLARE_STATIC_KEY_FALSE(pghot_src_hintfaults); +DECLARE_STATIC_KEY_FALSE(pghot_src_fma); =20 /* * Bit positions to enable individual sources in pghot/records_enabled @@ -45,6 +47,7 @@ enum pghot_src_enabled { PGHOT_HWHINTS_BIT =3D 0, PGHOT_PGTSCAN_BIT, PGHOT_HINTFAULT_BIT, + PGHOT_FMA_BIT, PGHOT_MAX_BIT }; =20 @@ -52,6 +55,8 @@ enum pghot_src_enabled { #define PGHOT_PGTSCAN_ENABLED BIT(PGHOT_PGTSCAN_BIT) #define PGHOT_HINTFAULT_ENABLED BIT(PGHOT_HINTFAULT_BIT) #define PGHOT_SRC_ENABLED_MASK GENMASK(PGHOT_MAX_BIT - 1, 0) +#define PGHOT_FMA_ENABLED BIT(PGHOT_FMA_BIT) +#define PGHOT_SRC_ENABLED_MASK GENMASK(PGHOT_MAX_BIT - 1, 0) =20 #define PGHOT_DEFAULT_FREQ_THRESHOLD 2 =20 diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 67efbca9051c..ac1f28646b9c 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -193,6 +193,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, PGHOT_RECORD_HWHINTS, PGHOT_RECORD_PGTSCANS, PGHOT_RECORD_HINTFAULTS, + PGHOT_RECORD_FMA, #ifdef CONFIG_HWMEM_PROFILER HWHINT_NR_EVENTS, HWHINT_KERNEL, diff --git a/mm/pghot-tunables.c b/mm/pghot-tunables.c index 79afbcb1e4f0..11c7f742a1be 100644 --- a/mm/pghot-tunables.c +++ b/mm/pghot-tunables.c @@ -124,6 +124,13 @@ static void pghot_src_enabled_update(unsigned int enab= led) else static_branch_disable(&pghot_src_hintfaults); } + + if (changed & PGHOT_FMA_ENABLED) { + if (enabled & PGHOT_FMA_ENABLED) + static_branch_enable(&pghot_src_fma); + else + static_branch_disable(&pghot_src_fma); + } } =20 static ssize_t pghot_src_enabled_write(struct file *filp, const char __use= r *ubuf, diff --git a/mm/pghot.c b/mm/pghot.c index 6fc76c1eaff8..537f4af816ff 100644 --- a/mm/pghot.c +++ b/mm/pghot.c @@ -43,6 +43,7 @@ static unsigned int sysctl_pghot_promote_rate_limit =3D 6= 5536; DEFINE_STATIC_KEY_FALSE(pghot_src_hwhints); DEFINE_STATIC_KEY_FALSE(pghot_src_pgtscans); DEFINE_STATIC_KEY_FALSE(pghot_src_hintfaults); +DEFINE_STATIC_KEY_FALSE(pghot_src_fma); =20 #ifdef CONFIG_SYSCTL static const struct ctl_table pghot_sysctls[] =3D { @@ -113,6 +114,11 @@ int pghot_record_access(unsigned long pfn, int nid, in= t src, unsigned long now) return -EINVAL; count_vm_event(PGHOT_RECORD_HINTFAULTS); break; + case PGHOT_FMA: + if (!static_branch_likely(&pghot_src_fma)) + return -EINVAL; + count_vm_event(PGHOT_RECORD_FMA); + break; default: return -EINVAL; } diff --git a/mm/swap.c b/mm/swap.c index 2260dcd2775e..31a654b19844 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -37,6 +37,8 @@ #include #include #include +#include +#include =20 #include "internal.h" =20 @@ -454,8 +456,14 @@ static bool lru_gen_clear_refs(struct folio *folio) */ void folio_mark_accessed(struct folio *folio) { + unsigned long pfn =3D folio_pfn(folio); + if (folio_test_dropbehind(folio)) return; + + if (!node_is_toptier(pfn_to_nid(pfn))) + pghot_record_access(pfn, NUMA_NO_NODE, PGHOT_FMA, jiffies); + if (lru_gen_enabled()) { lru_gen_inc_refs(folio); return; diff --git a/mm/vmstat.c b/mm/vmstat.c index 62c47f44edf0..c4d90baf440b 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1506,6 +1506,7 @@ const char * const vmstat_text[] =3D { [I(PGHOT_RECORD_HWHINTS)] =3D "pghot_recorded_hwhints", [I(PGHOT_RECORD_PGTSCANS)] =3D "pghot_recorded_pgtscans", [I(PGHOT_RECORD_HINTFAULTS)] =3D "pghot_recorded_hintfaults", + [I(PGHOT_RECORD_FMA)] =3D "pghot_recorded_fma", #ifdef CONFIG_HWMEM_PROFILER [I(HWHINT_NR_EVENTS)] =3D "hwhint_nr_events", [I(HWHINT_KERNEL)] =3D "hwhint_kernel", --=20 2.34.1