From: SeongJae Park <sj@kernel.org> Date: 2025-12-16 08:01:43
Introduce three changes for improving DAMOS stat's provided information,
deterministic control, and reading usability.
DAMOS provides stats that are important for understanding its behavior.
It lacks information about how many DAMON-generated monitoring output
snapshots it has worked on. Add a new stat, nr_snapshots, to show the
information.
Users can control DAMOS schemes in multiple ways. Using the online
parameters commit feature, they can install and uninstall DAMOS schemes
whenever they want while keeping DAMON runs. DAMOS quotas and
watermarks can be used for manually or automatically turning on/off or
adjusting the aggressiveness of the scheme. DAMOS filters can be used
for applying the scheme to specific memory entities based on their types
and locations. Some users want their DAMOS scheme to be applied to only
specific number of DAMON snapshots, for more deterministic control. One
example use case is tracepoint based snapshot reading. Add a new knob,
max_nr_snapshots, to support this. If the nr_snapshots parameter
becomes same to or greater than the value of this parameter, the scheme
is deactivated.
Users can read DAMOS stats via DAMON's sysfs interface. For deep level
investigations on environments having advanced tools like perf and
bpftrace, exposing the stats via a tracepoint can be useful. Implement
a new tracepoint, namely damon:damos_stat_after_apply_interval.
First five patches (patches 1-5) of this series implement the new stat,
nr_snapshots, on the core layer (patch 1), expose on DAMON sysfs user
interface (patch 2), and update documents (patches 3-5).
Following six patches (patches 6-11) are for the new stat based DAMOS
deactivation (max_nr_snapshots). The first one (patch 6) of this group
updates a kernel-doc comment before making further changes. Then an
implementation of it on the core layer (patch 7), an introduction of a
new DAMON sysfs interface file for users of the feature (patch 8), and
three updates of the documents (patches 9-11) follow.
The final one (patch 12) introduces the new tracepoint that exposes the
DAMOS stat values for each scheme apply interval.
Revision History
----------------
Changes from RFC
(https://lore.kernel.org/20251123184329.85287-1-sj@kernel.org)
- Check damos_stat tracepoint enablement inside the trace function.
- Update ABI document's 'Date:' fields.
- Slightly change series subject.
SeongJae Park (12):
mm/damon/core: introduce nr_snapshots damos stat
mm/damon/sysfs-schemes: introduce nr_snapshots damos stat file
Docs/mm/damon/design: update for nr_snapshots damos stat
Docs/admin-guide/mm/damon/usage: update for nr_snapshots damos stat
Docs/ABI/damon: update for nr_snapshots damos stat
mm/damon: update damos kerneldoc for stat field
mm/damon/core: implement max_nr_snapshots
mm/damon/sysfs-schemes: implement max_nr_snapshots file
Docs/mm/damon/design: update for max_nr_snapshots
Docs/admin-guide/mm/damon/usage: update for max_nr_snapshots
Docs/ABI/damon: update for max_nr_snapshots
mm/damon/core: add trace point for damos stat per apply interval
.../ABI/testing/sysfs-kernel-mm-damon | 13 ++++++
Documentation/admin-guide/mm/damon/usage.rst | 11 ++---
Documentation/mm/damon/design.rst | 7 +++
include/linux/damon.h | 12 ++++--
include/trace/events/damon.h | 41 ++++++++++++++++++
mm/damon/core.c | 39 +++++++++++++++--
mm/damon/sysfs-schemes.c | 43 +++++++++++++++++++
7 files changed, 155 insertions(+), 11 deletions(-)
base-commit: 37164b8fc049b9a72b3f0fa9bf3241e8852931a9
--
2.47.3
From: SeongJae Park <sj@kernel.org> Date: 2025-12-16 08:02:05
DAMON users can read DAMOS stats via DAMON sysfs interface. It enables
efficient, simple and flexible usages of the stats. Especially for
systems not having advanced tools like perf or bpftrace, that can be
useful. But if the advanced tools are available, exposing the stats via
tracepoint can reduce unnecessary reimplementation of the wheels. Add a
new tracepoint for DAMOS stats, namely damos_stat_after_apply_interval.
The tracepoint is triggered for each scheme's apply interval and exposes
the whole stat values. If the user needs sub-apply interval information
for any chance, damos_before_apply tracepoint could be used.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
include/trace/events/damon.h | 41 ++++++++++++++++++++++++++++++++++++
mm/damon/core.c | 17 +++++++++++++++
2 files changed, 58 insertions(+)
Nit, but it's been stated that strings should not be broken up because of
the column limit.
I also found checkpatch.pl shows warning for that. I was ignoring that since I
was thinking that's just a recommendation. But as I got more than one warning,
now I'd like to fix this.
Andrew, could you please add below attaching fixup patch?
Other than that, from a tracing POV:
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Thank you! :)
Thanks,
SJ
[...]
=== >8 ===
From 67a7762ee1ade258c53913ea4ecf9bafd4746ea9 Mon Sep 17 00:00:00 2001
From: SeongJae Park <sj@kernel.org>
Date: Wed, 17 Dec 2025 15:42:06 -0800
Subject: [PATCH] mm/damon: do not break the string for damos_stat tracepoint
The format string for damos_stat tracepoint is broken up to multiple
lines. Strings shouldn't be broken up due to the column limit, though.
Update the string to be put on a single line.
Suggested-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: SeongJae Park <sj@kernel.org>
---
include/trace/events/damon.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
because that's just crazy. Let's use some judgment here!
I'm fine with either direction. So I understand you want to just keep the
original patch without this fixup, and therefore no action is needed from my
side? Let me know if I'm getting anything wrong.
Thanks,
SJ
[...]
because that's just crazy. Let's use some judgment here!
Does it really matter? Actually, I prefer this way because it better shows
where the format ends and the parameters start. I care more about the
parameters than the format string, except to look for each "%*" value.
-- Steve