v1 2026-07-10

非访问属性监控 · v1

引入数据属性权重机制,使 DAMON 能优先监控用户关注的非访问属性而非仅访问信息。

原始补丁链接

子 Patch(19)

1/19
mm/damon/core: introduce damon_probe->weight
在 damon_probe 结构体中新增 weight 字段,用于表示调用者对 probe 数据属性的关注程度,为后续基于权重的监测优化提供基础。
2/19
mm/damon/core: ask apply_probes() ops callback to set sampling address
更新 apply_probes() ops 回调协议,新增 set_samples 参数,允许 DAMON core 请求回调在遍历 region 时同时设置采样地址,减少不必要的重复遍历。
3/19
mm/damon/paddr: set samples in apply_probes() if requested
使 DAMON_PADDR 的 apply_probes() 实现尊重 set_samples 参数,当该参数为真时在回调中设置 region 的采样地址。
4/19
mm/damon/core: ask apply_probe() to return max probe hits weighted sum
更新 apply_probes() 回调协议,新增 return_max_wsum 参数,要求回调返回 region 中 probe hits 加权和的最大值,用于后续基于权重的 region 合并。
5/19
mm/damon/core: implement damon_probe_hits_wsum()
实现 damon_probe_hits_wsum() 函数,当 damon_probe->weight 被设置时,计算 probe hits 的加权和,供用户和内部逻辑(如 region 合并)使用。
6/19
mm/damon/paddr: respect return_max_wsum
使 DAMON_PADDR 的 apply_probes() 实现尊重 return_max_wsum 参数,当该参数为真时计算并返回 region 中 probe hits 加权和的最大值。
7/19
mm/damon/core: use abs_diff() instead of abs()
将 damon_merge_regions_of() 中的 abs() 替换为 abs_diff(),避免 unsigned int 到 signed int 转换导致的静默溢出,提升代码正确性。
8/19
mm/damon/core: extend merge function to work with probe hits
扩展 damon_merge_regions_of() 使其在 probe weights 设置时基于 probe hits 加权和进行 region 合并,但当前权重检测函数始终返回 false,因此该改动为 no-op。
9/19
mm/damon/core: disallow probe_hits overflow on attrs only monitoring
在 DAMON 参数验证中增加检查,当 aggregation interval 超过 sampling interval 的 256 倍时返回错误,防止 probe_hits(unsigned char)溢出。
10/19
mm/damon/core: validate params for probe hits weighted sum overflow
在 DAMON 参数验证中增加对 damon_probe_hits_wsum() 溢出的防护,当 weight 过高或 aggr/sample 间隔比过大时返回错误,避免加权和溢出。
11/19
mm/damon/core: disable access monitoring when probe weights are set
当用户设置了 probe weights 时,禁用数据访问模式监控(prepare_access_checks),因为此时用户只关心 probe 数据属性而非访问模式。
12/19
mm/damon/core: set samples in apply_probes() if probe weights are set
当 probe weights 被设置时,在调用 apply_probes() 时设置 set_samples 参数,因为此时 prepare_access_checks() 未被调用,需要由 apply_probes() 负责设置采样地址。
13/19
mm/damon/core: s/max_nr_accesses/max_merge_score/ in kdamond_fn()
在 kdamond_fn() 中将变量 max_nr_accesses 重命名为 max_merge_score,为后续基于 probe hits 的合并阈值计算做准备,使命名更通用。
14/19
mm/damon/core: get merge threshold from probe hits when weights are set
修改 DAMON 合并阈值计算逻辑,当设置了 probe weights 时,从 apply_probes() 回调获取最大 probe hits 加权和并据此生成阈值,而非基于访问频率。
15/19
mm/damon/core: implement damon_has_probe_weight()
实现 damon_has_probe_weight() 函数,使其正确检测 probe weights 是否设置,从而启用仅基于数据属性的监控模式,此前该函数始终返回 false。
16/19
mm/damon/sysfs: implement probe/weight file
在 sysfs 的 probe 目录下新增 weight 文件,允许用户设置 probe weight 并启用仅属性监控模式,扩展用户接口。
17/19
Docs/mm/damon/design: document attrs-only monitoring
更新 DAMON 设计文档,新增仅属性监控模式的说明,记录该模式的工作原理和使用方式。
18/19
Docs/admin-guide/mm/damon/usage: document weight sysfs file
在DAMON使用文档中添加probe weight sysfs文件的说明,指导用户配置采样权重。
19/19
Docs/ABI/damon: document probe weight file
更新 DAMON ABI 文档,新增对 probe weight sysfs 文件的说明,记录其路径和用途。