From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (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 85906342C9E for ; Mon, 22 Dec 2025 10:28:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766399306; cv=none; b=dErhxzhZueQMVEiIWSzFlJVOfXc90Y+Kt+dTMTpbZf2LMVevuTcnHAdXIg7U4O8vEwHmLwFvvha6m02hZz/ClQnhN2yxVtlZGCOZ2XnWLgi0ixVnnE8UUJMi7tcXwa33M/7MgcxDWINwRJ9B+n7vsehjJopI4bWITFssIISP5lQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766399306; c=relaxed/simple; bh=yMDtYjZgQECxxPR3ImMe/OchysUvvw//E/+tmdkaDpo=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:In-Reply-To: Content-Type:References; b=nRWdObZf0vz/dlztTga64vGQI7inW4cFf+Y9ySFLF/Vesiy+6zA5jGgv3FKNTqOzL32vhDpjb0MPcY6w+OhK726Ob8g0bf1H4DVh940P59H/FbdW0/eH5pnQ1lvbOwh81gWUJGSe4lMltJ7qNNUZFC2Z/OvdNChSE4zqOXAxJf0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=YExNtzNp; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="YExNtzNp" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20251222102003epoutp02d8a8b9eff3f11d5f89eb34b1b51cfe25~Dglp2gC2M1164811648epoutp02t; Mon, 22 Dec 2025 10:20:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20251222102003epoutp02d8a8b9eff3f11d5f89eb34b1b51cfe25~Dglp2gC2M1164811648epoutp02t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1766398803; bh=iFw/FFLjXpV1aTmhrvnbspHZO+4aypiGinSWzi3VTcs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=YExNtzNpgb/ZELsmpjZ4Hi6x3CSEc07tIGOAXLYh29W4XliI7lkrG/ux51Hn9w31P ePoid/2NPDg0bVKtap3ZOsehSU+7T+ZUORs1hX3BM3/I7Uo888wJe738hgk5ruOtwE pDL5lefA6mhdu0HzODT05t9Ps+WLfGlH61ZIIP1g= Received: from epsnrtp01.localdomain (unknown [182.195.42.153]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPS id 20251222102003epcas5p444e057d306fc02ab41075b4458f8710f~Dglpioc2e2320923209epcas5p4G; Mon, 22 Dec 2025 10:20:03 +0000 (GMT) Received: from epcpadp1new (unknown [182.195.40.141]) by epsnrtp01.localdomain (Postfix) with ESMTP id 4dZYzl3pN5z6B9m5; Mon, 22 Dec 2025 10:20:03 +0000 (GMT) Received: from epsmtip2.samsung.com (unknown [182.195.34.31]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20251222101745epcas5p43ca3a6a59efe996cd62769e8d57bb81d~Dgjo6EToi2922429224epcas5p4k; Mon, 22 Dec 2025 10:17:45 +0000 (GMT) Received: from test-PowerEdge-R740xd (unknown [107.99.41.79]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20251222101734epsmtip2a9293df1d5ea6e02bbc8d3cc0a8321db~DgjfEfHIV1164911649epsmtip2a; Mon, 22 Dec 2025 10:17:34 +0000 (GMT) Date: Mon, 22 Dec 2025 15:47:21 +0530 From: Alok Rathore To: Bharata B Rao Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jonathan.Cameron@huawei.com, dave.hansen@intel.com, gourry@gourry.net, mgorman@techsingularity.net, mingo@redhat.com, peterz@infradead.org, raghavendra.kt@amd.com, riel@surriel.com, rientjes@google.com, sj@kernel.org, weixugc@google.com, willy@infradead.org, ying.huang@linux.alibaba.com, ziy@nvidia.com, dave@stgolabs.net, nifan.cxl@gmail.com, xuezhengchu@huawei.com, yiannis@zptcorp.com, akpm@linux-foundation.org, david@redhat.com, byungchul@sk.com, kinseyho@google.com, joshua.hahnjy@gmail.com, yuanchu@google.com, balbirs@nvidia.com, shivankg@amd.com, alokrathore20@gmail.com, gost.dev@samsung.com, cpgs@samsung.com Subject: Re: [RFC PATCH v4 3/9] mm: Hot page tracking and promotion Message-ID: <158453976.61766398803526.JavaMail.epsvc@epcpadp1new> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20251206101423.5004-4-bharata@amd.com> X-CMS-MailID: 20251222101745epcas5p43ca3a6a59efe996cd62769e8d57bb81d X-Msg-Generator: CA Content-Type: multipart/mixed; boundary="----Rvty6Ov.E7w8fqTiecbGSIlWaDZOz3Joz9WFZpHBwcJNCC2Q=_9fec5_" CMS-TYPE: 105P X-CPGSPASS: Y X-Hop-Count: 3 X-CMS-RootMailID: 20251222101745epcas5p43ca3a6a59efe996cd62769e8d57bb81d References: <20251206101423.5004-1-bharata@amd.com> <20251206101423.5004-4-bharata@amd.com> ------Rvty6Ov.E7w8fqTiecbGSIlWaDZOz3Joz9WFZpHBwcJNCC2Q=_9fec5_ Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Disposition: inline On 06/12/25 03:44PM, Bharata B Rao wrote: >This introduces a sub-system for collecting memory access >information from different sources. It maintains the hotness >information based on the access history and time of access. > >Additionally, it provides per-lowertier-node kernel threads >(named kmigrated) that periodically promote the pages that >are eligible for promotion. > >Sub-systems that generate hot page access info can report that >using this API: > >int pghot_record_access(unsigned long pfn, int nid, int src, > unsigned long time) > >@pfn: The PFN of the memory accessed >@nid: The accessing NUMA node ID >@src: The temperature source (sub-system) that generated the > access info >@time: The access time in jiffies > >Some temperature sources may not provide the nid from which >the page was accessed. This is true for sources that use >page table scanning for PTE Accessed bit. For such sources, >the default toptier node to which such pages should be promoted >is hard coded. > >The hotness information is stored for every page of lower >tier memory in an unsigned long variable that is part of >mem_section data structure. > >kmigrated is a per-lowertier-node kernel thread that migrates >the folios marked for migration in batches. Each kmigrated >thread walks the PFN range spanning its node and checks >for potential migration candidates. > >A bunch of tunables for enabling different hotness sources, >setting target_nid, frequency threshold are provided in debugfs. > >Signed-off-by: Bharata B Rao >+++ b/include/linux/pghot.h >@@ -0,0 +1,71 @@ >+/* SPDX-License-Identifier: GPL-2.0 */ >+#ifndef _LINUX_PGHOT_H >+#define _LINUX_PGHOT_H >+ >+/* Page hotness temperature sources */ >+enum pghot_src { >+ PGHOT_HW_HINTS, >+ PGHOT_PGTABLE_SCAN, >+ PGHOT_HINT_FAULT, >+}; >+ >+#ifdef CONFIG_PGHOT >+/* >+ * Bit positions to enable individual sources in pghot/records_enabled >+ * of debugfs. >+ */ >+enum pghot_src_enabed { >+ PGHOT_HWHINTS_BIT = 0, >+ PGHOT_PGTSCAN_BIT, >+ PGHOT_HINTFAULT_BIT, >+ PGHOT_MAX_BIT >+}; >+ >+#define PGHOT_HWHINTS_ENABLED BIT(PGHOT_HWHINTS_BIT) >+#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_DEFAULT_FREQ_WINDOW (5 * MSEC_PER_SEC) >+#define PGHOT_DEFAULT_FREQ_THRESHOLD 2 >+ >+#define KMIGRATED_DEFAULT_SLEEP_MS 100 >+#define KMIGRATED_DEFAULT_BATCH_NR 512 >+ >+#define PGHOT_DEFAULT_NODE 0 >+ >+/* >+ * Bits 0-31 are used to store nid, frequency and time. >+ * Bits 32-62 are unused now. >+ * Bit 63 is used to indicate the page is ready for migration. >+ */ >+#define PGHOT_MIGRATE_READY 63 >+ >+#define PGHOT_NID_WIDTH 10 >+#define PGHOT_FREQ_WIDTH 3 >+/* time is stored in 19 bits which can represent up to 8.73s with HZ=1000 */ If we consider HZ = 1000 then using 19 bit time is coming 8.73 mins. I think by mistake you commented as 8.73 secs. Suggetion: If we are targeting to promote page in ~8 secs then 13 bits would be enough, that way we can handle hotness using 32 bits per pfn insead of 64 bits. #define PGHOT_MIGRATE_READY 31 #define PGHOT_NID_WIDTH 10 #define PGHOT_FREQ_WIDTH 3 /* time is stored in 13 bits which can represent up to 8.19s with HZ=1000 */ #define PGHOT_TIME_WIDTH 13 >+#define PGHOT_TIME_WIDTH 19 >+ >+#define PGHOT_NID_SHIFT 0 >+#define PGHOT_FREQ_SHIFT (PGHOT_NID_SHIFT + PGHOT_NID_WIDTH) >+#define PGHOT_TIME_SHIFT (PGHOT_FREQ_SHIFT + PGHOT_FREQ_WIDTH) >+ >+#define PGHOT_NID_MASK ((1UL << PGHOT_NID_SHIFT) - 1) >+#define PGHOT_FREQ_MASK ((1UL << PGHOT_FREQ_SHIFT) - 1) >+#define PGHOT_TIME_MASK ((1UL << PGHOT_TIME_SHIFT) - 1) Mask generation of freq, nid and time seems not correct. It should be #define PGHOT_NID_MASK ((1UL << PGHOT_NID_WIDTH) - 1) #define PGHOT_FREQ_MASK ((1UL << PGHOT_FREQ_WIDTH) - 1) #define PGHOT_TIME_MASK ((1UL << PGHOT_TIME_WIDTH) - 1) Can you please have a look? Regards, Alok Rathore ------Rvty6Ov.E7w8fqTiecbGSIlWaDZOz3Joz9WFZpHBwcJNCC2Q=_9fec5_ Content-Type: text/plain; charset="utf-8" ------Rvty6Ov.E7w8fqTiecbGSIlWaDZOz3Joz9WFZpHBwcJNCC2Q=_9fec5_--