From nobody Sat Oct 4 00:32:10 2025 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (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 5F7D12F5491 for ; Fri, 22 Aug 2025 09:48:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755856094; cv=none; b=o+sPS+tqbMgZm8S5Brl3/hZ+yVLkn6xoTFlhpXISN0wezmpkrfes3nXRHQJW/1F3bNXnsCXO+6atMW0faCZatnTqU58XBP5Y9AgaaFCzPimYjwlBMvU0lryG+DnVa923bsQSMg8JsCMtCe3gTPXTkuF2rhGlbpNx8TfJruA54TM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755856094; c=relaxed/simple; bh=jX4XLa+Ei2Dcz7wnr9MkXGCLGpv8WXAzaE8JfLJD6CQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cVWPM9ltWKfmNUbG9naaANIyy0sK9carr9l5a3czYddQjPHzJVTfTZtAGU6C3gBxTfBj3lFH5SSmvgBEr2HHbi87yXAspy0YCeoImrsVZIDmfyy19hzn0zI6BOnaPXZKtKmHHRKXeNydFGXutfKgWiTF3i42su8qOBidLbHxTKQ= 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.32 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.112]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4c7b4W2Mkvz27jJG; Fri, 22 Aug 2025 17:49:15 +0800 (CST) Received: from dggpemf200018.china.huawei.com (unknown [7.185.36.31]) by mail.maildlp.com (Postfix) with ESMTPS id 9D58F140258; Fri, 22 Aug 2025 17:48:09 +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:08 +0800 From: Quanmin Yan To: CC: , , , , , , Subject: [PATCH v2 06/11] mm/damon/paddr: support addr_unit for DAMOS_STAT Date: Fri, 22 Aug 2025 17:34:14 +0800 Message-ID: <20250822093420.2103803-7-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 for DAMOS_STAT action handling from the DAMOS operation implementation for the physical address space. Signed-off-by: SeongJae Park Signed-off-by: Quanmin Yan Reviewed-by: SeongJae Park --- mm/damon/paddr.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 0305e59818da..5fad2f9a99a0 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -277,17 +277,18 @@ static unsigned long damon_pa_migrate(struct damon_re= gion *r, return applied * PAGE_SIZE / addr_unit; } =20 -static unsigned long damon_pa_stat(struct damon_region *r, struct damos *s, +static unsigned long damon_pa_stat(struct damon_region *r, + unsigned long addr_unit, struct damos *s, unsigned long *sz_filter_passed) { - unsigned long addr; + phys_addr_t addr; struct folio *folio; =20 if (!damos_ops_has_filter(s)) return 0; =20 - addr =3D r->ar.start; - while (addr < r->ar.end) { + addr =3D damon_pa_phys_addr(r->ar.start, addr_unit); + while (addr < damon_pa_phys_addr(r->ar.end, addr_unit)) { folio =3D damon_get_folio(PHYS_PFN(addr)); if (damon_pa_invalid_damos_folio(folio, s)) { addr +=3D PAGE_SIZE; @@ -295,7 +296,7 @@ static unsigned long damon_pa_stat(struct damon_region = *r, struct damos *s, } =20 if (!damos_pa_filter_out(s, folio)) - *sz_filter_passed +=3D folio_size(folio); + *sz_filter_passed +=3D folio_size(folio) / addr_unit; addr +=3D folio_size(folio); folio_put(folio); } @@ -322,7 +323,7 @@ static unsigned long damon_pa_apply_scheme(struct damon= _ctx *ctx, case DAMOS_MIGRATE_COLD: return damon_pa_migrate(r, aunit, scheme, sz_filter_passed); case DAMOS_STAT: - return damon_pa_stat(r, scheme, sz_filter_passed); + return damon_pa_stat(r, aunit, scheme, sz_filter_passed); default: /* DAMOS actions that not yet supported by 'paddr'. */ break; --=20 2.43.0