Add a support of DAMON_FILTER_TYPE_REPORT_MADE type probe filter to the physical address space operation set. Use the DAMON core API function, damon_report_exist() for the core report search functionality. Set the time range as the last sampling interval. Pass damon_ctx to the filter matching function for getting the sampling interval. Signed-off-by: SJ Park --- mm/damon/paddr.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index e89cb14ee17be..4003ae914f1a2 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -140,9 +140,10 @@ static void damon_pa_prep_probes(struct damon_ctx *ctx, bool set_samples) } static bool damon_pa_filter_match(struct damon_filter *filter, - struct folio *folio) + struct folio *folio, phys_addr_t pa, struct damon_ctx *ctx) { bool matched = false; + struct damon_addr_range addr_range; switch (filter->type) { case DAMON_FILTER_TYPE_PGIDLE_UNSET: @@ -157,19 +158,27 @@ static bool damon_pa_filter_match(struct damon_filter *filter, else matched = damon_folio_young(folio) == false; break; + case DAMON_FILTER_TYPE_REPORT_MADE: + addr_range.start = pa; + addr_range.end = pa + 1; + matched = damon_report_exist(filter->report_type, &addr_range, + jiffies - + usecs_to_jiffies(ctx->attrs.sample_interval)); + break; default: return damon_ops_filter_match(filter, folio); } return matched == filter->matching; } -static bool damon_pa_filter_pass(struct folio *folio, struct damon_probe *p) +static bool damon_pa_filter_pass(struct folio *folio, struct damon_probe *p, + phys_addr_t pa, struct damon_ctx *ctx) { struct damon_filter *f; bool pass = true; damon_for_each_filter(f, p) { - if (damon_pa_filter_match(f, folio)) { + if (damon_pa_filter_match(f, folio, pa, ctx)) { pass = f->allow; break; } @@ -199,7 +208,7 @@ static unsigned int damon_pa_apply_probes(struct damon_ctx *ctx, ctx->addr_unit); folio = damon_get_folio(PHYS_PFN(pa)); damon_for_each_probe(p, ctx) { - if (damon_pa_filter_pass(folio, p)) + if (damon_pa_filter_pass(folio, p, pa, ctx)) r->probe_hits[i]++; i++; } -- 2.47.3