From nobody Sat Oct 4 00:32:10 2025 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (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 874A62EE5FE for ; Fri, 22 Aug 2025 09:48:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755856092; cv=none; b=BhhnVIcNW8PHO3dIQeJS9HUbyRJkRvPr+6flxwAppCYnrVrTbWPUBK/p0GJuVlkfqtmtCl5kS7AUEUVb8TlddZuDU9bpB/xyRTazkTdgVtleHSO6XZ+CpfHA7362F0vJsLqJExj+cr6d6V20ykc7FLFKvYWuS4SphizwdyhZwq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755856092; c=relaxed/simple; bh=Fgut11h8yU4yWyJQWtddUDJ/FKEdzel6IfB24RRD29o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cmWEOglQoDVAVfyVeeW4md4I/LLRomhuTZDH146pH8LofwWAyiyugQP3th6VXEQ/dqFs6MzZtsM0ioZrBoFMSw8a0CkCaSMSmj3vcFbLCBTsnROaUT7BbHncDYvzqxkk9TAdyEEqyVZx3ip9LniwL0HfgK48CZBRlnFAFfaK220= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4c7Zxv1mnlzPnbw; Fri, 22 Aug 2025 17:43:31 +0800 (CST) Received: from dggpemf200018.china.huawei.com (unknown [7.185.36.31]) by mail.maildlp.com (Postfix) with ESMTPS id 2DC64180495; Fri, 22 Aug 2025 17:48:07 +0800 (CST) Received: from huawei.com (10.50.85.135) by dggpemf200018.china.huawei.com (7.185.36.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 22 Aug 2025 17:48:06 +0800 From: Quanmin Yan To: CC: , , , , , , Subject: [PATCH v2 02/11] mm/damon/paddr: support addr_unit for access monitoring Date: Fri, 22 Aug 2025 17:34:10 +0800 Message-ID: <20250822093420.2103803-3-yanquanmin1@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822093420.2103803-1-yanquanmin1@huawei.com> References: <20250822093420.2103803-1-yanquanmin1@huawei.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: kwepems500002.china.huawei.com (7.221.188.17) To dggpemf200018.china.huawei.com (7.185.36.31) Content-Type: text/plain; charset="utf-8" From: SeongJae Park Add support of addr_unit paramer for access monitoing operations of paddr. Signed-off-by: SeongJae Park Signed-off-by: Quanmin Yan Reviewed-by: SeongJae Park --- mm/damon/paddr.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 0b67d9321460..d497373c2bd2 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -18,7 +18,13 @@ #include "../internal.h" #include "ops-common.h" =20 -static void damon_pa_mkold(unsigned long paddr) +static phys_addr_t damon_pa_phys_addr( + unsigned long addr, unsigned long addr_unit) +{ + return (phys_addr_t)addr * addr_unit; +} + +static void damon_pa_mkold(phys_addr_t paddr) { struct folio *folio =3D damon_get_folio(PHYS_PFN(paddr)); =20 @@ -29,11 +35,12 @@ static void damon_pa_mkold(unsigned long paddr) folio_put(folio); } =20 -static void __damon_pa_prepare_access_check(struct damon_region *r) +static void __damon_pa_prepare_access_check(struct damon_region *r, + unsigned long addr_unit) { r->sampling_addr =3D damon_rand(r->ar.start, r->ar.end); =20 - damon_pa_mkold(r->sampling_addr); + damon_pa_mkold(damon_pa_phys_addr(r->sampling_addr, addr_unit)); } =20 static void damon_pa_prepare_access_checks(struct damon_ctx *ctx) @@ -43,11 +50,11 @@ static void damon_pa_prepare_access_checks(struct damon= _ctx *ctx) =20 damon_for_each_target(t, ctx) { damon_for_each_region(r, t) - __damon_pa_prepare_access_check(r); + __damon_pa_prepare_access_check(r, ctx->addr_unit); } } =20 -static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) +static bool damon_pa_young(phys_addr_t paddr, unsigned long *folio_sz) { struct folio *folio =3D damon_get_folio(PHYS_PFN(paddr)); bool accessed; @@ -62,23 +69,25 @@ static bool damon_pa_young(unsigned long paddr, unsigne= d long *folio_sz) } =20 static void __damon_pa_check_access(struct damon_region *r, - struct damon_attrs *attrs) + struct damon_attrs *attrs, unsigned long addr_unit) { - static unsigned long last_addr; + static phys_addr_t last_addr; static unsigned long last_folio_sz =3D PAGE_SIZE; static bool last_accessed; + phys_addr_t sampling_addr =3D damon_pa_phys_addr( + r->sampling_addr, addr_unit); =20 /* If the region is in the last checked page, reuse the result */ if (ALIGN_DOWN(last_addr, last_folio_sz) =3D=3D - ALIGN_DOWN(r->sampling_addr, last_folio_sz)) { + ALIGN_DOWN(sampling_addr, last_folio_sz)) { damon_update_region_access_rate(r, last_accessed, attrs); return; } =20 - last_accessed =3D damon_pa_young(r->sampling_addr, &last_folio_sz); + last_accessed =3D damon_pa_young(sampling_addr, &last_folio_sz); damon_update_region_access_rate(r, last_accessed, attrs); =20 - last_addr =3D r->sampling_addr; + last_addr =3D sampling_addr; } =20 static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx) @@ -89,7 +98,8 @@ static unsigned int damon_pa_check_accesses(struct damon_= ctx *ctx) =20 damon_for_each_target(t, ctx) { damon_for_each_region(r, t) { - __damon_pa_check_access(r, &ctx->attrs); + __damon_pa_check_access( + r, &ctx->attrs, ctx->addr_unit); max_nr_accesses =3D max(r->nr_accesses, max_nr_accesses); } } --=20 2.43.0