Commit 2a689e4e authored by SeongJae Park's avatar SeongJae Park Committed by Andrew Morton
Browse files

mm/damon/core: put ops-handled filters to damos->ops_filters

damos->ops_filters has introduced to be used for all operations layer
handled filters.  But DAMON kernel API callers can put any type of DAMOS
filters to any of damos->filters and damos->ops_filters.  DAMON user-space
ABI users have no way to use ->ops_filters at all.  Update
damos_add_filter(), which should be used by API callers to install DAMOS
filters, to add filters to ->filters and ->ops_filters depending on their
handling layer.  The change forces both API callers and ABI users to use
proper lists since ABI users use the API internally.

Link: https://lkml.kernel.org/r/20250304211913.53574-5-sj@kernel.org


Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 3607cc59
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -281,8 +281,23 @@ struct damos_filter *damos_new_filter(enum damos_filter_type type,
	return filter;
}

static bool damos_filter_for_ops(enum damos_filter_type type)
{
	switch (type) {
	case DAMOS_FILTER_TYPE_ADDR:
	case DAMOS_FILTER_TYPE_TARGET:
		return false;
	default:
		break;
	}
	return true;
}

void damos_add_filter(struct damos *s, struct damos_filter *f)
{
	if (damos_filter_for_ops(f->type))
		list_add_tail(&f->list, &s->ops_filters);
	else
		list_add_tail(&f->list, &s->filters);
}