xref: /linux/Documentation/admin-guide/mm/damon/usage.rst (revision ab93e0dd72c37d378dd936f031ffb83ff2bd87ce)
1c4ba6014SSeongJae Park.. SPDX-License-Identifier: GPL-2.0
2c4ba6014SSeongJae Park
3c4ba6014SSeongJae Park===============
4c4ba6014SSeongJae ParkDetailed Usages
5c4ba6014SSeongJae Park===============
6c4ba6014SSeongJae Park
7b1840272SSeongJae ParkDAMON provides below interfaces for different users.
8c4ba6014SSeongJae Park
9c4ba6014SSeongJae Park- *DAMON user space tool.*
1023a425aaSSeongJae Park  `This <https://github.com/damonitor/damo>`_ is for privileged people such as
1135b43d40SSeongJae Park  system administrators who want a just-working human-friendly interface.
1235b43d40SSeongJae Park  Using this, users can use the DAMON’s major features in a human-friendly way.
13ddb7d012SSeongJae Park  It may not be highly tuned for special cases, though.  For more detail,
14ddb7d012SSeongJae Park  please refer to its `usage document
1523a425aaSSeongJae Park  <https://github.com/damonitor/damo/blob/next/USAGE.md>`_.
16b1840272SSeongJae Park- *sysfs interface.*
17b1840272SSeongJae Park  :ref:`This <sysfs_interface>` is for privileged user space programmers who
1835b43d40SSeongJae Park  want more optimized use of DAMON.  Using this, users can use DAMON’s major
19b1840272SSeongJae Park  features by reading from and writing to special sysfs files.  Therefore,
20b1840272SSeongJae Park  you can write and use your personalized DAMON sysfs wrapper programs that
21b1840272SSeongJae Park  reads/writes the sysfs files instead of you.  The `DAMON user space tool
2223a425aaSSeongJae Park  <https://github.com/damonitor/damo>`_ is one example of such programs.
23c4ba6014SSeongJae Park- *Kernel Space Programming Interface.*
24ee65728eSMike Rapoport  :doc:`This </mm/damon/api>` is for kernel space programmers.  Using this,
2535b43d40SSeongJae Park  users can utilize every feature of DAMON most flexibly and efficiently by
2635b43d40SSeongJae Park  writing kernel space DAMON application programs for you.  You can even extend
2735b43d40SSeongJae Park  DAMON for various address spaces.  For detail, please refer to the interface
28ee65728eSMike Rapoport  :doc:`document </mm/damon/api>`.
29c4ba6014SSeongJae Park
30b1840272SSeongJae Park.. _sysfs_interface:
31b1840272SSeongJae Park
32b1840272SSeongJae Parksysfs Interface
33b1840272SSeongJae Park===============
34b1840272SSeongJae Park
35b1840272SSeongJae ParkDAMON sysfs interface is built when ``CONFIG_DAMON_SYSFS`` is defined.  It
36b1840272SSeongJae Parkcreates multiple directories and files under its sysfs directory,
37b1840272SSeongJae Park``<sysfs>/kernel/mm/damon/``.  You can control DAMON by writing to and reading
38b1840272SSeongJae Parkfrom the files under the directory.
39b1840272SSeongJae Park
40b1840272SSeongJae ParkFor a short example, users can monitor the virtual address space of a given
41b1840272SSeongJae Parkworkload as below. ::
42b1840272SSeongJae Park
43b1840272SSeongJae Park    # cd /sys/kernel/mm/damon/admin/
44465d0eb0SKairui Song    # echo 1 > kdamonds/nr_kdamonds && echo 1 > kdamonds/0/contexts/nr_contexts
45b1840272SSeongJae Park    # echo vaddr > kdamonds/0/contexts/0/operations
46465d0eb0SKairui Song    # echo 1 > kdamonds/0/contexts/0/targets/nr_targets
47465d0eb0SKairui Song    # echo $(pidof <workload>) > kdamonds/0/contexts/0/targets/0/pid_target
48b1840272SSeongJae Park    # echo on > kdamonds/0/state
49b1840272SSeongJae Park
50b1840272SSeongJae ParkFiles Hierarchy
51b1840272SSeongJae Park---------------
52b1840272SSeongJae Park
53b1840272SSeongJae ParkThe files hierarchy of DAMON sysfs interface is shown below.  In the below
54b1840272SSeongJae Parkfigure, parents-children relations are represented with indentations, each
55b1840272SSeongJae Parkdirectory is having ``/`` suffix, and files in each directory are separated by
569c8c315dSSeongJae Parkcomma (",").
57b1840272SSeongJae Park
589c8c315dSSeongJae Park.. parsed-literal::
599c8c315dSSeongJae Park
609c8c315dSSeongJae Park    :ref:`/sys/kernel/mm/damon <sysfs_root>`/admin
619c8c315dSSeongJae Park    │ :ref:`kdamonds <sysfs_kdamonds>`/nr_kdamonds
629c8c315dSSeongJae Park    │ │ :ref:`0 <sysfs_kdamond>`/state,pid,refresh_ms
639c8c315dSSeongJae Park    │ │ │ :ref:`contexts <sysfs_contexts>`/nr_contexts
649c8c315dSSeongJae Park    │ │ │ │ :ref:`0 <sysfs_context>`/avail_operations,operations
659c8c315dSSeongJae Park    │ │ │ │ │ :ref:`monitoring_attrs <sysfs_monitoring_attrs>`/
66b1840272SSeongJae Park    │ │ │ │ │ │ intervals/sample_us,aggr_us,update_us
67b243d666SSeongJae Park    │ │ │ │ │ │ │ intervals_goal/access_bp,aggrs,min_sample_us,max_sample_us
68b1840272SSeongJae Park    │ │ │ │ │ │ nr_regions/min,max
699c8c315dSSeongJae Park    │ │ │ │ │ :ref:`targets <sysfs_targets>`/nr_targets
709c8c315dSSeongJae Park    │ │ │ │ │ │ :ref:`0 <sysfs_target>`/pid_target
719c8c315dSSeongJae Park    │ │ │ │ │ │ │ :ref:`regions <sysfs_regions>`/nr_regions
729c8c315dSSeongJae Park    │ │ │ │ │ │ │ │ :ref:`0 <sysfs_region>`/start,end
73b1840272SSeongJae Park    │ │ │ │ │ │ │ │ ...
74b1840272SSeongJae Park    │ │ │ │ │ │ ...
759c8c315dSSeongJae Park    │ │ │ │ │ :ref:`schemes <sysfs_schemes>`/nr_schemes
7683d0d46aSHonggyu Kim    │ │ │ │ │ │ :ref:`0 <sysfs_scheme>`/action,target_nid,apply_interval_us
779c8c315dSSeongJae Park    │ │ │ │ │ │ │ :ref:`access_pattern <sysfs_access_pattern>`/
78b1840272SSeongJae Park    │ │ │ │ │ │ │ │ sz/min,max
79b1840272SSeongJae Park    │ │ │ │ │ │ │ │ nr_accesses/min,max
80b1840272SSeongJae Park    │ │ │ │ │ │ │ │ age/min,max
81a6068d6dSSeongJae Park    │ │ │ │ │ │ │ :ref:`quotas <sysfs_quotas>`/ms,bytes,reset_interval_ms,effective_bytes
82b1840272SSeongJae Park    │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil
839c8c315dSSeongJae Park    │ │ │ │ │ │ │ │ :ref:`goals <sysfs_schemes_quota_goals>`/nr_goals
84*a7bb1e75SSeongJae Park    │ │ │ │ │ │ │ │ │ 0/target_metric,target_value,current_value,nid
859c8c315dSSeongJae Park    │ │ │ │ │ │ │ :ref:`watermarks <sysfs_watermarks>`/metric,interval_us,high,mid,low
86114b4808SSeongJae Park    │ │ │ │ │ │ │ :ref:`{core_,ops_,}filters <sysfs_filters>`/nr_filters
874ddb2092SUsama Arif    │ │ │ │ │ │ │ │ 0/type,matching,allow,memcg_path,addr_start,addr_end,target_idx,min,max
886bbdb28dSSeongJae Park    │ │ │ │ │ │ │ :ref:`dests <damon_sysfs_dests>`/nr_dests
899c8c315dSSeongJae Park    │ │ │ │ │ │ │ │ 0/id,weight
90f423944bSSeongJae Park    │ │ │ │ │ │ │ :ref:`stats <sysfs_schemes_stats>`/nr_tried,sz_tried,nr_applied,sz_applied,sz_ops_filter_passed,qt_exceeds
917f0a86f3SSeongJae Park    │ │ │ │ │ │ │ :ref:`tried_regions <sysfs_schemes_tried_regions>`/total_bytes
92b1840272SSeongJae Park    │ │ │ │ │ │ │ │ 0/start,end,nr_accesses,age,sz_filter_passed
93b1840272SSeongJae Park    │ │ │ │ │ │ │ │ ...
94b1840272SSeongJae Park    │ │ │ │ │ │ ...
95b1840272SSeongJae Park    │ │ │ │ ...
969c8c315dSSeongJae Park    │ │ ...
979c8c315dSSeongJae Park
98b1840272SSeongJae Park.. _sysfs_root:
99b1840272SSeongJae Park
100b1840272SSeongJae ParkRoot
101b1840272SSeongJae Park----
102b1840272SSeongJae Park
103d56b699dSBjorn HelgaasThe root of the DAMON sysfs interface is ``<sysfs>/kernel/mm/damon/``, and it
104b1840272SSeongJae Parkhas one directory named ``admin``.  The directory contains the files for
105b1840272SSeongJae Parkprivileged user space programs' control of DAMON.  User space tools or daemons
1069c8c315dSSeongJae Parkhaving the root permission could use this directory.
1079c8c315dSSeongJae Park
108b1840272SSeongJae Park.. _sysfs_kdamonds:
109b1840272SSeongJae Park
110b1840272SSeongJae Parkkdamonds/
111b1840272SSeongJae Park---------
11246158bf2SSeongJae Park
11346158bf2SSeongJae ParkUnder the ``admin`` directory, one directory, ``kdamonds``, which has files for
11446158bf2SSeongJae Parkcontrolling the kdamonds (refer to
11546158bf2SSeongJae Park:ref:`design <damon_design_execution_model_and_data_structures>` for more
11646158bf2SSeongJae Parkdetails) exists.  In the beginning, this directory has only one file,
117b1840272SSeongJae Park``nr_kdamonds``.  Writing a number (``N``) to the file creates the number of
118b1840272SSeongJae Parkchild directories named ``0`` to ``N-1``.  Each directory represents each
1196140edeeSSeongJae Parkkdamond.
1206140edeeSSeongJae Park
121b1840272SSeongJae Park.. _sysfs_kdamond:
122b1840272SSeongJae Park
123b1840272SSeongJae Parkkdamonds/<N>/
124b1840272SSeongJae Park-------------
125b1840272SSeongJae Park
126b1840272SSeongJae ParkIn each kdamond directory, three files (``state``, ``pid`` and ``refresh_ms``)
127b1840272SSeongJae Parkand one directory (``contexts``) exist.
128e93b81a3SSeongJae Park
1296140edeeSSeongJae ParkReading ``state`` returns ``on`` if the kdamond is currently running, or
130e93b81a3SSeongJae Park``off`` if it is not running.
1316140edeeSSeongJae Park
132e93b81a3SSeongJae ParkUsers can write below commands for the kdamond to the ``state`` file.
133e93b81a3SSeongJae Park
134e93b81a3SSeongJae Park- ``on``: Start running.
135e93b81a3SSeongJae Park- ``off``: Stop running.
136b243d666SSeongJae Park- ``commit``: Read the user inputs in the sysfs files except ``state`` file
137b243d666SSeongJae Park  again.
138b243d666SSeongJae Park- ``update_tuned_intervals``: Update the contents of ``sample_us`` and
139b243d666SSeongJae Park  ``aggr_us`` files of the kdamond with the auto-tuning applied ``sampling
140b243d666SSeongJae Park  interval`` and ``aggregation interval`` for the files.  Please refer to
141e93b81a3SSeongJae Park  :ref:`intervals_goal section <damon_usage_sysfs_monitoring_intervals_goal>`
142e93b81a3SSeongJae Park  for more details.
143e93b81a3SSeongJae Park- ``commit_schemes_quota_goals``: Read the DAMON-based operation schemes'
144e93b81a3SSeongJae Park  :ref:`quota goals <sysfs_schemes_quota_goals>`.
145e93b81a3SSeongJae Park- ``update_schemes_stats``: Update the contents of stats files for each
146e93b81a3SSeongJae Park  DAMON-based operation scheme of the kdamond.  For details of the stats,
147e93b81a3SSeongJae Park  please refer to :ref:`stats section <sysfs_schemes_stats>`.
148e93b81a3SSeongJae Park- ``update_schemes_tried_regions``: Update the DAMON-based operation scheme
149e93b81a3SSeongJae Park  action tried regions directory for each DAMON-based operation scheme of the
150e93b81a3SSeongJae Park  kdamond.  For details of the DAMON-based operation scheme action tried
151e93b81a3SSeongJae Park  regions directory, please refer to
152e93b81a3SSeongJae Park  :ref:`tried_regions section <sysfs_schemes_tried_regions>`.
153e93b81a3SSeongJae Park- ``update_schemes_tried_bytes``: Update only ``.../tried_regions/total_bytes``
154e93b81a3SSeongJae Park  files.
155e93b81a3SSeongJae Park- ``clear_schemes_tried_regions``: Clear the DAMON-based operating scheme
15614e70e46SSeongJae Park  action tried regions directory for each DAMON-based operation scheme of the
157a6068d6dSSeongJae Park  kdamond.
158a6068d6dSSeongJae Park- ``update_schemes_effective_quotas``: Update the contents of
159b1840272SSeongJae Park  ``effective_bytes`` files for each DAMON-based operation scheme of the
160b1840272SSeongJae Park  kdamond.  For more details, refer to :ref:`quotas directory <sysfs_quotas>`.
161b1840272SSeongJae Park
162b1840272SSeongJae ParkIf the state is ``on``, reading ``pid`` shows the pid of the kdamond thread.
163b1840272SSeongJae Park
164b1840272SSeongJae ParkUsers can ask the kernel to periodically update files showing auto-tuned
1659c8c315dSSeongJae Parkparameters and DAMOS stats instead of manually writing
1669c8c315dSSeongJae Park``update_tuned_intervals`` like keywords to ``state`` file.  For this, users
167b1840272SSeongJae Parkshould write the desired update time interval in milliseconds to ``refresh_ms``
168b1840272SSeongJae Parkfile.  If the interval is zero, the periodic update is disabled.  Reading the
169b1840272SSeongJae Parkfile shows currently set time interval.
170b1840272SSeongJae Park
171b1840272SSeongJae Park``contexts`` directory contains files for controlling the monitoring contexts
17246158bf2SSeongJae Parkthat this kdamond will execute.
17346158bf2SSeongJae Park
17446158bf2SSeongJae Park.. _sysfs_contexts:
17546158bf2SSeongJae Park
176b1840272SSeongJae Parkkdamonds/<N>/contexts/
177c7ae9634SSeongJae Park----------------------
1789b7f9322SSeongJae Park
179b1840272SSeongJae ParkIn the beginning, this directory has only one file, ``nr_contexts``.  Writing a
180b1840272SSeongJae Parknumber (``N``) to the file creates the number of child directories named as
181b1840272SSeongJae Park``0`` to ``N-1``.  Each directory represents each monitoring context (refer to
1822fe60ec9SSeongJae Park:ref:`design <damon_design_execution_model_and_data_structures>` for more
1832fe60ec9SSeongJae Parkdetails).  At the moment, only one context per kdamond is supported, so only
1842fe60ec9SSeongJae Park``0`` or ``1`` can be written to the file.
185b1840272SSeongJae Park
186669971b4SSeongJae Park.. _sysfs_context:
187669971b4SSeongJae Park
188669971b4SSeongJae Parkcontexts/<N>/
189669971b4SSeongJae Park-------------
1902fe60ec9SSeongJae Park
191669971b4SSeongJae ParkIn each context directory, two files (``avail_operations`` and ``operations``)
192669971b4SSeongJae Parkand three directories (``monitoring_attrs``, ``targets``, and ``schemes``)
193669971b4SSeongJae Parkexist.
19491541808SSeongJae Park
1952fe60ec9SSeongJae ParkDAMON supports multiple types of :ref:`monitoring operations
1962fe60ec9SSeongJae Park<damon_design_configurable_operations_set>`, including those for virtual address
1972fe60ec9SSeongJae Parkspace and the physical address space.  You can get the list of available
1982fe60ec9SSeongJae Parkmonitoring operations set on the currently running kernel by reading
1997f0a86f3SSeongJae Park``avail_operations`` file.  Based on the kernel configuration, the file will
2007f0a86f3SSeongJae Parklist different available operation sets.  Please refer to the :ref:`design
201b1840272SSeongJae Park<damon_operations_set>` for the list of all available operation sets and their
202b1840272SSeongJae Parkbrief explanations.
203b1840272SSeongJae Park
204b1840272SSeongJae ParkYou can set and get what type of monitoring operations DAMON will use for the
205b1840272SSeongJae Parkcontext by writing one of the keywords listed in ``avail_operations`` file and
206b1840272SSeongJae Parkreading from the ``operations`` file.
207b1840272SSeongJae Park
208b1840272SSeongJae Park.. _sysfs_monitoring_attrs:
209b1840272SSeongJae Park
210b1840272SSeongJae Parkcontexts/<N>/monitoring_attrs/
211b1840272SSeongJae Park------------------------------
212b1840272SSeongJae Park
213b1840272SSeongJae ParkFiles for specifying attributes of the monitoring including required quality
214b1840272SSeongJae Parkand efficiency of the monitoring are in ``monitoring_attrs`` directory.
215b1840272SSeongJae ParkSpecifically, two directories, ``intervals`` and ``nr_regions`` exist in this
216b1840272SSeongJae Parkdirectory.
217b1840272SSeongJae Park
218b1840272SSeongJae ParkUnder ``intervals`` directory, three files for DAMON's sampling interval
219b1840272SSeongJae Park(``sample_us``), aggregation interval (``aggr_us``), and update interval
220ee65728eSMike Rapoport(``update_us``) exist.  You can set and get the values in micro-seconds by
221b1840272SSeongJae Parkwriting to and reading from the files.
222b243d666SSeongJae Park
223b243d666SSeongJae ParkUnder ``nr_regions`` directory, two files for the lower-bound and upper-bound
224b243d666SSeongJae Parkof DAMON's monitoring regions (``min`` and ``max``, respectively), which
225b243d666SSeongJae Parkcontrols the monitoring overhead, exist.  You can set and get the values by
226b243d666SSeongJae Parkwriting to and rading from the files.
227b243d666SSeongJae Park
228b243d666SSeongJae ParkFor more details about the intervals and monitoring regions range, please refer
229b243d666SSeongJae Parkto the Design document (:doc:`/mm/damon/design`).
230b243d666SSeongJae Park
231b243d666SSeongJae Park.. _damon_usage_sysfs_monitoring_intervals_goal:
232b243d666SSeongJae Park
233b243d666SSeongJae Parkcontexts/<N>/monitoring_attrs/intervals/intervals_goal/
234b243d666SSeongJae Park-------------------------------------------------------
235b243d666SSeongJae Park
236b243d666SSeongJae ParkUnder the ``intervals`` directory, one directory for automated tuning of
237b243d666SSeongJae Park``sample_us`` and ``aggr_us``, namely ``intervals_goal`` directory also exists.
238b243d666SSeongJae ParkUnder the directory, four files for the auto-tuning control, namely
239b243d666SSeongJae Park``access_bp``, ``aggrs``, ``min_sample_us`` and ``max_sample_us`` exist.
240b243d666SSeongJae ParkPlease refer to  the :ref:`design document of the feature
2419c8c315dSSeongJae Park<damon_design_monitoring_intervals_autotuning>` for the internal of the tuning
2429c8c315dSSeongJae Parkmechanism.  Reading and writing the four files under ``intervals_goal``
243b1840272SSeongJae Parkdirectory shows and updates the tuning parameters that described in the
244b1840272SSeongJae Park:ref:design doc <damon_design_monitoring_intervals_autotuning>` with the same
245b1840272SSeongJae Parknames.  The tuning starts with the user-set ``sample_us`` and ``aggr_us``.  The
246b1840272SSeongJae Parktuning-applied current values of the two intervals can be read from the
247b1840272SSeongJae Park``sample_us`` and ``aggr_us`` files after writing ``update_tuned_intervals`` to
248b1840272SSeongJae Parkthe ``state`` file.
249b1840272SSeongJae Park
2509c8c315dSSeongJae Park.. _sysfs_targets:
2519c8c315dSSeongJae Park
252b1840272SSeongJae Parkcontexts/<N>/targets/
253b1840272SSeongJae Park---------------------
254b1840272SSeongJae Park
255b1840272SSeongJae ParkIn the beginning, this directory has only one file, ``nr_targets``.  Writing a
256b1840272SSeongJae Parknumber (``N``) to the file creates the number of child directories named ``0``
257b1840272SSeongJae Parkto ``N-1``.  Each directory represents each monitoring target.
258b1840272SSeongJae Park
259b1840272SSeongJae Park.. _sysfs_target:
260b1840272SSeongJae Park
261b1840272SSeongJae Parktargets/<N>/
26291541808SSeongJae Park------------
26391541808SSeongJae Park
264b1840272SSeongJae ParkIn each target directory, one file (``pid_target``) and one directory
265b1840272SSeongJae Park(``regions``) exist.
266b1840272SSeongJae Park
2672d89957cSSeongJae ParkIf you wrote ``vaddr`` to the ``contexts/<N>/operations``, each target should
2682d89957cSSeongJae Parkbe a process.  You can specify the process to DAMON by writing the pid of the
2692d89957cSSeongJae Parkprocess to the ``pid_target`` file.
2702d89957cSSeongJae Park
2712d89957cSSeongJae Park.. _sysfs_regions:
272b1840272SSeongJae Park
273b1840272SSeongJae Parktargets/<N>/regions
274b1840272SSeongJae Park-------------------
275b1840272SSeongJae Park
276b1840272SSeongJae ParkIn case of ``fvaddr`` or ``paddr`` monitoring operations sets, users are
277b1840272SSeongJae Parkrequired to set the monitoring target address ranges.  In case of ``vaddr``
278b1840272SSeongJae Parkoperations set, it is not mandatory, but users can optionally set the initial
279b1840272SSeongJae Parkmonitoring region to specific address ranges.  Please refer to the :ref:`design
2809c8c315dSSeongJae Park<damon_design_vaddr_target_regions_construction>` for more details.
2819c8c315dSSeongJae Park
282b1840272SSeongJae ParkFor such cases, users can explicitly set the initial monitoring target regions
283b1840272SSeongJae Parkas they want, by writing proper values to the files under this directory.
284b1840272SSeongJae Park
285b1840272SSeongJae ParkIn the beginning, this directory has only one file, ``nr_regions``.  Writing a
286b1840272SSeongJae Parknumber (``N``) to the file creates the number of child directories named ``0``
287b1840272SSeongJae Parkto ``N-1``.  Each directory represents each initial monitoring target region.
288b1840272SSeongJae Park
289bd414929SSeongJae Park.. _sysfs_region:
290bd414929SSeongJae Park
291bd414929SSeongJae Parkregions/<N>/
2929c8c315dSSeongJae Park------------
2939c8c315dSSeongJae Park
294b1840272SSeongJae ParkIn each region directory, you will find two files (``start`` and ``end``).  You
295b1840272SSeongJae Parkcan set and get the start and end addresses of the initial monitoring target
296b1840272SSeongJae Parkregion by writing to and reading from the files, respectively.
29701e08737SSeongJae Park
29801e08737SSeongJae ParkEach region should not overlap with others.  ``end`` of directory ``N`` should
29901e08737SSeongJae Parkbe equal or smaller than ``start`` of directory ``N+1``.
300b1840272SSeongJae Park
301b1840272SSeongJae Park.. _sysfs_schemes:
302b1840272SSeongJae Park
303b1840272SSeongJae Parkcontexts/<N>/schemes/
304b1840272SSeongJae Park---------------------
3059c8c315dSSeongJae Park
3069c8c315dSSeongJae ParkThe directory for DAMON-based Operation Schemes (:ref:`DAMOS
307b1840272SSeongJae Park<damon_design_damos>`).  Users can get and set the schemes by reading from and
308b1840272SSeongJae Parkwriting to files under this directory.
309b1840272SSeongJae Park
310114b4808SSeongJae ParkIn the beginning, this directory has only one file, ``nr_schemes``.  Writing a
311114b4808SSeongJae Parknumber (``N``) to the file creates the number of child directories named ``0``
312114b4808SSeongJae Parkto ``N-1``.  Each directory represents each DAMON-based operation scheme.
313114b4808SSeongJae Park
314b1840272SSeongJae Park.. _sysfs_scheme:
31501e08737SSeongJae Park
31601e08737SSeongJae Parkschemes/<N>/
3175b7708e6SSeongJae Park------------
3185b7708e6SSeongJae Park
319b1840272SSeongJae ParkIn each scheme directory, eight directories (``access_pattern``, ``quotas``,
32083d0d46aSHonggyu Kim``watermarks``, ``core_filters``, ``ops_filters``, ``filters``, ``dests``,
32183d0d46aSHonggyu Kim``stats``, and ``tried_regions``) and three files (``action``, ``target_nid``
32283d0d46aSHonggyu Kimand ``apply_interval``) exist.
32383d0d46aSHonggyu Kim
324033343d5SSeongJae ParkThe ``action`` file is for setting and getting the scheme's :ref:`action
325033343d5SSeongJae Park<damon_design_damos_action>`.  The keywords that can be written to and read
326033343d5SSeongJae Parkfrom the file and their meaning are same to those of the list on
3279c8c315dSSeongJae Park:ref:`design doc <damon_design_damos_action>`.
3289c8c315dSSeongJae Park
329b1840272SSeongJae ParkThe ``target_nid`` file is for setting the migration target node, which is
330b1840272SSeongJae Parkonly meaningful when the ``action`` is either ``migrate_hot`` or
331b1840272SSeongJae Park``migrate_cold``.
33201e08737SSeongJae Park
33301e08737SSeongJae ParkThe ``apply_interval_us`` file is for setting and getting the scheme's
334b1840272SSeongJae Park:ref:`apply_interval <damon_design_damos>` in microseconds.
335b1840272SSeongJae Park
336b1840272SSeongJae Park.. _sysfs_access_pattern:
337b1840272SSeongJae Park
338b1840272SSeongJae Parkschemes/<N>/access_pattern/
33967c34f6cSSeongJae Park---------------------------
34067c34f6cSSeongJae Park
341b1840272SSeongJae ParkThe directory for the target access :ref:`pattern
3429c8c315dSSeongJae Park<damon_design_damos_access_pattern>` of the given DAMON-based operation scheme.
3439c8c315dSSeongJae Park
344b1840272SSeongJae ParkUnder the ``access_pattern`` directory, three directories (``sz``,
345b1840272SSeongJae Park``nr_accesses``, and ``age``) each having two files (``min`` and ``max``)
346b1840272SSeongJae Parkexist.  You can set and get the access pattern for the given scheme by writing
34701e08737SSeongJae Parkto and reading from the ``min`` and ``max`` files under ``sz``,
34801e08737SSeongJae Park``nr_accesses``, and ``age`` directories, respectively.  Note that the ``min``
349b1840272SSeongJae Parkand the ``max`` form a closed interval.
350a6068d6dSSeongJae Park
351a6068d6dSSeongJae Park.. _sysfs_quotas:
352a6068d6dSSeongJae Park
353b1840272SSeongJae Parkschemes/<N>/quotas/
354b1840272SSeongJae Park-------------------
355b1840272SSeongJae Park
35667c34f6cSSeongJae ParkThe directory for the :ref:`quotas <damon_design_damos_quotas>` of the given
35767c34f6cSSeongJae ParkDAMON-based operation scheme.
35867c34f6cSSeongJae Park
35967c34f6cSSeongJae ParkUnder ``quotas`` directory, four files (``ms``, ``bytes``,
3607d8cebb9SSeongJae Park``reset_interval_ms``, ``effective_bytes``) and two directores (``weights`` and
3617d8cebb9SSeongJae Park``goals``) exist.
36267c34f6cSSeongJae Park
363a6068d6dSSeongJae ParkYou can set the ``time quota`` in milliseconds, ``size quota`` in bytes, and
364a6068d6dSSeongJae Park``reset interval`` in milliseconds by writing the values to the three files,
365a6068d6dSSeongJae Parkrespectively.  Then, DAMON tries to use only up to ``time quota`` milliseconds
366a6068d6dSSeongJae Parkfor applying the ``action`` to memory regions of the ``access_pattern``, and to
367a6068d6dSSeongJae Parkapply the action to only up to ``bytes`` bytes of memory regions within the
368a6068d6dSSeongJae Park``reset_interval_ms``.  Setting both ``ms`` and ``bytes`` zero disables the
36914e70e46SSeongJae Parkquota limits unless at least one :ref:`goal <sysfs_schemes_quota_goals>` is
370a6068d6dSSeongJae Parkset.
371a6068d6dSSeongJae Park
3726140edeeSSeongJae ParkThe time quota is internally transformed to a size quota.  Between the
3736140edeeSSeongJae Parktransformed size quota and user-specified size quota, smaller one is applied.
3746140edeeSSeongJae ParkBased on the user-specified :ref:`goal <sysfs_schemes_quota_goals>`, the
37501e08737SSeongJae Parkeffective size quota is further adjusted.  Reading ``effective_bytes`` returns
37601e08737SSeongJae Parkthe current effective size quota.  The file is not updated in real time, so
37701e08737SSeongJae Parkusers should ask DAMON sysfs interface to update the content of the file for
378b1840272SSeongJae Parkthe stats by writing a special keyword, ``update_schemes_effective_quotas`` to
3796140edeeSSeongJae Parkthe relevant ``kdamonds/<N>/state`` file.
3806140edeeSSeongJae Park
3816140edeeSSeongJae ParkUnder ``weights`` directory, three files (``sz_permil``,
3826140edeeSSeongJae Park``nr_accesses_permil``, and ``age_permil``) exist.
3836140edeeSSeongJae ParkYou can set the :ref:`prioritization weights
3846140edeeSSeongJae Park<damon_design_damos_quotas_prioritization>` for size, access frequency, and age
3856140edeeSSeongJae Parkin per-thousand unit by writing the values to the three files under the
3866140edeeSSeongJae Park``weights`` directory.
3876140edeeSSeongJae Park
3886140edeeSSeongJae Park.. _sysfs_schemes_quota_goals:
3896140edeeSSeongJae Park
3906140edeeSSeongJae Parkschemes/<N>/quotas/goals/
3916140edeeSSeongJae Park-------------------------
3926140edeeSSeongJae Park
393*a7bb1e75SSeongJae ParkThe directory for the :ref:`automatic quota tuning goals
394*a7bb1e75SSeongJae Park<damon_design_damos_quotas_auto_tuning>` of the given DAMON-based operation
395*a7bb1e75SSeongJae Parkscheme.
396*a7bb1e75SSeongJae Park
397*a7bb1e75SSeongJae ParkIn the beginning, this directory has only one file, ``nr_goals``.  Writing a
3986140edeeSSeongJae Parknumber (``N``) to the file creates the number of child directories named ``0``
3996140edeeSSeongJae Parkto ``N-1``.  Each directory represents each goal and current achievement.
4006140edeeSSeongJae ParkAmong the multiple feedback, the best one is used.
4019c8c315dSSeongJae Park
4029c8c315dSSeongJae ParkEach goal directory contains four files, namely ``target_metric``,
403b1840272SSeongJae Park``target_value``, ``current_value`` and ``nid``.  Users can set and get the
404b1840272SSeongJae Parkfour parameters for the quota auto-tuning goals that specified on the
405b1840272SSeongJae Park:ref:`design doc <damon_design_damos_quotas_auto_tuning>` by writing to and
40601e08737SSeongJae Parkreading from each of the files.  Note that users should further write
40701e08737SSeongJae Park``commit_schemes_quota_goals`` to the ``state`` file of the :ref:`kdamond
408b1840272SSeongJae Parkdirectory <sysfs_kdamond>` to pass the feedback to DAMON.
409b1840272SSeongJae Park
41001e08737SSeongJae Park.. _sysfs_watermarks:
41101e08737SSeongJae Park
412b1840272SSeongJae Parkschemes/<N>/watermarks/
413b1840272SSeongJae Park-----------------------
414b1840272SSeongJae Park
415b1840272SSeongJae ParkThe directory for the :ref:`watermarks <damon_design_damos_watermarks>` of the
416b1840272SSeongJae Parkgiven DAMON-based operation scheme.
417b1840272SSeongJae Park
418b1840272SSeongJae ParkUnder the watermarks directory, five files (``metric``, ``interval_us``,
419b1840272SSeongJae Park``high``, ``mid``, and ``low``) for setting the metric, the time interval
420b1840272SSeongJae Parkbetween check of the metric, and the three watermarks exist.  You can set and
421b1840272SSeongJae Parkget the five values by writing to the files, respectively.
4229c8c315dSSeongJae Park
4239c8c315dSSeongJae ParkKeywords and meanings of those that can be written to the ``metric`` file are
424114b4808SSeongJae Parkas below.
425114b4808SSeongJae Park
4269b7f9322SSeongJae Park - none: Ignore the watermarks
427114b4808SSeongJae Park - free_mem_rate: System's free memory rate (per thousand)
42801e08737SSeongJae Park
4299b7f9322SSeongJae ParkThe ``interval`` should written in microseconds unit.
430114b4808SSeongJae Park
431114b4808SSeongJae Park.. _sysfs_filters:
432114b4808SSeongJae Park
433114b4808SSeongJae Parkschemes/<N>/{core\_,ops\_,}filters/
434114b4808SSeongJae Park-----------------------------------
435114b4808SSeongJae Park
436114b4808SSeongJae ParkDirectories for :ref:`filters <damon_design_damos_filters>` of the given
437114b4808SSeongJae ParkDAMON-based operation scheme.
438114b4808SSeongJae Park
439114b4808SSeongJae Park``core_filters`` and ``ops_filters`` directories are for the filters handled by
440114b4808SSeongJae Parkthe DAMON core layer and operations set layer, respectively.  ``filters``
441114b4808SSeongJae Parkdirectory can be used for installing filters regardless of their handled
4429b7f9322SSeongJae Parklayers.  Filters that requested by ``core_filters`` and ``ops_filters`` will be
4439b7f9322SSeongJae Parkinstalled before those of ``filters``.  All three directories have same files.
4449b7f9322SSeongJae Park
4459b7f9322SSeongJae ParkUse of ``filters`` directory can make expecting evaluation orders of given
4464ddb2092SUsama Ariffilters with the files under directory bit confusing.  Users are hence
4474ddb2092SUsama Arifrecommended to use ``core_filters`` and ``ops_filters`` directories.  The
4480f28583bSSeongJae Park``filters`` directory could be deprecated in future.
4490f28583bSSeongJae Park
450114b4808SSeongJae ParkIn the beginning, the directory has only one file, ``nr_filters``.  Writing a
4515bce4947SSeongJae Parknumber (``N``) to the file creates the number of child directories named ``0``
4520f28583bSSeongJae Parkto ``N-1``.  Each directory represents each filter.  The filters are evaluated
4530f28583bSSeongJae Parkin the numeric order.
4540f28583bSSeongJae Park
4550f28583bSSeongJae ParkEach filter directory contains nine files, namely ``type``, ``matching``,
4560f28583bSSeongJae Park``allow``, ``memcg_path``, ``addr_start``, ``addr_end``, ``min``, ``max``
4570f28583bSSeongJae Parkand ``target_idx``.  To ``type`` file, you can write the type of the filter.
4580f28583bSSeongJae ParkRefer to :ref:`the design doc <damon_design_damos_filters>` for available type
4590f28583bSSeongJae Parknames, their meaning and on what layer those are handled.
4600f28583bSSeongJae Park
4615bce4947SSeongJae ParkFor ``memcg`` type, you can specify the memory cgroup of the interest by
462bc6f663aSSeongJae Parkwriting the path of the memory cgroup from the cgroups mount point to
463bc6f663aSSeongJae Park``memcg_path`` file.  For ``addr`` type, you can specify the start and end
464bc6f663aSSeongJae Parkaddress of the range (open-ended interval) to ``addr_start`` and ``addr_end``
465bc6f663aSSeongJae Parkfiles, respectively.  For ``hugepage_size`` type, you can specify the minimum
4669b7f9322SSeongJae Parkand maximum size of the range (closed interval) to ``min`` and ``max`` files,
4679b7f9322SSeongJae Parkrespectively.  For ``target`` type, you can specify the index of the target
4689b7f9322SSeongJae Parkbetween the list of the DAMON context's monitoring targets list to
4699b7f9322SSeongJae Park``target_idx`` file.
470114b4808SSeongJae Park
4719b7f9322SSeongJae ParkYou can write ``Y`` or ``N`` to ``matching`` file to specify whether the filter
472bc6f663aSSeongJae Parkis for memory that matches the ``type``.  You can write ``Y`` or ``N`` to
4739b7f9322SSeongJae Park``allow`` file to specify if applying the action to the memory that satisfies
4749b7f9322SSeongJae Parkthe ``type`` and ``matching`` should be allowed or not.
475bc6f663aSSeongJae Park
4769b7f9322SSeongJae ParkFor example, below restricts a DAMOS action to be applied to only non-anonymous
4779b7f9322SSeongJae Parkpages of all memory cgroups except ``/having_care_already``.::
4789b7f9322SSeongJae Park
479da2a0618SSeongJae Park    # cd ops_filters/0/
480bc6f663aSSeongJae Park    # echo 2 > nr_filters
4819b7f9322SSeongJae Park    # # disallow anonymous pages
4825bce4947SSeongJae Park    echo anon > 0/type
483bc6f663aSSeongJae Park    echo Y > 0/matching
484bc6f663aSSeongJae Park    echo N > 0/allow
485bc6f663aSSeongJae Park    # # further filter out all cgroups except one at '/having_care_already'
4869b7f9322SSeongJae Park    echo memcg > 1/type
487b1840272SSeongJae Park    echo /having_care_already > 1/memcg_path
488b1840272SSeongJae Park    echo Y > 1/matching
489b1840272SSeongJae Park    echo N > 1/allow
490b1840272SSeongJae Park
491b1840272SSeongJae ParkRefer to the :ref:`DAMOS filters design documentation
4926bbdb28dSSeongJae Park<damon_design_damos_filters>` for more details including how multiple filters
4936bbdb28dSSeongJae Parkof different ``allow`` works, when each of the filters are supported, and
4946bbdb28dSSeongJae Parkdifferences on stats.
495b1840272SSeongJae Park
496b1840272SSeongJae Park.. _damon_sysfs_dests:
4976bbdb28dSSeongJae Park
4986bbdb28dSSeongJae Parkschemes/<N>/dests/
4996bbdb28dSSeongJae Park------------------
5006bbdb28dSSeongJae Park
5016bbdb28dSSeongJae ParkDirectory for specifying the destinations of given DAMON-based operation
502b1840272SSeongJae Parkscheme's action.  This directory is ignored if the action of the given scheme
5037f0a86f3SSeongJae Parkis not supporting multiple destinations.  Only ``DAMOS_MIGRATE_{HOT,COLD}``
5047f0a86f3SSeongJae Parkactions are supporting multiple destinations.
5057f0a86f3SSeongJae Park
5067f0a86f3SSeongJae ParkIn the beginning, the directory has only one file, ``nr_dests``.  Writing a
5077f0a86f3SSeongJae Parknumber (``N``) to the file creates the number of child directories named ``0``
508ea7f03a4SSeongJae Parkto ``N-1``.  Each directory represents each action destination.
509ea7f03a4SSeongJae Park
5107f0a86f3SSeongJae ParkEach destination directory contains two files, namely ``id`` and ``weight``.
511ea7f03a4SSeongJae ParkUsers can write and read the identifier of the destination to ``id`` file.
512ea7f03a4SSeongJae ParkFor ``DAMOS_MIGRATE_{HOT,COLD}`` actions, the migrate destination node's node
513ea7f03a4SSeongJae Parkid should be written to ``id`` file.  Users can write and read the weight of
514ea7f03a4SSeongJae Parkthe destination among the given destinations to the ``weight`` file.  The
515ea7f03a4SSeongJae Parkweight can be an arbitrary integer.  When DAMOS apply the action to each entity
516bc17ea26SSeongJae Parkof the memory region, it will select the destination of the action based on the
517bc17ea26SSeongJae Parkrelative weights of the destinations.
518bc17ea26SSeongJae Park
519ea7f03a4SSeongJae Park.. _sysfs_schemes_stats:
520ea7f03a4SSeongJae Park
521ea7f03a4SSeongJae Parkschemes/<N>/stats/
522ea7f03a4SSeongJae Park------------------
5237f0a86f3SSeongJae Park
5247f0a86f3SSeongJae ParkDAMON counts statistics for each scheme.  This statistics can be used for
5257f0a86f3SSeongJae Parkonline analysis or tuning of the schemes.  Refer to :ref:`design doc
5267f0a86f3SSeongJae Park<damon_design_damos_stat>` for more details about the stats.
5277f0a86f3SSeongJae Park
528ff71f26fSSeongJae ParkThe statistics can be retrieved by reading the files under ``stats`` directory
529ff71f26fSSeongJae Park(``nr_tried``, ``sz_tried``, ``nr_applied``, ``sz_applied``,
530ff71f26fSSeongJae Park``sz_ops_filter_passed``, and ``qt_exceeds``), respectively.  The files are not
531ff71f26fSSeongJae Parkupdated in real time, so you should ask DAMON sysfs interface to update the
532ff71f26fSSeongJae Parkcontent of the files for the stats by writing a special keyword,
5339c8c315dSSeongJae Park``update_schemes_stats`` to the relevant ``kdamonds/<N>/state`` file.
5349c8c315dSSeongJae Park
5357f0a86f3SSeongJae Park.. _sysfs_schemes_tried_regions:
5367f0a86f3SSeongJae Park
5377f0a86f3SSeongJae Parkschemes/<N>/tried_regions/
538f423944bSSeongJae Park--------------------------
539f423944bSSeongJae Park
540f423944bSSeongJae ParkThis directory initially has one file, ``total_bytes``.
541f423944bSSeongJae Park
5427f0a86f3SSeongJae ParkWhen a special keyword, ``update_schemes_tried_regions``, is written to the
543b1840272SSeongJae Parkrelevant ``kdamonds/<N>/state`` file, DAMON updates the ``total_bytes`` file so
544b1840272SSeongJae Parkthat reading it returns the total size of the scheme tried regions, and creates
545b1840272SSeongJae Parkdirectories named integer starting from ``0`` under this directory.  Each
546b1840272SSeongJae Parkdirectory contains files exposing detailed information about each of the memory
547b1840272SSeongJae Parkregion that the corresponding scheme's ``action`` has tried to be applied under
548b1840272SSeongJae Parkthis directory, during next :ref:`apply interval <damon_design_damos>` of the
549b1840272SSeongJae Parkcorresponding scheme.  The information includes address range, ``nr_accesses``,
550b1840272SSeongJae Parkand ``age`` of the region.
551b1840272SSeongJae Park
552b1840272SSeongJae ParkWriting ``update_schemes_tried_bytes`` to the relevant ``kdamonds/<N>/state``
553b1840272SSeongJae Parkfile will only update the ``total_bytes`` file, and will not create the
554b1840272SSeongJae Parksubdirectories.
555b1840272SSeongJae Park
556b1840272SSeongJae ParkThe directories will be removed when another special keyword,
557b1840272SSeongJae Park``clear_schemes_tried_regions``, is written to the relevant
558b1840272SSeongJae Park``kdamonds/<N>/state`` file.
559b1840272SSeongJae Park
560b1840272SSeongJae ParkThe expected usage of this directory is investigations of schemes' behaviors,
561465d0eb0SKairui Songand query-like efficient data access monitoring results retrievals.  For the
562465d0eb0SKairui Songlatter use case, in particular, users can set the ``action`` as ``stat`` and
563465d0eb0SKairui Songset the ``access pattern`` as their interested pattern that they want to query.
564465d0eb0SKairui Song
565465d0eb0SKairui Song.. _sysfs_schemes_tried_region:
566465d0eb0SKairui Song
567b1840272SSeongJae Parktried_regions/<N>/
568b1840272SSeongJae Park------------------
569b1840272SSeongJae Park
570b1840272SSeongJae ParkIn each region directory, you will find five files (``start``, ``end``,
571b1840272SSeongJae Park``nr_accesses``, ``age``, and ``sz_filter_passed``).  Reading the files will
572b1840272SSeongJae Parkshow the properties of the region that corresponding DAMON-based operation
573b1840272SSeongJae Parkscheme ``action`` has tried to be applied.
574b1840272SSeongJae Park
575b1840272SSeongJae ParkExample
576b1840272SSeongJae Park~~~~~~~
577b1840272SSeongJae Park
578b1840272SSeongJae ParkBelow commands applies a scheme saying "If a memory region of size in [4KiB,
579b1840272SSeongJae Park8KiB] is showing accesses per aggregate interval in [0, 5] for aggregate
58023a425aaSSeongJae Parkinterval in [10, 20], page out the region.  For the paging out, use only up to
581b1840272SSeongJae Park10ms per second, and also don't page out more than 1GiB per second.  Under the
58235b43d40SSeongJae Parklimitation, page out memory regions having longer age first.  Also, check the
58375999724SSeongJae Parkfree memory rate of the system every 5 seconds, start the monitoring and paging
58475999724SSeongJae Parkout when the free memory rate becomes lower than 50%, but stop it if the free
5851b2b7a17SSeongJae Parkmemory rate becomes larger than 60%, or lower than 30%". ::
5861b2b7a17SSeongJae Park
58775999724SSeongJae Park    # cd <sysfs>/kernel/mm/damon/admin
58875999724SSeongJae Park    # # populate directories
5891b2b7a17SSeongJae Park    # echo 1 > kdamonds/nr_kdamonds; echo 1 > kdamonds/0/contexts/nr_contexts;
5901b2b7a17SSeongJae Park    # echo 1 > kdamonds/0/contexts/0/schemes/nr_schemes
5911b2b7a17SSeongJae Park    # cd kdamonds/0/contexts/0/schemes/0
5921b2b7a17SSeongJae Park    # # set the basic access pattern and the action
5931b2b7a17SSeongJae Park    # echo 4096 > access_pattern/sz/min
5941b2b7a17SSeongJae Park    # echo 8192 > access_pattern/sz/max
5951b2b7a17SSeongJae Park    # echo 0 > access_pattern/nr_accesses/min
5961b2b7a17SSeongJae Park    # echo 5 > access_pattern/nr_accesses/max
5971b2b7a17SSeongJae Park    # echo 10 > access_pattern/age/min
5981b2b7a17SSeongJae Park    # echo 20 > access_pattern/age/max
5991b2b7a17SSeongJae Park    # echo pageout > action
6001b2b7a17SSeongJae Park    # # set quotas
6011b2b7a17SSeongJae Park    # echo 10 > quotas/ms
6021b2b7a17SSeongJae Park    # echo $((1024*1024*1024)) > quotas/bytes
60375999724SSeongJae Park    # echo 1000 > quotas/reset_interval_ms
6045af28560SSeongJae Park    # # set watermark
60575999724SSeongJae Park    # echo free_mem_rate > watermarks/metric
60675999724SSeongJae Park    # echo 5000000 > watermarks/interval_us
60775999724SSeongJae Park    # echo 600 > watermarks/high
6085af28560SSeongJae Park    # echo 500 > watermarks/mid
60975999724SSeongJae Park    # echo 300 > watermarks/low
6104f554ca1SSeongJae Park
6114f554ca1SSeongJae ParkPlease note that it's highly recommended to use user space tools like `damo
6124f554ca1SSeongJae Park<https://github.com/damonitor/damo>`_ rather than manually reading and writing
6134f554ca1SSeongJae Parkthe files as above.  Above is only for an example.
6144f554ca1SSeongJae Park
6154f554ca1SSeongJae Park.. _tracepoint:
6164f554ca1SSeongJae Park
6174f554ca1SSeongJae ParkTracepoints for Monitoring Results
6184f554ca1SSeongJae Park==================================
6194f554ca1SSeongJae Park
6204f554ca1SSeongJae ParkUsers can get the monitoring results via the :ref:`tried_regions
6214f554ca1SSeongJae Park<sysfs_schemes_tried_regions>`.  The interface is useful for getting a
6224f554ca1SSeongJae Parksnapshot, but it could be inefficient for fully recording all the monitoring
6234f554ca1SSeongJae Parkresults.  For the purpose, two trace points, namely ``damon:damon_aggregated``
62475999724SSeongJae Parkand ``damon:damos_before_apply``, are provided.  ``damon:damon_aggregated``
6251b2b7a17SSeongJae Parkprovides the whole monitoring results, while ``damon:damos_before_apply``
6261b2b7a17SSeongJae Parkprovides the monitoring results for regions that each DAMON-based Operation
6271b2b7a17SSeongJae ParkScheme (:ref:`DAMOS <damon_design_damos>`) is gonna be applied.  Hence,
6281b2b7a17SSeongJae Park``damon:damos_before_apply`` is more useful for recording internal behavior of
6291b2b7a17SSeongJae ParkDAMOS, or DAMOS target access
6301b2b7a17SSeongJae Park:ref:`pattern <damon_design_damos_access_pattern>` based query-like efficient
6311b2b7a17SSeongJae Parkmonitoring results recording.
6321b2b7a17SSeongJae Park
6331b2b7a17SSeongJae ParkWhile the monitoring is turned on, you could record the tracepoint events and
6341b2b7a17SSeongJae Parkshow results using tracepoint supporting tools like ``perf``.  For example::
6351b2b7a17SSeongJae Park
6361b2b7a17SSeongJae Park    # echo on > kdamonds/0/state
637    # perf record -e damon:damon_aggregated &
638    # sleep 5
639    # kill 9 $(pidof perf)
640    # echo off > kdamonds/0/state
641    # perf script
642    kdamond.0 46568 [027] 79357.842179: damon:damon_aggregated: target_id=0 nr_regions=11 122509119488-135708762112: 0 864
643    [...]
644
645Each line of the perf script output represents each monitoring region.  The
646first five fields are as usual other tracepoint outputs.  The sixth field
647(``target_id=X``) shows the ide of the monitoring target of the region.  The
648seventh field (``nr_regions=X``) shows the total number of monitoring regions
649for the target.  The eighth field (``X-Y:``) shows the start (``X``) and end
650(``Y``) addresses of the region in bytes.  The ninth field (``X``) shows the
651``nr_accesses`` of the region (refer to
652:ref:`design <damon_design_region_based_sampling>` for more details of the
653counter).  Finally the tenth field (``X``) shows the ``age`` of the region
654(refer to :ref:`design <damon_design_age_tracking>` for more details of the
655counter).
656
657If the event was ``damon:damos_beofre_apply``, the ``perf script`` output would
658be somewhat like below::
659
660    kdamond.0 47293 [000] 80801.060214: damon:damos_before_apply: ctx_idx=0 scheme_idx=0 target_idx=0 nr_regions=11 121932607488-135128711168: 0 136
661    [...]
662
663Each line of the output represents each monitoring region that each DAMON-based
664Operation Scheme was about to be applied at the traced time.  The first five
665fields are as usual.  It shows the index of the DAMON context (``ctx_idx=X``)
666of the scheme in the list of the contexts of the context's kdamond, the index
667of the scheme (``scheme_idx=X``) in the list of the schemes of the context, in
668addition to the output of ``damon_aggregated`` tracepoint.
669