Skip to content

Commit bdbe1d7

Browse files
uarif1akpm00
authored andcommitted
mm/damon/paddr: increment pa_stat damon address range by folio size
This is to avoid going through all the pages in a folio. For folio_size > PAGE_SIZE, damon_get_folio will return NULL for tail pages, so the for loop in those instances will be a nop. Have a more efficient loop by just incrementing the address by folio_size. Link: https://lkml.kernel.org/r/20250113190738.1156381-1-usamaarif642@gmail.com Signed-off-by: Usama Arif <usamaarif642@gmail.com> Reviewed-by: SeongJae Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent bf06901 commit bdbe1d7

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

mm/damon/paddr.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,17 +504,21 @@ static unsigned long damon_pa_stat(struct damon_region *r, struct damos *s,
504504
if (!damon_pa_scheme_has_filter(s))
505505
return 0;
506506

507-
for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) {
507+
addr = r->ar.start;
508+
while (addr < r->ar.end) {
508509
struct folio *folio = damon_get_folio(PHYS_PFN(addr));
509510

510-
if (!folio)
511+
if (!folio) {
512+
addr += PAGE_SIZE;
511513
continue;
514+
}
512515

513516
if (damos_pa_filter_out(s, folio))
514517
goto put_folio;
515518
else
516519
*sz_filter_passed += folio_size(folio);
517520
put_folio:
521+
addr += folio_size(folio);
518522
folio_put(folio);
519523
}
520524
return 0;

0 commit comments

Comments
 (0)