From nobody Sat Oct 4 06:37:49 2025 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 BDC4D2DA76F for ; Wed, 20 Aug 2025 08:20:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755678016; cv=none; b=mj5CN+VtNoZ2BwSd1eQ63B63Ol5D0bmJIJlDX+d+z4EQ3nnQsEBP/U42Ckmmgce3F0DfS3ZbgQi0c9Uu+hUNVHYQQBZRbD6dVBSphfhTZsHyc69lbDuDQAQXTZ9N+1HI+DrJ1PUuZQ2bCHlW5LjoXgMY8uSBjtMLidztdWSrAto= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755678016; c=relaxed/simple; bh=+VT3qcPTdQYv7Btq06E7aQ9Y8JOxL5JGYeobA8Aa3iM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rmfL1XEJXsYO3bpE/D3xVPagPH0Uf7zYjFkf4k7ipZRY1IiF14zyE7LyTPspUn1BjpplTWAOBY7QtFqbrhKWJuXxdL0xeJJecRX5GfFDOy21wFMfPm5gUaEnmtWj5pF5I3lLkzIjx2fQgUEDp2EkZPO0hdzNKodWF0DT/zn3uzw= 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.187 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 szxga01-in.huawei.com (SkyGuard) with ESMTP id 4c6KBW05Dgz14MQG; Wed, 20 Aug 2025 16:20:03 +0800 (CST) Received: from dggpemf200018.china.huawei.com (unknown [7.185.36.31]) by mail.maildlp.com (Postfix) with ESMTPS id C53A318048F; Wed, 20 Aug 2025 16:20:06 +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; Wed, 20 Aug 2025 16:20:06 +0800 From: Quanmin Yan To: CC: , , , , , , Subject: [RFC PATCH mm-next v2 06/12] mm/damon/paddr: support addr_unit for DAMOS_STAT Date: Wed, 20 Aug 2025 16:06:16 +0800 Message-ID: <20250820080623.3799131-7-yanquanmin1@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250820080623.3799131-1-yanquanmin1@huawei.com> References: <20250820080623.3799131-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: kwepems200002.china.huawei.com (7.221.188.68) 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 --- 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