linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/damon: increment pa_stat damon address range by folio size
@ 2025-01-13 18:03 Usama Arif
  2025-01-13 18:43 ` SeongJae Park
  0 siblings, 1 reply; 4+ messages in thread
From: Usama Arif @ 2025-01-13 18:03 UTC (permalink / raw)
  To: sj, akpm; +Cc: damon, linux-mm, Usama Arif

This is to take into account for folios with size > 1 page.
Iterating at PAGE_SIZE increment would increment sz_filter_passed
multiple times for the same folio by folio_size, providing incorrect
stats. Hence go through the folio only once.

Fixes: 6347f3385dd0 ("mm/damon/paddr: report filter-passed bytes back for DAMOS_STAT action")
Signed-off-by: Usama Arif <usamaarif642@gmail.com>
---
 mm/damon/paddr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index 6b4397de4199..cc789a97c6f5 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -504,7 +504,8 @@ static unsigned long damon_pa_stat(struct damon_region *r, struct damos *s,
 	if (!damon_pa_scheme_has_filter(s))
 		return 0;
 
-	for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) {
+	addr = r->ar.start;
+	while (addr < r->ar.end) {
 		struct folio *folio = damon_get_folio(PHYS_PFN(addr));
 
 		if (!folio)
@@ -515,6 +516,7 @@ static unsigned long damon_pa_stat(struct damon_region *r, struct damos *s,
 		else
 			*sz_filter_passed += folio_size(folio);
 put_folio:
+		addr += folio_size(folio);
 		folio_put(folio);
 	}
 	return 0;
-- 
2.43.5



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-13 19:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-13 18:03 [PATCH] mm/damon: increment pa_stat damon address range by folio size Usama Arif
2025-01-13 18:43 ` SeongJae Park
2025-01-13 18:53   ` Usama Arif
2025-01-13 19:04     ` SeongJae Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox