Linux 5.18's DAMON Adds DAMOS Configuration Interface

Written by Michael Larabel in Linux Kernel on 23 March 2022 at 12:00 AM EDT. Add A Comment
LINUX KERNEL
Added to the Linux kernel last year was Amazon's DAMON for data access monitoring that has seen public patches since early 2020. Since its Linux 5.15 introduction, this kernel functionality has continued to see new functionality tacked on and now for Linux 5.18 is DAMOS.

The DAMON feature patches for Linux 5.18 were merged on Tuesday by way of Andrew Morton's patch series. Most notable with the DAMON changes for Linux 5.18 is the introduction of a sysfs interface for it and dubbed as "DAMOS" - DAMON-based Operation Schemes.

DAMON's sysfs interface / DAMOS is aimed to improve the ease of configurability around DAMON and superior design to the existing DebugFS interface. This new sysfs interface to DAMON is designed to be easier to use and more easily extensible. DAMOS relies upon the directory hierarchies of sysfs and has a dedicated file for each value, per sysfs requirements. Here's how the patch series summed up the DAMOS work:
At the moment, DAMON_DBGFS and DAMON_SYSFS provides same features. One important difference between them is their exclusiveness. DAMON_DBGFS works in an exclusive manner, so that no DAMON worker thread (kdamond) in the system can run concurrently and interfere somehow. For the reason, DAMON_DBGFS asks users to construct all monitoring contexts and start them at once. It's not a big problem but makes the operation a little bit complex and unflexible.

For more flexible usage, DAMON_SYSFS moves the responsibility of preventing any possible interference to the admins and work in a non-exclusive manner. That is, users can configure and start contexts one by one. Note that DAMON respects both exclusive groups and non-exclusive groups of contexts, in a manner similar to that of reader-writer locks. That is, if any exclusive monitoring contexts (e.g., contexts that started via DAMON_DBGFS) are running, DAMON_SYSFS does not start new contexts, and vice versa.


DAMON's DebugFS interface is to be eventually deprecated and focused just on the sysfs interface. Here's an example of virtual address monitoring for a process using the new DAMOS interface:
# cd /sys/kernel/mm/damon/admin/
# echo 1 > kdamonds/nr_kdamonds
# echo 1 > kdamonds/0/contexts/nr_contexts
# echo vaddr > kdamonds/0/contexts/0/operations
# echo 1 > kdamonds/0/contexts/0/targets/nr_targets
# echo $(pidof ) > kdamonds/0/contexts/0/targets/0/pid_target
# echo on > kdamonds/0/state

This documentation patch for Linux 5.18 provides more detailed explanation of the DAMON sysfs configuration interface.

All this work is now in Linux 5.18 Git thanks to the latest akpm patches.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week