damos_walk(9)
๐ damos_walk โ the walk-and-callback page (section 9 of the Kernel API Manual, bestie)
okay so you found damos_walk(9) and you're like "what does this even do" โ don't worry, we're getting through this together โจ It's a kernel function, it lives in the Kernel API Manual, section 9, and honestly? It's giving "polite request to the DAMON worker thread" energy. Let's go.
โจ NAME โจ
damos_walk โ literally just: invoke a given functions while DAMOS walk regions ๐ซ (yes, that's the official phrasing, and yes, we're keeping it, "functions" plural and all, slay)
๐ SYNOPSIS ๐
int damos_walk (struct damon_ctx *ctx , struct damos_walk_control
*control );
That's it. Two args, one int coming back at you. Clean. Iconic. No notes. ๐
๐ฆ ARGUMENTS ๐ฆ
ctxโ the DAMON context you want the functions called for. Like, which context, bestie, be specific ๐controlโ the control variable of the walk request. This is the little permission slip that says what we're doing ๐ซ
๐ธ DESCRIPTION ๐ธ
So here's the vibe: you ask DAMON's worker thread (that's kdamond, iykyk) of ctx to call a function for each region that the kdamond is gonna apply a DAMOS action to โ and then you wait until the kdamond finishes handling your request. No running off and doing your own thing. We wait. ๐ซถ
The kdamond runs your given function in the main loop, for each region just after it applied any DAMOS actions of ctx to that region. Timing is everything, and the timing is chef's kiss.
Now the important bit, the part where you go "ohhh okay": the invocation is made only within one damos->apply_interval_us since damos_walk invocation, for each scheme. That's the window. That's the whole window. โณ
Which means โ and this is the good part โ your callback function can safely access the internal data of struct damon_ctx and struct damon_region that each of the schemes will apply the action for next interval, without additional synchronizations against the kdamond. No locks. No extra ceremony. Just vibes and correct access ๐ฅ
And if every scheme of ctx passed at least one damos->apply_interval_us, the kdamond marks the request as completed, so that damos_walk can wakeup and return. That's your cue to exit the group chat ๐ชโจ
โ ๏ธ okay listen, this one matters: this function should be called only afterdamon_startwith thectxhas succeeded. Otherwise, this function could fall into an indefinite wait. Not a cute indefinite wait. Not a "brb" indefinite wait. Like, stuck-forever indefinite. Do thedamon_startfirst, bestie ๐ญ๐
โญ RETURN โญ
0on success ๐- negative error code otherwise ๐
Two outcomes. Very simple. Very demure.
๐ฎ SEE ALSO ๐ฎ
Everything adjacent to this, in a big beautiful list. Kernel file ./mm/damon/core.c, plus:
damon_is_registered_ops(9)damon_register_ops(9)damon_select_ops(9)damon_nr_accesses_mvsum(9)damon_probe_hits_wsum(9)damos_filter_for_ops(9)damon_set_attrs(9)damon_set_schemes(9)damos_commit_quota_goals(9)damos_filters_default_reject(9)damon_commit_ctx(9)damon_nr_running_ctxs(9)damon_start(9)damon_stop(9)damon_is_running(9)damon_kdamond_pid(9)damon_call(9)damon_set_region_system_rams_default(9)damon_update_region_access_rate(9)damon_initialized(9)
๐ that's the whole page, you ate it, no crumbs ๐
Sign-off time, because we always credit our sources: this one's from ./mm/damon, dated October 2026 โ go drink some water and go read damon_start(9) before you call this, fr fr ๐๐งโโ๏ธ
๐ฆ 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