damos_walk(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿ’… 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 after damon_start with the ctx has 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 the damon_start first, bestie ๐Ÿ˜ญ๐Ÿ’€

โญ RETURN โญ

  • 0 on 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:


๐Ÿ’– 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