STRUCT DAMON_OPERATIONS(9)
π struct damon_operations(9) β like, the whole kernel API manual vibe, but make it make sense
okay bestie, welcome to the Kernel API Manual page for struct damon_operations(9) β this is the plug-in system for DAMON, and honestly? it ate. let's get into it π
β¨ NAME β¨
struct damon_operations β monitoring operations for given use cases. that's it, that's the vibe check π¦
πΈ SYNOPSIS πΈ
struct damon_operations {
enum damon_ops_id id;
void (*init)(struct damon_ctx *context);
void (*update)(struct damon_ctx *context);
void (*prepare_access_checks)(struct damon_ctx *context);
unsigned int (*check_accesses)(struct damon_ctx *context);
unsigned int (*apply_probes)(struct damon_ctx *context, bool
set_samples, bool return_max_wsum);
int (*get_scheme_score)(struct damon_ctx *context, struct
damon_region *r, struct damos *scheme);
unsigned long (*apply_scheme)(struct damon_ctx *context, struct
damon_target *t, struct damon_region *r, struct damos *scheme, unsigned
long *sz_filter_passed);
bool (*target_valid)(struct damon_target *t);
void (*cleanup_target)(struct damon_target *t);
};
π Members π
idβ the identifier of this operations set. it's giving social security number, but for ops sets π«Άinitβ initialize the operations-related data structures.updateβ update the operations-related data structures.prepare_access_checksβ prepare the next access check of target regions.check_accessesβ check the accesses to target regions.apply_probesβ apply probes for each region.get_scheme_scoreβ get the score of a region for a scheme.apply_schemeβ apply a DAMON-based operation scheme.target_validβ determine if the target is valid.cleanup_targetβ clean up each target before deallocation.
π Description π
so like, DAMON can be extended for various address spaces and usages β it's flexible like that, main character energy fr. for this, users should register the low level operations for their target address space and usecase via the damon_ctx.ops. then the monitoring thread (damon_ctx.kdamond) does a little choreography, and the timing is everything β:
- it calls
initandprepare_access_checksbefore starting the monitoring updateafter eachdamon_attrs.ops_update_interval- and
check_accesses,target_validandprepare_access_checksafter eachdamon_attrs.sample_interval
Each struct damon_operations instance having valid id can be registered via damon_register_ops and selected by damon_select_ops later. iconic registration pipeline, no notes π₯
Now the member-by-member tea β:
initshould initialize operations-related data structures. for example, this could be used to construct proper monitoring target regions and link those todamon_ctx.adaptive_targets. slay.updateshould update the operations-related data structures. for example, this could be used to update monitoring target regions for current status. glow-up, but for regions β¨prepare_access_checksshould manipulate the monitoring regions to be prepared for the next access check.check_accessesshould check the accesses to each region that made after the last preparation and update the number of observed accesses of each region. it should also return max number of observed accesses that made as a result of its update. the value will be used for regions adjustment threshold. lowkey important, don't skip it πapply_probesshould apply the data attribute probes to each region and accordingly update the probe hits counter of the region. it should also setdamon_region->sampling_addrof each region ifset_samplesis true. it should also return maximum probe hits weighted sum of regions ifreturn_max_wsumis true. yes, two bool params, she's multitalented πget_scheme_scoreshould return the priority score of a region for a scheme as an integer in[0, DAMOS_MAX_SCORE]. bestie, that range is the whole assignment, do not exceed it πapply_schemeis called fromkdamondwhen a region for user provided DAMON-based operation scheme is found. it should apply the scheme's action to the region and return bytes of the region that the action is successfully applied. it should also report how many bytes of the region has passed filters (struct damos_filter) that handled by itself. receipts! we love receipts π§Ύtarget_validshould check whether the target is still valid for the monitoring. vibe check on the target, essentially πcleanup_targetis called before the target will be deallocated. say bye properly, king π«‘
π¦ SEE ALSO π¦
Kernel file ./include/linux/damon.h:
struct damon_addr_range(9)struct damon_size_range(9)struct damon_region(9)struct damon_target(9)enum damos_action(9)enum damos_quota_goal_metric(9)struct damos_quota_goal(9)enum damos_quota_goal_tuner(9)struct damos_quota(9)enum damos_wmark_metric(9)struct damos_watermarks(9)struct damos_stat(9)enum damos_filter_type(9)struct damos_filter(9)struct damos_walk_control(9)struct damos_access_pattern(9)struct damos_migrate_dests(9)struct damos(9)enum damon_ops_id(9)struct damon_intervals_goal(9)enum damon_filter_type(9)struct damon_filter(9)struct damon_probe(9)struct damon_attrs(9)struct damon_ctx(9)
go read all of them. yes, all of them. i'll know if you skipped ππ
okay that's the page!! sourced straight from ./include/linux, dated October 2026, and that's a wrap bestie β go forth and register your ops πππ«Ά
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms