damon
damon is a safe, typed Rust library for the Linux DAMON admin sysfs ABI.
It provides:
- Typed low-level sysfs access and owned configuration types
- Capability-driven behavior without kernel version checks
- High-level
vaddr,fvaddr, andpaddrworkflows - Multiple process targets and managed multi-kdamond hierarchies
- Scoped and persistent lifecycle APIs
- Transactional staging, verified rollback, and ownership checks
- Runtime updates, statistics, tried-region snapshots, and probe results
- Checked address-unit conversion
The crate is sysfs-only. It does not provide the legacy debugfs backend or continuous tracepoint recording.
DAMON
DAMON, the Data Access MONitor, is a Linux kernel subsystem for efficient data access monitoring and access-aware operations. It samples how memory regions are accessed. DAMOS can act on regions selected by access frequency, age, and size, with quotas, watermarks, and filters controlling application. This crate controls DAMON through its privileged admin sysfs interface.
See the DAMON project website, the Linux documentation, the mainline kernel source, and the DAMON mailing-list archive.
Requirements
Building requires Rust 1.85 or newer. The running Linux kernel needs
CONFIG_DAMON and CONFIG_DAMON_SYSFS. Virtual-address workflows also need
CONFIG_DAMON_VADDR, while physical-address workflows need
CONFIG_DAMON_PADDR. Access to the admin interface usually requires elevated
privileges.
This read-only check reports the relevant kernel options, sysfs availability, and access permissions:
damon_kernel_config="/boot/config-"
damon_config_pattern='^(CONFIG_DAMON(_(SYSFS|VADDR|PADDR))?=|# CONFIG_DAMON(_(SYSFS|VADDR|PADDR))? is not set)'
if ; then
elif ; then
else
fi
damon_admin=/sys/kernel/mm/damon/admin
if ; then
&& ||
&& ||
else
fi
Example
use Duration;
use ;
API
Damon::vaddr(), Damon::fvaddr(), and Damon::paddr() build common
monitoring workflows. Damon::exclusive_session() manages one kdamond, while
Damon::managed_hierarchy() manages a complete multi-kdamond configuration.
Damon::start_persistent() returns a receipt for later verified attach,
update, and stop operations.
Scoped sessions hold a cooperative advisory lock and restore the preceding stopped hierarchy when closed. Persistent operations reacquire the lock and verify the receipt for each operation. The kernel has no ownership primitive, so privileged controllers that ignore the lock cannot be excluded.
Snapshot materialization is a synchronous kernel operation and may wait for a
scheme apply interval. Cached reads avoid the materialization command.
SnapshotRequest supports deadline-based waiting without claiming to cancel a
blocked kernel write.
Compatibility
The public damon::sysfs module exposes typed handles for direct ABI access.
Runtime support is discovered from available paths and accepted values.
Unknown future ABI values are preserved where possible. See
the ABI notes for the behavior that affects ownership,
snapshots, and address units.