From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.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 20FEA284886 for ; Wed, 26 Nov 2025 13:50:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764165007; cv=none; b=gtJhWOTi6+PnJI42DF70b/w5GVRZ0H3nbX1N6Dj1dKdgXbAz9/rrhLTqXqNrQLo/mzhqomDBrh8mWdKo8pt7U6/kLYYd+bDJ7SxBvZjG1PbDTvh8ANTGKepfk6GH0V24xRU2rz9fhYHEZ5kQqYI6yeicSvtpt4P0UKH0uW9iQ/o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764165007; c=relaxed/simple; bh=7tlh/wfmEgDspOI3bEw3RM4kfUeKnWbM2FN3vPSxsVI=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:In-Reply-To: Content-Type:References; b=W3BS30kW6brRiHNsdAxvlLsyDFKkXB2vW12l3kgyrut6uleAO4RRZM1JtbKBPRBfh+htIyX1/z6L4SdpYv8NHWFM9mq24p5kyxSf+GAt2kzbX7om9cuOfcn0DaUNoRlYl/Atwg/zBdrj9/jWwbdsWebk9EELXgb+K+KK+ybecdE= 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=NhWivFtX; arc=none smtp.client-ip=203.254.224.33 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="NhWivFtX" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20251126135002epoutp03b06aba9dcb92930bab7cb9fa9abc610b~7krkdHftk1180211802epoutp03d for ; Wed, 26 Nov 2025 13:50:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20251126135002epoutp03b06aba9dcb92930bab7cb9fa9abc610b~7krkdHftk1180211802epoutp03d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1764165002; bh=nYJjotrkxNwVzA+wabEwI8W6n2EiGBbBw3Ldq8jIFmo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NhWivFtX1O5ygsumaPnKKDcK+AhAVWYBJY5gwrDWZ/yKl80rFlrVSPAF3ztr9cVNR hTpbGQ4V4bwHFOsEtVQLi7bWKMv/o/8WMvvLvMAX9Ky/GQwkVIMBDcUDMDoEZcq9/p hJ1LyvPpO25MUKzOIUJ4FjEGZfbi1HsucZHSRBqI= Received: from epsnrtp03.localdomain (unknown [182.195.42.155]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPS id 20251126135001epcas5p3880f9faacc98aa0e9555392b5e99def7~7krje6F7a2648726487epcas5p3E; Wed, 26 Nov 2025 13:50:01 +0000 (GMT) Received: from epcpadp1new (unknown [182.195.40.141]) by epsnrtp03.localdomain (Postfix) with ESMTP id 4dGgt15Djkz3hhT4; Wed, 26 Nov 2025 13:50:01 +0000 (GMT) Received: from epsmtip1.samsung.com (unknown [182.195.34.30]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20251126132450epcas5p123220533572f40d70799294cd3ca4819~7kVkYPkAO2180121801epcas5p1O; Wed, 26 Nov 2025 13:24:50 +0000 (GMT) Received: from test-PowerEdge-R740xd (unknown [107.99.41.79]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20251126132443epsmtip1690557373ad981c299b65525802e4e32~7kVdmwiMw0381303813epsmtip1w; Wed, 26 Nov 2025 13:24:43 +0000 (GMT) Date: Wed, 26 Nov 2025 18:54:35 +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, cpgs@samsung.com Subject: Re: [RFC PATCH v3 3/8] mm: Hot page tracking and promotion Message-ID: <1983025922.01764165001727.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: <20251110052343.208768-4-bharata@amd.com> X-CMS-MailID: 20251126132450epcas5p123220533572f40d70799294cd3ca4819 X-Msg-Generator: CA Content-Type: multipart/mixed; boundary="----on9-joxjuqL8vLZJsXK9p6vuNy0FCcc_Bo-VMubfWYorGk78=_35b0b_" CMS-TYPE: 105P X-CPGSPASS: Y X-Hop-Count: 3 X-CMS-RootMailID: 20251126132450epcas5p123220533572f40d70799294cd3ca4819 References: <20251110052343.208768-1-bharata@amd.com> <20251110052343.208768-4-bharata@amd.com> ------on9-joxjuqL8vLZJsXK9p6vuNy0FCcc_Bo-VMubfWYorGk78=_35b0b_ Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Disposition: inline On 10/11/25 10:53AM, 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. > >Also, the access time provided some sources may at best be >considered approximate. This is especially true for hot pages >detected by PTE A bit scanning. > >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. > >Signed-off-by: Bharata B Rao >--- > include/linux/mmzone.h | 14 ++ > include/linux/pghot.h | 52 ++++ > include/linux/vm_event_item.h | 4 + > mm/Kconfig | 11 + > mm/Makefile | 1 + > mm/mm_init.c | 10 + > mm/page_ext.c | 11 + > mm/pghot.c | 446 ++++++++++++++++++++++++++++++++++ > mm/vmstat.c | 4 + > 9 files changed, 553 insertions(+) > create mode 100644 include/linux/pghot.h > create mode 100644 mm/pghot.c > >+ >+/* >+ * Walks the PFNs of the zone, isolates and migrates them in batches. >+ */ >+static void kmigrated_walk_zone(unsigned long start_pfn, unsigned long end_pfn, >+ int src_nid) >+{ >+ int cur_nid = NUMA_NO_NODE; >+ LIST_HEAD(migrate_list); >+ int batch_count = 0; >+ struct folio *folio; >+ struct page *page; >+ unsigned long pfn; >+ >+ pfn = start_pfn; >+ do { >+ unsigned long nid = NUMA_NO_NODE, freq = 0, time = 0, nr = 1; >+ >+ if (!pfn_valid(pfn)) >+ goto out_next; >+ >+ page = pfn_to_online_page(pfn); >+ if (!page) >+ goto out_next; >+ >+ folio = page_folio(page); >+ nr = folio_nr_pages(folio); >+ if (folio_nid(folio) != src_nid) >+ goto out_next; >+ >+ if (!folio_test_lru(folio)) >+ goto out_next; >+ >+ if (pghot_get_hotness(pfn, &nid, &freq, &time)) Better to remove freq value, it’s not used later. Regards, Alok Rathore ------on9-joxjuqL8vLZJsXK9p6vuNy0FCcc_Bo-VMubfWYorGk78=_35b0b_ Content-Type: text/plain; charset="utf-8" ------on9-joxjuqL8vLZJsXK9p6vuNy0FCcc_Bo-VMubfWYorGk78=_35b0b_--