Skip to content

Commit 39a326e

Browse files
sjp38akpm00
authored andcommitted
mm/damon: respect core layer filters' allowance decision on ops layer
Filtering decisions are made in filters evaluation order. Once a decision is made by a filter, filters that scheduled to be evaluated after the decision-made filter should just respect it. This is the intended and documented behavior. Since core layer-handled filters are evaluated before operations layer-handled filters, decisions made on core layer should respected by ops layer. In case of reject filters, the decision is respected, since core layer-rejected regions are not passed to ops layer. But in case of allow filters, ops layer filters don't know if the region has passed to them because it was allowed by core filters or just because it didn't match to any core layer. The current wrong implementation assumes it was due to not matched by any core filters. As a reuslt, the decision is not respected. Pass the missing information to ops layer using a new filed in 'struct damos', and make the ops layer filters respect it. Link: https://lkml.kernel.org/r/20250228175336.42781-1-sj@kernel.org Fixes: 491fee2 ("mm/damon/core: support damos_filter->allow") Signed-off-by: SeongJae Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 665575c commit 39a326e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

include/linux/damon.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,11 @@ struct damos {
470470
unsigned long next_apply_sis;
471471
/* informs if ongoing DAMOS walk for this scheme is finished */
472472
bool walk_completed;
473+
/*
474+
* If the current region in the filtering stage is allowed by core
475+
* layer-handled filters. If true, operations layer allows it, too.
476+
*/
477+
bool core_filters_allowed;
473478
/* public: */
474479
struct damos_quota quota;
475480
struct damos_watermarks wmarks;

mm/damon/core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,9 +1429,13 @@ static bool damos_filter_out(struct damon_ctx *ctx, struct damon_target *t,
14291429
{
14301430
struct damos_filter *filter;
14311431

1432+
s->core_filters_allowed = false;
14321433
damos_for_each_filter(filter, s) {
1433-
if (damos_filter_match(ctx, t, r, filter))
1434+
if (damos_filter_match(ctx, t, r, filter)) {
1435+
if (filter->allow)
1436+
s->core_filters_allowed = true;
14341437
return !filter->allow;
1438+
}
14351439
}
14361440
return false;
14371441
}

mm/damon/paddr.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ static bool damos_pa_filter_out(struct damos *scheme, struct folio *folio)
236236
{
237237
struct damos_filter *filter;
238238

239+
if (scheme->core_filters_allowed)
240+
return false;
241+
239242
damos_for_each_filter(filter, scheme) {
240243
if (damos_pa_filter_match(filter, folio))
241244
return !filter->allow;

0 commit comments

Comments
 (0)