Access information that is reported via damon_report_access() can inform DAMON not only whether there was an access, but also additional things such as the access-generated CPU. By filtering in/out specific types of the reported access based on such additional information, DAMON can support more fine-tuned monitoring, such as per-CPUs access monitoring. Implement a core API data structure for controlling such filtering. Signed-off-by: SeongJae Park --- include/linux/damon.h | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index e23a10ba7c92..78be584ce5dd 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -781,18 +781,53 @@ struct damon_primitives_enabled { bool page_fault; }; +/** + * enum damon_sample_filter_type - Type of &struct damon_sample_filter. + * + * @DAMON_FILTER_TYPE_CPUMASK: Filter by access-generated CPUs. + * + * Read &struct damon_sample_control for more details. + */ +enum damon_sample_filter_type { + DAMON_FILTER_TYPE_CPUMASK, +}; + +/** + * struct damon_sample_filter - &struct damon_access_report filter. + * + * @type: The type of this filter. + * @matching: Whether it is for condition-matching reports. + * @allow: Whether to include or excludie the @matching reports. + * @cpumask: Access-generated CPUs if @type is DAMON_FILTER_TYPE_CPUMASK. + * @list: List head for siblings. + * + * Read &struct damon_sample_control for more details. + */ +struct damon_sample_filter { + enum damon_sample_filter_type type; + bool matching; + bool allow; + cpumask_t cpumask; + struct list_head list; +}; + /** * struct damon_sample_control - Low level access check sampling rules. * * @primitives_enabled: Enablement of access check primitives. + * @sample_filters: List of access check sample filters. * * DAMON collect low level access information using sampling, and aggregate * that to make higher access pattern picture. It can use multiple sampling - * primitives including page table accessed bits and page fault events. This - * struct is for controlling what sampling primitives to use (enable). + * 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. 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; + struct list_head sample_filters; }; /** -- 2.47.3