From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 260861D63E4 for ; Wed, 9 Jul 2025 02:23:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752027833; cv=none; b=mcuDCn8xeyLSw8zUOTb/BEgEckilGNMrkLGzpkJHdEQyRqa6/aYZB3W3CwgmoVY9wGklm/EcwoExZ9WT3XYhoiSaBtsWtB6sOZxInmboTvmjNnHvOL7XM4XcWy0jd/v0gDtLgiiq18QN5pcWNbmTKRw5KW/HowsVnxDNIhJDqWs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752027833; c=relaxed/simple; bh=6Luw25RhWBCsueZey56ljVJP0dBXbUSAmsKN1Hm0M68=; h=Date:To:From:Subject:Message-Id; b=SeLCQBqpecHAhzMd4JpNIFcQgbcd434J5KYYp3Oq6K+spG1MTF3IjBEjVgZoGmia5FWq2HSOWfHGVe7/bLTXJFgOyCiAACPwjLoDn6m+2aoT4rX5v5XWd96NxJsVb4iex033CR5jMg1GU/XmOCqVm41HNzwv3GCYadwCdGnleZI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=v5zxUpUo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="v5zxUpUo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A319EC4CEED; Wed, 9 Jul 2025 02:23:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1752027832; bh=6Luw25RhWBCsueZey56ljVJP0dBXbUSAmsKN1Hm0M68=; h=Date:To:From:Subject:From; b=v5zxUpUoCT04+TzeiSfGYUIjFFdXnoMiHEso9mhPEHE5lMZ7d0CDj4lzktWuZl6Tv 25/NjlRKpP9yIseyxUaHQPyeUVUJGurYWIY7Kb0OBviv3ubf0qWdmZ7RDto93TI8yc f/IXnnwagko06yXb9WvPHl4yy6uYh08MZH+r3N18= Date: Tue, 08 Jul 2025 19:23:52 -0700 To: mm-commits@vger.kernel.org,sj@kernel.org,ravis.opensrc@micron.com,corbet@lwn.net,bijantabatab@micron.com,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-damon-vaddr-add-vaddr-versions-of-migrate_hotcold.patch added to mm-new branch Message-Id: <20250709022352.A319EC4CEED@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm/damon/vaddr: add vaddr versions of migrate_{hot,cold} has been added to the -mm mm-new branch. Its filename is mm-damon-vaddr-add-vaddr-versions-of-migrate_hotcold.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-vaddr-add-vaddr-versions-of-migrate_hotcold.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Bijan Tabatabai Subject: mm/damon/vaddr: add vaddr versions of migrate_{hot,cold} Date: Tue, 8 Jul 2025 19:59:39 -0500 migrate_{hot,cold} are paddr schemes that are used to migrate hot/cold data to a specified node. However, these schemes are only available when doing physical address monitoring. This patch adds an implementation for them virtual address monitoring as well. Link: https://lkml.kernel.org/r/20250709005952.17776-10-bijan311@gmail.com Co-developed-by: Ravi Shankar Jonnalagadda Signed-off-by: Ravi Shankar Jonnalagadda Signed-off-by: Bijan Tabatabai Cc: Jonathan Corbet Cc: SeongJae Park Signed-off-by: Andrew Morton --- mm/damon/vaddr.c | 98 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) --- a/mm/damon/vaddr.c~mm-damon-vaddr-add-vaddr-versions-of-migrate_hotcold +++ a/mm/damon/vaddr.c @@ -15,6 +15,7 @@ #include #include +#include "../internal.h" #include "ops-common.h" #ifdef CONFIG_DAMON_VADDR_KUNIT_TEST @@ -610,6 +611,68 @@ static unsigned int damon_va_check_acces return max_nr_accesses; } +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +static int damos_va_migrate_pmd_entry(pmd_t *pmd, unsigned long addr, + unsigned long next, struct mm_walk *walk) +{ + struct list_head *migration_list = walk->private; + struct folio *folio; + spinlock_t *ptl; + pmd_t pmde; + + ptl = pmd_lock(walk->mm, pmd); + pmde = pmdp_get(pmd); + + if (!pmd_present(pmde) || !pmd_trans_huge(pmde)) + goto unlock; + + /* Tell page walk code to not split the PMD */ + walk->action = ACTION_CONTINUE; + + folio = damon_get_folio(pmd_pfn(pmde)); + if (!folio) + goto unlock; + + if (!folio_isolate_lru(folio)) + goto put_folio; + + list_add(&folio->lru, migration_list); + +put_folio: + folio_put(folio); +unlock: + spin_unlock(ptl); + return 0; +} +#else +#define damos_va_migrate_pmd_entry NULL +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ + +static int damos_va_migrate_pte_entry(pte_t *pte, unsigned long addr, + unsigned long next, struct mm_walk *walk) +{ + struct list_head *migration_list = walk->private; + struct folio *folio; + pte_t ptent; + + ptent = ptep_get(pte); + if (pte_none(ptent) || !pte_present(ptent)) + return 0; + + folio = damon_get_folio(pte_pfn(ptent)); + if (!folio) + return 0; + + if (!folio_isolate_lru(folio)) + goto out; + + list_add(&folio->lru, migration_list); + +out: + folio_put(folio); + return 0; +} + /* * Functions for the target validity check and cleanup */ @@ -653,6 +716,34 @@ static unsigned long damos_madvise(struc } #endif /* CONFIG_ADVISE_SYSCALLS */ +static unsigned long damos_va_migrate(struct damon_target *target, + struct damon_region *r, struct damos *s, + unsigned long *sz_filter_passed) +{ + LIST_HEAD(folio_list); + struct mm_struct *mm; + unsigned long applied = 0; + struct mm_walk_ops walk_ops = { + .pmd_entry = damos_va_migrate_pmd_entry, + .pte_entry = damos_va_migrate_pte_entry, + .walk_lock = PGWALK_RDLOCK, + }; + + mm = damon_get_mm(target); + if (!mm) + return 0; + + mmap_read_lock(mm); + walk_page_range(mm, r->ar.start, r->ar.end, &walk_ops, &folio_list); + mmap_read_unlock(mm); + mmput(mm); + + applied = damon_migrate_pages(&folio_list, s->target_nid); + cond_resched(); + + return applied * PAGE_SIZE; +} + static unsigned long damon_va_apply_scheme(struct damon_ctx *ctx, struct damon_target *t, struct damon_region *r, struct damos *scheme, unsigned long *sz_filter_passed) @@ -675,6 +766,9 @@ static unsigned long damon_va_apply_sche case DAMOS_NOHUGEPAGE: madv_action = MADV_NOHUGEPAGE; break; + case DAMOS_MIGRATE_HOT: + case DAMOS_MIGRATE_COLD: + return damos_va_migrate(t, r, scheme, sz_filter_passed); case DAMOS_STAT: return 0; default: @@ -695,6 +789,10 @@ static int damon_va_scheme_score(struct switch (scheme->action) { case DAMOS_PAGEOUT: return damon_cold_score(context, r, scheme); + case DAMOS_MIGRATE_HOT: + return damon_hot_score(context, r, scheme); + case DAMOS_MIGRATE_COLD: + return damon_cold_score(context, r, scheme); default: break; } _ Patches currently in -mm which might be from bijantabatab@micron.com are mm-damon-core-commit-damos-target_nid.patch mm-damon-core-commit-damos-migrate_dests.patch mm-damon-move-migration-helpers-from-paddr-to-ops-common.patch mm-damon-vaddr-add-vaddr-versions-of-migrate_hotcold.patch docs-mm-damon-design-document-vaddr-support-for-migrate_hotcold.patch mm-damon-vaddr-use-damos-migrate_dests-in-migrate_hotcold.patch mm-damon-move-folio-filtering-from-paddr-to-ops-common.patch mm-damon-vaddr-apply-filters-in-migrate_hot-cold.patch