Now page fault events based access reports contain information about if the access was for a read or a write. Doing sampling results filtering based on the information can be useful. Introduce a new type of damon sample filter for that. Signed-off-by: SeongJae Park --- include/linux/damon.h | 9 ++++++--- mm/damon/core.c | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 9299fc91ba27..f9fd26f7eab8 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -790,12 +790,14 @@ struct damon_primitives_enabled { * * @DAMON_FILTER_TYPE_CPUMASK: Filter by access-generated CPUs. * @DAMON_FILTER_TYPE_THREADS: Filter by access-generated threads. + * @DAMON_FILTER_TYPE_WRITE: Filter by whether the access was for writing. * * Read &struct damon_sample_control for more details. */ enum damon_sample_filter_type { DAMON_FILTER_TYPE_CPUMASK, DAMON_FILTER_TYPE_THREADS, + DAMON_FILTER_TYPE_WRITE, }; /** @@ -836,9 +838,10 @@ struct damon_sample_filter { * that to make higher access pattern picture. It can use multiple sampling * primitives including page table accessed bits and page fault events. It can * also filter in/out specific types of sampled access events to monitor - * accesses of specific types, such as access-generated CPUs and threads. This - * struct is for controlling what sampling primitives to use (enable), and what - * sampled access events should be filtered in/out. + * accesses of specific types, such as access-generated CPUs, threads, and + * whether it was for read or writes. This struct is for controlling what + * sampling primitives to use (enable), and what sampled access events should + * be filtered in/out. */ struct damon_sample_control { struct damon_primitives_enabled primitives_enabled; diff --git a/mm/damon/core.c b/mm/damon/core.c index e2fd17b83a92..5f29e4dee267 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1336,6 +1336,8 @@ static int damon_commit_sample_filter_arg(struct damon_sample_filter *dst, src->nr_tids); dst->nr_tids = src->nr_tids; break; + case DAMON_FILTER_TYPE_WRITE: + break; default: break; } @@ -2912,6 +2914,9 @@ static bool damon_sample_filter_matching(struct damon_access_report *report, break; } break; + case DAMON_FILTER_TYPE_WRITE: + matched = report->is_write; + break; default: break; } -- 2.47.3