~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/admin-guide/mm/damon/usage.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/admin-guide/mm/damon/usage.rst (Architecture m68k) and /Documentation/admin-guide/mm/damon/usage.rst (Architecture ppc)


  1 .. SPDX-License-Identifier: GPL-2.0                 1 .. SPDX-License-Identifier: GPL-2.0
  2                                                     2 
  3 ===============                                     3 ===============
  4 Detailed Usages                                     4 Detailed Usages
  5 ===============                                     5 ===============
  6                                                     6 
  7 DAMON provides below interfaces for different       7 DAMON provides below interfaces for different users.
  8                                                     8 
  9 - *DAMON user space tool.*                          9 - *DAMON user space tool.*
 10   `This <https://github.com/damonitor/damo>`_      10   `This <https://github.com/damonitor/damo>`_ is for privileged people such as
 11   system administrators who want a just-workin     11   system administrators who want a just-working human-friendly interface.
 12   Using this, users can use the DAMON’s majo     12   Using this, users can use the DAMON’s major features in a human-friendly way.
 13   It may not be highly tuned for special cases     13   It may not be highly tuned for special cases, though.  For more detail,
 14   please refer to its `usage document              14   please refer to its `usage document
 15   <https://github.com/damonitor/damo/blob/next     15   <https://github.com/damonitor/damo/blob/next/USAGE.md>`_.
 16 - *sysfs interface.*                               16 - *sysfs interface.*
 17   :ref:`This <sysfs_interface>` is for privile     17   :ref:`This <sysfs_interface>` is for privileged user space programmers who
 18   want more optimized use of DAMON.  Using thi     18   want more optimized use of DAMON.  Using this, users can use DAMON’s major
 19   features by reading from and writing to spec     19   features by reading from and writing to special sysfs files.  Therefore,
 20   you can write and use your personalized DAMO     20   you can write and use your personalized DAMON sysfs wrapper programs that
 21   reads/writes the sysfs files instead of you.     21   reads/writes the sysfs files instead of you.  The `DAMON user space tool
 22   <https://github.com/damonitor/damo>`_ is one     22   <https://github.com/damonitor/damo>`_ is one example of such programs.
 23 - *Kernel Space Programming Interface.*            23 - *Kernel Space Programming Interface.*
 24   :doc:`This </mm/damon/api>` is for kernel sp     24   :doc:`This </mm/damon/api>` is for kernel space programmers.  Using this,
 25   users can utilize every feature of DAMON mos     25   users can utilize every feature of DAMON most flexibly and efficiently by
 26   writing kernel space DAMON application progr     26   writing kernel space DAMON application programs for you.  You can even extend
 27   DAMON for various address spaces.  For detai     27   DAMON for various address spaces.  For detail, please refer to the interface
 28   :doc:`document </mm/damon/api>`.                 28   :doc:`document </mm/damon/api>`.
 29 - *debugfs interface. (DEPRECATED!)*               29 - *debugfs interface. (DEPRECATED!)*
 30   :ref:`This <debugfs_interface>` is almost id     30   :ref:`This <debugfs_interface>` is almost identical to :ref:`sysfs interface
 31   <sysfs_interface>`.  This is deprecated, so      31   <sysfs_interface>`.  This is deprecated, so users should move to the
 32   :ref:`sysfs interface <sysfs_interface>`.  I     32   :ref:`sysfs interface <sysfs_interface>`.  If you depend on this and cannot
 33   move, please report your usecase to damon@li     33   move, please report your usecase to damon@lists.linux.dev and
 34   linux-mm@kvack.org.                              34   linux-mm@kvack.org.
 35                                                    35 
 36 .. _sysfs_interface:                               36 .. _sysfs_interface:
 37                                                    37 
 38 sysfs Interface                                    38 sysfs Interface
 39 ===============                                    39 ===============
 40                                                    40 
 41 DAMON sysfs interface is built when ``CONFIG_D     41 DAMON sysfs interface is built when ``CONFIG_DAMON_SYSFS`` is defined.  It
 42 creates multiple directories and files under i     42 creates multiple directories and files under its sysfs directory,
 43 ``<sysfs>/kernel/mm/damon/``.  You can control     43 ``<sysfs>/kernel/mm/damon/``.  You can control DAMON by writing to and reading
 44 from the files under the directory.                44 from the files under the directory.
 45                                                    45 
 46 For a short example, users can monitor the vir     46 For a short example, users can monitor the virtual address space of a given
 47 workload as below. ::                              47 workload as below. ::
 48                                                    48 
 49     # cd /sys/kernel/mm/damon/admin/               49     # cd /sys/kernel/mm/damon/admin/
 50     # echo 1 > kdamonds/nr_kdamonds && echo 1      50     # echo 1 > kdamonds/nr_kdamonds && echo 1 > kdamonds/0/contexts/nr_contexts
 51     # echo vaddr > kdamonds/0/contexts/0/opera     51     # echo vaddr > kdamonds/0/contexts/0/operations
 52     # echo 1 > kdamonds/0/contexts/0/targets/n     52     # echo 1 > kdamonds/0/contexts/0/targets/nr_targets
 53     # echo $(pidof <workload>) > kdamonds/0/co     53     # echo $(pidof <workload>) > kdamonds/0/contexts/0/targets/0/pid_target
 54     # echo on > kdamonds/0/state                   54     # echo on > kdamonds/0/state
 55                                                    55 
 56 Files Hierarchy                                    56 Files Hierarchy
 57 ---------------                                    57 ---------------
 58                                                    58 
 59 The files hierarchy of DAMON sysfs interface i     59 The files hierarchy of DAMON sysfs interface is shown below.  In the below
 60 figure, parents-children relations are represe     60 figure, parents-children relations are represented with indentations, each
 61 directory is having ``/`` suffix, and files in     61 directory is having ``/`` suffix, and files in each directory are separated by
 62 comma (",").                                       62 comma (",").
 63                                                    63 
 64 .. parsed-literal::                                64 .. parsed-literal::
 65                                                    65 
 66     :ref:`/sys/kernel/mm/damon <sysfs_root>`/a     66     :ref:`/sys/kernel/mm/damon <sysfs_root>`/admin
 67     │ :ref:`kdamonds <sysfs_kdamonds>`/nr_kd     67     │ :ref:`kdamonds <sysfs_kdamonds>`/nr_kdamonds
 68     │ │ :ref:`0 <sysfs_kdamond>`/state,pid     68     │ │ :ref:`0 <sysfs_kdamond>`/state,pid
 69     │ │ │ :ref:`contexts <sysfs_contexts     69     │ │ │ :ref:`contexts <sysfs_contexts>`/nr_contexts
 70     │ │ │ │ :ref:`0 <sysfs_context>`/a     70     │ │ │ │ :ref:`0 <sysfs_context>`/avail_operations,operations
 71     │ │ │ │ │ :ref:`monitoring_attrs     71     │ │ │ │ │ :ref:`monitoring_attrs <sysfs_monitoring_attrs>`/
 72     │ │ │ │ │ │ intervals/sample_u     72     │ │ │ │ │ │ intervals/sample_us,aggr_us,update_us
 73     │ │ │ │ │ │ nr_regions/min,max     73     │ │ │ │ │ │ nr_regions/min,max
 74     │ │ │ │ │ :ref:`targets <sysfs_t     74     │ │ │ │ │ :ref:`targets <sysfs_targets>`/nr_targets
 75     │ │ │ │ │ │ :ref:`0 <sysfs_tar     75     │ │ │ │ │ │ :ref:`0 <sysfs_target>`/pid_target
 76     │ │ │ │ │ │ │ :ref:`regions      76     │ │ │ │ │ │ │ :ref:`regions <sysfs_regions>`/nr_regions
 77     │ │ │ │ │ │ │ │ :ref:`0 <s     77     │ │ │ │ │ │ │ │ :ref:`0 <sysfs_region>`/start,end
 78     │ │ │ │ │ │ │ │ ...            78     │ │ │ │ │ │ │ │ ...
 79     │ │ │ │ │ │ ...                    79     │ │ │ │ │ │ ...
 80     │ │ │ │ │ :ref:`schemes <sysfs_s     80     │ │ │ │ │ :ref:`schemes <sysfs_schemes>`/nr_schemes
 81     │ │ │ │ │ │ :ref:`0 <sysfs_sch     81     │ │ │ │ │ │ :ref:`0 <sysfs_scheme>`/action,target_nid,apply_interval_us
 82     │ │ │ │ │ │ │ :ref:`access_p     82     │ │ │ │ │ │ │ :ref:`access_pattern <sysfs_access_pattern>`/
 83     │ │ │ │ │ │ │ │ sz/min,max     83     │ │ │ │ │ │ │ │ sz/min,max
 84     │ │ │ │ │ │ │ │ nr_accesse     84     │ │ │ │ │ │ │ │ nr_accesses/min,max
 85     │ │ │ │ │ │ │ │ age/min,ma     85     │ │ │ │ │ │ │ │ age/min,max
 86     │ │ │ │ │ │ │ :ref:`quotas <     86     │ │ │ │ │ │ │ :ref:`quotas <sysfs_quotas>`/ms,bytes,reset_interval_ms,effective_bytes
 87     │ │ │ │ │ │ │ │ weights/sz     87     │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil
 88     │ │ │ │ │ │ │ │ :ref:`goal     88     │ │ │ │ │ │ │ │ :ref:`goals <sysfs_schemes_quota_goals>`/nr_goals
 89     │ │ │ │ │ │ │ │ │ 0/targ     89     │ │ │ │ │ │ │ │ │ 0/target_metric,target_value,current_value
 90     │ │ │ │ │ │ │ :ref:`watermar     90     │ │ │ │ │ │ │ :ref:`watermarks <sysfs_watermarks>`/metric,interval_us,high,mid,low
 91     │ │ │ │ │ │ │ :ref:`filters      91     │ │ │ │ │ │ │ :ref:`filters <sysfs_filters>`/nr_filters
 92     │ │ │ │ │ │ │ │ 0/type,mat     92     │ │ │ │ │ │ │ │ 0/type,matching,memcg_id
 93     │ │ │ │ │ │ │ :ref:`stats <s     93     │ │ │ │ │ │ │ :ref:`stats <sysfs_schemes_stats>`/nr_tried,sz_tried,nr_applied,sz_applied,qt_exceeds
 94     │ │ │ │ │ │ │ :ref:`tried_re     94     │ │ │ │ │ │ │ :ref:`tried_regions <sysfs_schemes_tried_regions>`/total_bytes
 95     │ │ │ │ │ │ │ │ 0/start,en     95     │ │ │ │ │ │ │ │ 0/start,end,nr_accesses,age
 96     │ │ │ │ │ │ │ │ ...            96     │ │ │ │ │ │ │ │ ...
 97     │ │ │ │ │ │ ...                    97     │ │ │ │ │ │ ...
 98     │ │ │ │ ...                            98     │ │ │ │ ...
 99     │ │ ...                                    99     │ │ ...
100                                                   100 
101 .. _sysfs_root:                                   101 .. _sysfs_root:
102                                                   102 
103 Root                                              103 Root
104 ----                                              104 ----
105                                                   105 
106 The root of the DAMON sysfs interface is ``<sy    106 The root of the DAMON sysfs interface is ``<sysfs>/kernel/mm/damon/``, and it
107 has one directory named ``admin``.  The direct    107 has one directory named ``admin``.  The directory contains the files for
108 privileged user space programs' control of DAM    108 privileged user space programs' control of DAMON.  User space tools or daemons
109 having the root permission could use this dire    109 having the root permission could use this directory.
110                                                   110 
111 .. _sysfs_kdamonds:                               111 .. _sysfs_kdamonds:
112                                                   112 
113 kdamonds/                                         113 kdamonds/
114 ---------                                         114 ---------
115                                                   115 
116 Under the ``admin`` directory, one directory,     116 Under the ``admin`` directory, one directory, ``kdamonds``, which has files for
117 controlling the kdamonds (refer to                117 controlling the kdamonds (refer to
118 :ref:`design <damon_design_execution_model_and    118 :ref:`design <damon_design_execution_model_and_data_structures>` for more
119 details) exists.  In the beginning, this direc    119 details) exists.  In the beginning, this directory has only one file,
120 ``nr_kdamonds``.  Writing a number (``N``) to     120 ``nr_kdamonds``.  Writing a number (``N``) to the file creates the number of
121 child directories named ``0`` to ``N-1``.  Eac    121 child directories named ``0`` to ``N-1``.  Each directory represents each
122 kdamond.                                          122 kdamond.
123                                                   123 
124 .. _sysfs_kdamond:                                124 .. _sysfs_kdamond:
125                                                   125 
126 kdamonds/<N>/                                     126 kdamonds/<N>/
127 -------------                                     127 -------------
128                                                   128 
129 In each kdamond directory, two files (``state`    129 In each kdamond directory, two files (``state`` and ``pid``) and one directory
130 (``contexts``) exist.                             130 (``contexts``) exist.
131                                                   131 
132 Reading ``state`` returns ``on`` if the kdamon    132 Reading ``state`` returns ``on`` if the kdamond is currently running, or
133 ``off`` if it is not running.                     133 ``off`` if it is not running.
134                                                   134 
135 Users can write below commands for the kdamond    135 Users can write below commands for the kdamond to the ``state`` file.
136                                                   136 
137 - ``on``: Start running.                          137 - ``on``: Start running.
138 - ``off``: Stop running.                          138 - ``off``: Stop running.
139 - ``commit``: Read the user inputs in the sysf    139 - ``commit``: Read the user inputs in the sysfs files except ``state`` file
140   again.                                          140   again.
141 - ``commit_schemes_quota_goals``: Read the DAM    141 - ``commit_schemes_quota_goals``: Read the DAMON-based operation schemes'
142   :ref:`quota goals <sysfs_schemes_quota_goals    142   :ref:`quota goals <sysfs_schemes_quota_goals>`.
143 - ``update_schemes_stats``: Update the content    143 - ``update_schemes_stats``: Update the contents of stats files for each
144   DAMON-based operation scheme of the kdamond.    144   DAMON-based operation scheme of the kdamond.  For details of the stats,
145   please refer to :ref:`stats section <sysfs_s    145   please refer to :ref:`stats section <sysfs_schemes_stats>`.
146 - ``update_schemes_tried_regions``: Update the    146 - ``update_schemes_tried_regions``: Update the DAMON-based operation scheme
147   action tried regions directory for each DAMO    147   action tried regions directory for each DAMON-based operation scheme of the
148   kdamond.  For details of the DAMON-based ope    148   kdamond.  For details of the DAMON-based operation scheme action tried
149   regions directory, please refer to              149   regions directory, please refer to
150   :ref:`tried_regions section <sysfs_schemes_t    150   :ref:`tried_regions section <sysfs_schemes_tried_regions>`.
151 - ``update_schemes_tried_bytes``: Update only     151 - ``update_schemes_tried_bytes``: Update only ``.../tried_regions/total_bytes``
152   files.                                          152   files.
153 - ``clear_schemes_tried_regions``: Clear the D    153 - ``clear_schemes_tried_regions``: Clear the DAMON-based operating scheme
154   action tried regions directory for each DAMO    154   action tried regions directory for each DAMON-based operation scheme of the
155   kdamond.                                        155   kdamond.
156 - ``update_schemes_effective_quotas``: Update     156 - ``update_schemes_effective_quotas``: Update the contents of
157   ``effective_bytes`` files for each DAMON-bas    157   ``effective_bytes`` files for each DAMON-based operation scheme of the
158   kdamond.  For more details, refer to :ref:`q    158   kdamond.  For more details, refer to :ref:`quotas directory <sysfs_quotas>`.
159                                                   159 
160 If the state is ``on``, reading ``pid`` shows     160 If the state is ``on``, reading ``pid`` shows the pid of the kdamond thread.
161                                                   161 
162 ``contexts`` directory contains files for cont    162 ``contexts`` directory contains files for controlling the monitoring contexts
163 that this kdamond will execute.                   163 that this kdamond will execute.
164                                                   164 
165 .. _sysfs_contexts:                               165 .. _sysfs_contexts:
166                                                   166 
167 kdamonds/<N>/contexts/                            167 kdamonds/<N>/contexts/
168 ----------------------                            168 ----------------------
169                                                   169 
170 In the beginning, this directory has only one     170 In the beginning, this directory has only one file, ``nr_contexts``.  Writing a
171 number (``N``) to the file creates the number     171 number (``N``) to the file creates the number of child directories named as
172 ``0`` to ``N-1``.  Each directory represents e    172 ``0`` to ``N-1``.  Each directory represents each monitoring context (refer to
173 :ref:`design <damon_design_execution_model_and    173 :ref:`design <damon_design_execution_model_and_data_structures>` for more
174 details).  At the moment, only one context per    174 details).  At the moment, only one context per kdamond is supported, so only
175 ``0`` or ``1`` can be written to the file.        175 ``0`` or ``1`` can be written to the file.
176                                                   176 
177 .. _sysfs_context:                                177 .. _sysfs_context:
178                                                   178 
179 contexts/<N>/                                     179 contexts/<N>/
180 -------------                                     180 -------------
181                                                   181 
182 In each context directory, two files (``avail_    182 In each context directory, two files (``avail_operations`` and ``operations``)
183 and three directories (``monitoring_attrs``, `    183 and three directories (``monitoring_attrs``, ``targets``, and ``schemes``)
184 exist.                                            184 exist.
185                                                   185 
186 DAMON supports multiple types of :ref:`monitor    186 DAMON supports multiple types of :ref:`monitoring operations
187 <damon_design_configurable_operations_set>`, i    187 <damon_design_configurable_operations_set>`, including those for virtual address
188 space and the physical address space.  You can    188 space and the physical address space.  You can get the list of available
189 monitoring operations set on the currently run    189 monitoring operations set on the currently running kernel by reading
190 ``avail_operations`` file.  Based on the kerne    190 ``avail_operations`` file.  Based on the kernel configuration, the file will
191 list different available operation sets.  Plea    191 list different available operation sets.  Please refer to the :ref:`design
192 <damon_operations_set>` for the list of all av    192 <damon_operations_set>` for the list of all available operation sets and their
193 brief explanations.                               193 brief explanations.
194                                                   194 
195 You can set and get what type of monitoring op    195 You can set and get what type of monitoring operations DAMON will use for the
196 context by writing one of the keywords listed     196 context by writing one of the keywords listed in ``avail_operations`` file and
197 reading from the ``operations`` file.             197 reading from the ``operations`` file.
198                                                   198 
199 .. _sysfs_monitoring_attrs:                       199 .. _sysfs_monitoring_attrs:
200                                                   200 
201 contexts/<N>/monitoring_attrs/                    201 contexts/<N>/monitoring_attrs/
202 ------------------------------                    202 ------------------------------
203                                                   203 
204 Files for specifying attributes of the monitor    204 Files for specifying attributes of the monitoring including required quality
205 and efficiency of the monitoring are in ``moni    205 and efficiency of the monitoring are in ``monitoring_attrs`` directory.
206 Specifically, two directories, ``intervals`` a    206 Specifically, two directories, ``intervals`` and ``nr_regions`` exist in this
207 directory.                                        207 directory.
208                                                   208 
209 Under ``intervals`` directory, three files for    209 Under ``intervals`` directory, three files for DAMON's sampling interval
210 (``sample_us``), aggregation interval (``aggr_    210 (``sample_us``), aggregation interval (``aggr_us``), and update interval
211 (``update_us``) exist.  You can set and get th    211 (``update_us``) exist.  You can set and get the values in micro-seconds by
212 writing to and reading from the files.            212 writing to and reading from the files.
213                                                   213 
214 Under ``nr_regions`` directory, two files for     214 Under ``nr_regions`` directory, two files for the lower-bound and upper-bound
215 of DAMON's monitoring regions (``min`` and ``m    215 of DAMON's monitoring regions (``min`` and ``max``, respectively), which
216 controls the monitoring overhead, exist.  You     216 controls the monitoring overhead, exist.  You can set and get the values by
217 writing to and rading from the files.             217 writing to and rading from the files.
218                                                   218 
219 For more details about the intervals and monit    219 For more details about the intervals and monitoring regions range, please refer
220 to the Design document (:doc:`/mm/damon/design    220 to the Design document (:doc:`/mm/damon/design`).
221                                                   221 
222 .. _sysfs_targets:                                222 .. _sysfs_targets:
223                                                   223 
224 contexts/<N>/targets/                             224 contexts/<N>/targets/
225 ---------------------                             225 ---------------------
226                                                   226 
227 In the beginning, this directory has only one     227 In the beginning, this directory has only one file, ``nr_targets``.  Writing a
228 number (``N``) to the file creates the number     228 number (``N``) to the file creates the number of child directories named ``0``
229 to ``N-1``.  Each directory represents each mo    229 to ``N-1``.  Each directory represents each monitoring target.
230                                                   230 
231 .. _sysfs_target:                                 231 .. _sysfs_target:
232                                                   232 
233 targets/<N>/                                      233 targets/<N>/
234 ------------                                      234 ------------
235                                                   235 
236 In each target directory, one file (``pid_targ    236 In each target directory, one file (``pid_target``) and one directory
237 (``regions``) exist.                              237 (``regions``) exist.
238                                                   238 
239 If you wrote ``vaddr`` to the ``contexts/<N>/o    239 If you wrote ``vaddr`` to the ``contexts/<N>/operations``, each target should
240 be a process.  You can specify the process to     240 be a process.  You can specify the process to DAMON by writing the pid of the
241 process to the ``pid_target`` file.               241 process to the ``pid_target`` file.
242                                                   242 
243 .. _sysfs_regions:                                243 .. _sysfs_regions:
244                                                   244 
245 targets/<N>/regions                               245 targets/<N>/regions
246 -------------------                               246 -------------------
247                                                   247 
248 In case of ``fvaddr`` or ``paddr`` monitoring     248 In case of ``fvaddr`` or ``paddr`` monitoring operations sets, users are
249 required to set the monitoring target address     249 required to set the monitoring target address ranges.  In case of ``vaddr``
250 operations set, it is not mandatory, but users    250 operations set, it is not mandatory, but users can optionally set the initial
251 monitoring region to specific address ranges.     251 monitoring region to specific address ranges.  Please refer to the :ref:`design
252 <damon_design_vaddr_target_regions_constructio    252 <damon_design_vaddr_target_regions_construction>` for more details.
253                                                   253 
254 For such cases, users can explicitly set the i    254 For such cases, users can explicitly set the initial monitoring target regions
255 as they want, by writing proper values to the     255 as they want, by writing proper values to the files under this directory.
256                                                   256 
257 In the beginning, this directory has only one     257 In the beginning, this directory has only one file, ``nr_regions``.  Writing a
258 number (``N``) to the file creates the number     258 number (``N``) to the file creates the number of child directories named ``0``
259 to ``N-1``.  Each directory represents each in    259 to ``N-1``.  Each directory represents each initial monitoring target region.
260                                                   260 
261 .. _sysfs_region:                                 261 .. _sysfs_region:
262                                                   262 
263 regions/<N>/                                      263 regions/<N>/
264 ------------                                      264 ------------
265                                                   265 
266 In each region directory, you will find two fi    266 In each region directory, you will find two files (``start`` and ``end``).  You
267 can set and get the start and end addresses of    267 can set and get the start and end addresses of the initial monitoring target
268 region by writing to and reading from the file    268 region by writing to and reading from the files, respectively.
269                                                   269 
270 Each region should not overlap with others.  `    270 Each region should not overlap with others.  ``end`` of directory ``N`` should
271 be equal or smaller than ``start`` of director    271 be equal or smaller than ``start`` of directory ``N+1``.
272                                                   272 
273 .. _sysfs_schemes:                                273 .. _sysfs_schemes:
274                                                   274 
275 contexts/<N>/schemes/                             275 contexts/<N>/schemes/
276 ---------------------                             276 ---------------------
277                                                   277 
278 The directory for DAMON-based Operation Scheme    278 The directory for DAMON-based Operation Schemes (:ref:`DAMOS
279 <damon_design_damos>`).  Users can get and set    279 <damon_design_damos>`).  Users can get and set the schemes by reading from and
280 writing to files under this directory.            280 writing to files under this directory.
281                                                   281 
282 In the beginning, this directory has only one     282 In the beginning, this directory has only one file, ``nr_schemes``.  Writing a
283 number (``N``) to the file creates the number     283 number (``N``) to the file creates the number of child directories named ``0``
284 to ``N-1``.  Each directory represents each DA    284 to ``N-1``.  Each directory represents each DAMON-based operation scheme.
285                                                   285 
286 .. _sysfs_scheme:                                 286 .. _sysfs_scheme:
287                                                   287 
288 schemes/<N>/                                      288 schemes/<N>/
289 ------------                                      289 ------------
290                                                   290 
291 In each scheme directory, five directories (``    291 In each scheme directory, five directories (``access_pattern``, ``quotas``,
292 ``watermarks``, ``filters``, ``stats``, and ``    292 ``watermarks``, ``filters``, ``stats``, and ``tried_regions``) and three files
293 (``action``, ``target_nid`` and ``apply_interv    293 (``action``, ``target_nid`` and ``apply_interval``) exist.
294                                                   294 
295 The ``action`` file is for setting and getting    295 The ``action`` file is for setting and getting the scheme's :ref:`action
296 <damon_design_damos_action>`.  The keywords th    296 <damon_design_damos_action>`.  The keywords that can be written to and read
297 from the file and their meaning are same to th    297 from the file and their meaning are same to those of the list on
298 :ref:`design doc <damon_design_damos_action>`.    298 :ref:`design doc <damon_design_damos_action>`.
299                                                   299 
300 The ``target_nid`` file is for setting the mig    300 The ``target_nid`` file is for setting the migration target node, which is
301 only meaningful when the ``action`` is either     301 only meaningful when the ``action`` is either ``migrate_hot`` or
302 ``migrate_cold``.                                 302 ``migrate_cold``.
303                                                   303 
304 The ``apply_interval_us`` file is for setting     304 The ``apply_interval_us`` file is for setting and getting the scheme's
305 :ref:`apply_interval <damon_design_damos>` in     305 :ref:`apply_interval <damon_design_damos>` in microseconds.
306                                                   306 
307 .. _sysfs_access_pattern:                         307 .. _sysfs_access_pattern:
308                                                   308 
309 schemes/<N>/access_pattern/                       309 schemes/<N>/access_pattern/
310 ---------------------------                       310 ---------------------------
311                                                   311 
312 The directory for the target access :ref:`patt    312 The directory for the target access :ref:`pattern
313 <damon_design_damos_access_pattern>` of the gi    313 <damon_design_damos_access_pattern>` of the given DAMON-based operation scheme.
314                                                   314 
315 Under the ``access_pattern`` directory, three     315 Under the ``access_pattern`` directory, three directories (``sz``,
316 ``nr_accesses``, and ``age``) each having two     316 ``nr_accesses``, and ``age``) each having two files (``min`` and ``max``)
317 exist.  You can set and get the access pattern    317 exist.  You can set and get the access pattern for the given scheme by writing
318 to and reading from the ``min`` and ``max`` fi    318 to and reading from the ``min`` and ``max`` files under ``sz``,
319 ``nr_accesses``, and ``age`` directories, resp    319 ``nr_accesses``, and ``age`` directories, respectively.  Note that the ``min``
320 and the ``max`` form a closed interval.           320 and the ``max`` form a closed interval.
321                                                   321 
322 .. _sysfs_quotas:                                 322 .. _sysfs_quotas:
323                                                   323 
324 schemes/<N>/quotas/                               324 schemes/<N>/quotas/
325 -------------------                               325 -------------------
326                                                   326 
327 The directory for the :ref:`quotas <damon_desi    327 The directory for the :ref:`quotas <damon_design_damos_quotas>` of the given
328 DAMON-based operation scheme.                     328 DAMON-based operation scheme.
329                                                   329 
330 Under ``quotas`` directory, four files (``ms``    330 Under ``quotas`` directory, four files (``ms``, ``bytes``,
331 ``reset_interval_ms``, ``effective_bytes``) an    331 ``reset_interval_ms``, ``effective_bytes``) and two directores (``weights`` and
332 ``goals``) exist.                                 332 ``goals``) exist.
333                                                   333 
334 You can set the ``time quota`` in milliseconds    334 You can set the ``time quota`` in milliseconds, ``size quota`` in bytes, and
335 ``reset interval`` in milliseconds by writing     335 ``reset interval`` in milliseconds by writing the values to the three files,
336 respectively.  Then, DAMON tries to use only u    336 respectively.  Then, DAMON tries to use only up to ``time quota`` milliseconds
337 for applying the ``action`` to memory regions     337 for applying the ``action`` to memory regions of the ``access_pattern``, and to
338 apply the action to only up to ``bytes`` bytes    338 apply the action to only up to ``bytes`` bytes of memory regions within the
339 ``reset_interval_ms``.  Setting both ``ms`` an    339 ``reset_interval_ms``.  Setting both ``ms`` and ``bytes`` zero disables the
340 quota limits unless at least one :ref:`goal <s    340 quota limits unless at least one :ref:`goal <sysfs_schemes_quota_goals>` is
341 set.                                              341 set.
342                                                   342 
343 The time quota is internally transformed to a     343 The time quota is internally transformed to a size quota.  Between the
344 transformed size quota and user-specified size    344 transformed size quota and user-specified size quota, smaller one is applied.
345 Based on the user-specified :ref:`goal <sysfs_    345 Based on the user-specified :ref:`goal <sysfs_schemes_quota_goals>`, the
346 effective size quota is further adjusted.  Rea    346 effective size quota is further adjusted.  Reading ``effective_bytes`` returns
347 the current effective size quota.  The file is    347 the current effective size quota.  The file is not updated in real time, so
348 users should ask DAMON sysfs interface to upda    348 users should ask DAMON sysfs interface to update the content of the file for
349 the stats by writing a special keyword, ``upda    349 the stats by writing a special keyword, ``update_schemes_effective_quotas`` to
350 the relevant ``kdamonds/<N>/state`` file.         350 the relevant ``kdamonds/<N>/state`` file.
351                                                   351 
352 Under ``weights`` directory, three files (``sz    352 Under ``weights`` directory, three files (``sz_permil``,
353 ``nr_accesses_permil``, and ``age_permil``) ex    353 ``nr_accesses_permil``, and ``age_permil``) exist.
354 You can set the :ref:`prioritization weights      354 You can set the :ref:`prioritization weights
355 <damon_design_damos_quotas_prioritization>` fo    355 <damon_design_damos_quotas_prioritization>` for size, access frequency, and age
356 in per-thousand unit by writing the values to     356 in per-thousand unit by writing the values to the three files under the
357 ``weights`` directory.                            357 ``weights`` directory.
358                                                   358 
359 .. _sysfs_schemes_quota_goals:                    359 .. _sysfs_schemes_quota_goals:
360                                                   360 
361 schemes/<N>/quotas/goals/                         361 schemes/<N>/quotas/goals/
362 -------------------------                         362 -------------------------
363                                                   363 
364 The directory for the :ref:`automatic quota tu    364 The directory for the :ref:`automatic quota tuning goals
365 <damon_design_damos_quotas_auto_tuning>` of th    365 <damon_design_damos_quotas_auto_tuning>` of the given DAMON-based operation
366 scheme.                                           366 scheme.
367                                                   367 
368 In the beginning, this directory has only one     368 In the beginning, this directory has only one file, ``nr_goals``.  Writing a
369 number (``N``) to the file creates the number     369 number (``N``) to the file creates the number of child directories named ``0``
370 to ``N-1``.  Each directory represents each go    370 to ``N-1``.  Each directory represents each goal and current achievement.
371 Among the multiple feedback, the best one is u    371 Among the multiple feedback, the best one is used.
372                                                   372 
373 Each goal directory contains three files, name    373 Each goal directory contains three files, namely ``target_metric``,
374 ``target_value`` and ``current_value``.  Users    374 ``target_value`` and ``current_value``.  Users can set and get the three
375 parameters for the quota auto-tuning goals tha    375 parameters for the quota auto-tuning goals that specified on the :ref:`design
376 doc <damon_design_damos_quotas_auto_tuning>` b    376 doc <damon_design_damos_quotas_auto_tuning>` by writing to and reading from each
377 of the files.  Note that users should further     377 of the files.  Note that users should further write
378 ``commit_schemes_quota_goals`` to the ``state`    378 ``commit_schemes_quota_goals`` to the ``state`` file of the :ref:`kdamond
379 directory <sysfs_kdamond>` to pass the feedbac    379 directory <sysfs_kdamond>` to pass the feedback to DAMON.
380                                                   380 
381 .. _sysfs_watermarks:                             381 .. _sysfs_watermarks:
382                                                   382 
383 schemes/<N>/watermarks/                           383 schemes/<N>/watermarks/
384 -----------------------                           384 -----------------------
385                                                   385 
386 The directory for the :ref:`watermarks <damon_    386 The directory for the :ref:`watermarks <damon_design_damos_watermarks>` of the
387 given DAMON-based operation scheme.               387 given DAMON-based operation scheme.
388                                                   388 
389 Under the watermarks directory, five files (``    389 Under the watermarks directory, five files (``metric``, ``interval_us``,
390 ``high``, ``mid``, and ``low``) for setting th    390 ``high``, ``mid``, and ``low``) for setting the metric, the time interval
391 between check of the metric, and the three wat    391 between check of the metric, and the three watermarks exist.  You can set and
392 get the five values by writing to the files, r    392 get the five values by writing to the files, respectively.
393                                                   393 
394 Keywords and meanings of those that can be wri    394 Keywords and meanings of those that can be written to the ``metric`` file are
395 as below.                                         395 as below.
396                                                   396 
397  - none: Ignore the watermarks                    397  - none: Ignore the watermarks
398  - free_mem_rate: System's free memory rate (p    398  - free_mem_rate: System's free memory rate (per thousand)
399                                                   399 
400 The ``interval`` should written in microsecond    400 The ``interval`` should written in microseconds unit.
401                                                   401 
402 .. _sysfs_filters:                                402 .. _sysfs_filters:
403                                                   403 
404 schemes/<N>/filters/                              404 schemes/<N>/filters/
405 --------------------                              405 --------------------
406                                                   406 
407 The directory for the :ref:`filters <damon_des    407 The directory for the :ref:`filters <damon_design_damos_filters>` of the given
408 DAMON-based operation scheme.                     408 DAMON-based operation scheme.
409                                                   409 
410 In the beginning, this directory has only one     410 In the beginning, this directory has only one file, ``nr_filters``.  Writing a
411 number (``N``) to the file creates the number     411 number (``N``) to the file creates the number of child directories named ``0``
412 to ``N-1``.  Each directory represents each fi    412 to ``N-1``.  Each directory represents each filter.  The filters are evaluated
413 in the numeric order.                             413 in the numeric order.
414                                                   414 
415 Each filter directory contains six files, name    415 Each filter directory contains six files, namely ``type``, ``matcing``,
416 ``memcg_path``, ``addr_start``, ``addr_end``,     416 ``memcg_path``, ``addr_start``, ``addr_end``, and ``target_idx``.  To ``type``
417 file, you can write one of five special keywor    417 file, you can write one of five special keywords: ``anon`` for anonymous pages,
418 ``memcg`` for specific memory cgroup, ``young`    418 ``memcg`` for specific memory cgroup, ``young`` for young pages, ``addr`` for
419 specific address range (an open-ended interval    419 specific address range (an open-ended interval), or ``target`` for specific
420 DAMON monitoring target filtering.  In case of    420 DAMON monitoring target filtering.  In case of the memory cgroup filtering, you
421 can specify the memory cgroup of the interest     421 can specify the memory cgroup of the interest by writing the path of the memory
422 cgroup from the cgroups mount point to ``memcg    422 cgroup from the cgroups mount point to ``memcg_path`` file.  In case of the
423 address range filtering, you can specify the s    423 address range filtering, you can specify the start and end address of the range
424 to ``addr_start`` and ``addr_end`` files, resp    424 to ``addr_start`` and ``addr_end`` files, respectively.  For the DAMON
425 monitoring target filtering, you can specify t    425 monitoring target filtering, you can specify the index of the target between
426 the list of the DAMON context's monitoring tar    426 the list of the DAMON context's monitoring targets list to ``target_idx`` file.
427 You can write ``Y`` or ``N`` to ``matching`` f    427 You can write ``Y`` or ``N`` to ``matching`` file to filter out pages that does
428 or does not match to the type, respectively.      428 or does not match to the type, respectively.  Then, the scheme's action will
429 not be applied to the pages that specified to     429 not be applied to the pages that specified to be filtered out.
430                                                   430 
431 For example, below restricts a DAMOS action to    431 For example, below restricts a DAMOS action to be applied to only non-anonymous
432 pages of all memory cgroups except ``/having_c    432 pages of all memory cgroups except ``/having_care_already``.::
433                                                   433 
434     # echo 2 > nr_filters                         434     # echo 2 > nr_filters
435     # # filter out anonymous pages                435     # # filter out anonymous pages
436     echo anon > 0/type                            436     echo anon > 0/type
437     echo Y > 0/matching                           437     echo Y > 0/matching
438     # # further filter out all cgroups except     438     # # further filter out all cgroups except one at '/having_care_already'
439     echo memcg > 1/type                           439     echo memcg > 1/type
440     echo /having_care_already > 1/memcg_path      440     echo /having_care_already > 1/memcg_path
441     echo Y > 1/matching                           441     echo Y > 1/matching
442                                                   442 
443 Note that ``anon`` and ``memcg`` filters are c    443 Note that ``anon`` and ``memcg`` filters are currently supported only when
444 ``paddr`` :ref:`implementation <sysfs_context>    444 ``paddr`` :ref:`implementation <sysfs_context>` is being used.
445                                                   445 
446 Also, memory regions that are filtered out by     446 Also, memory regions that are filtered out by ``addr`` or ``target`` filters
447 are not counted as the scheme has tried to tho    447 are not counted as the scheme has tried to those, while regions that filtered
448 out by other type filters are counted as the s    448 out by other type filters are counted as the scheme has tried to.  The
449 difference is applied to :ref:`stats <damos_st    449 difference is applied to :ref:`stats <damos_stats>` and
450 :ref:`tried regions <sysfs_schemes_tried_regio    450 :ref:`tried regions <sysfs_schemes_tried_regions>`.
451                                                   451 
452 .. _sysfs_schemes_stats:                          452 .. _sysfs_schemes_stats:
453                                                   453 
454 schemes/<N>/stats/                                454 schemes/<N>/stats/
455 ------------------                                455 ------------------
456                                                   456 
457 DAMON counts the total number and bytes of reg    457 DAMON counts the total number and bytes of regions that each scheme is tried to
458 be applied, the two numbers for the regions th    458 be applied, the two numbers for the regions that each scheme is successfully
459 applied, and the total number of the quota lim    459 applied, and the total number of the quota limit exceeds.  This statistics can
460 be used for online analysis or tuning of the s    460 be used for online analysis or tuning of the schemes.
461                                                   461 
462 The statistics can be retrieved by reading the    462 The statistics can be retrieved by reading the files under ``stats`` directory
463 (``nr_tried``, ``sz_tried``, ``nr_applied``, `    463 (``nr_tried``, ``sz_tried``, ``nr_applied``, ``sz_applied``, and
464 ``qt_exceeds``), respectively.  The files are     464 ``qt_exceeds``), respectively.  The files are not updated in real time, so you
465 should ask DAMON sysfs interface to update the    465 should ask DAMON sysfs interface to update the content of the files for the
466 stats by writing a special keyword, ``update_s    466 stats by writing a special keyword, ``update_schemes_stats`` to the relevant
467 ``kdamonds/<N>/state`` file.                      467 ``kdamonds/<N>/state`` file.
468                                                   468 
469 .. _sysfs_schemes_tried_regions:                  469 .. _sysfs_schemes_tried_regions:
470                                                   470 
471 schemes/<N>/tried_regions/                        471 schemes/<N>/tried_regions/
472 --------------------------                        472 --------------------------
473                                                   473 
474 This directory initially has one file, ``total    474 This directory initially has one file, ``total_bytes``.
475                                                   475 
476 When a special keyword, ``update_schemes_tried    476 When a special keyword, ``update_schemes_tried_regions``, is written to the
477 relevant ``kdamonds/<N>/state`` file, DAMON up    477 relevant ``kdamonds/<N>/state`` file, DAMON updates the ``total_bytes`` file so
478 that reading it returns the total size of the     478 that reading it returns the total size of the scheme tried regions, and creates
479 directories named integer starting from ``0``     479 directories named integer starting from ``0`` under this directory.  Each
480 directory contains files exposing detailed inf    480 directory contains files exposing detailed information about each of the memory
481 region that the corresponding scheme's ``actio    481 region that the corresponding scheme's ``action`` has tried to be applied under
482 this directory, during next :ref:`apply interv    482 this directory, during next :ref:`apply interval <damon_design_damos>` of the
483 corresponding scheme.  The information include    483 corresponding scheme.  The information includes address range, ``nr_accesses``,
484 and ``age`` of the region.                        484 and ``age`` of the region.
485                                                   485 
486 Writing ``update_schemes_tried_bytes`` to the     486 Writing ``update_schemes_tried_bytes`` to the relevant ``kdamonds/<N>/state``
487 file will only update the ``total_bytes`` file    487 file will only update the ``total_bytes`` file, and will not create the
488 subdirectories.                                   488 subdirectories.
489                                                   489 
490 The directories will be removed when another s    490 The directories will be removed when another special keyword,
491 ``clear_schemes_tried_regions``, is written to    491 ``clear_schemes_tried_regions``, is written to the relevant
492 ``kdamonds/<N>/state`` file.                      492 ``kdamonds/<N>/state`` file.
493                                                   493 
494 The expected usage of this directory is invest    494 The expected usage of this directory is investigations of schemes' behaviors,
495 and query-like efficient data access monitorin    495 and query-like efficient data access monitoring results retrievals.  For the
496 latter use case, in particular, users can set     496 latter use case, in particular, users can set the ``action`` as ``stat`` and
497 set the ``access pattern`` as their interested    497 set the ``access pattern`` as their interested pattern that they want to query.
498                                                   498 
499 .. _sysfs_schemes_tried_region:                   499 .. _sysfs_schemes_tried_region:
500                                                   500 
501 tried_regions/<N>/                                501 tried_regions/<N>/
502 ------------------                                502 ------------------
503                                                   503 
504 In each region directory, you will find four f    504 In each region directory, you will find four files (``start``, ``end``,
505 ``nr_accesses``, and ``age``).  Reading the fi    505 ``nr_accesses``, and ``age``).  Reading the files will show the start and end
506 addresses, ``nr_accesses``, and ``age`` of the    506 addresses, ``nr_accesses``, and ``age`` of the region that corresponding
507 DAMON-based operation scheme ``action`` has tr    507 DAMON-based operation scheme ``action`` has tried to be applied.
508                                                   508 
509 Example                                           509 Example
510 ~~~~~~~                                           510 ~~~~~~~
511                                                   511 
512 Below commands applies a scheme saying "If a m    512 Below commands applies a scheme saying "If a memory region of size in [4KiB,
513 8KiB] is showing accesses per aggregate interv    513 8KiB] is showing accesses per aggregate interval in [0, 5] for aggregate
514 interval in [10, 20], page out the region.  Fo    514 interval in [10, 20], page out the region.  For the paging out, use only up to
515 10ms per second, and also don't page out more     515 10ms per second, and also don't page out more than 1GiB per second.  Under the
516 limitation, page out memory regions having lon    516 limitation, page out memory regions having longer age first.  Also, check the
517 free memory rate of the system every 5 seconds    517 free memory rate of the system every 5 seconds, start the monitoring and paging
518 out when the free memory rate becomes lower th    518 out when the free memory rate becomes lower than 50%, but stop it if the free
519 memory rate becomes larger than 60%, or lower     519 memory rate becomes larger than 60%, or lower than 30%". ::
520                                                   520 
521     # cd <sysfs>/kernel/mm/damon/admin            521     # cd <sysfs>/kernel/mm/damon/admin
522     # # populate directories                      522     # # populate directories
523     # echo 1 > kdamonds/nr_kdamonds; echo 1 >     523     # echo 1 > kdamonds/nr_kdamonds; echo 1 > kdamonds/0/contexts/nr_contexts;
524     # echo 1 > kdamonds/0/contexts/0/schemes/n    524     # echo 1 > kdamonds/0/contexts/0/schemes/nr_schemes
525     # cd kdamonds/0/contexts/0/schemes/0          525     # cd kdamonds/0/contexts/0/schemes/0
526     # # set the basic access pattern and the a    526     # # set the basic access pattern and the action
527     # echo 4096 > access_pattern/sz/min           527     # echo 4096 > access_pattern/sz/min
528     # echo 8192 > access_pattern/sz/max           528     # echo 8192 > access_pattern/sz/max
529     # echo 0 > access_pattern/nr_accesses/min     529     # echo 0 > access_pattern/nr_accesses/min
530     # echo 5 > access_pattern/nr_accesses/max     530     # echo 5 > access_pattern/nr_accesses/max
531     # echo 10 > access_pattern/age/min            531     # echo 10 > access_pattern/age/min
532     # echo 20 > access_pattern/age/max            532     # echo 20 > access_pattern/age/max
533     # echo pageout > action                       533     # echo pageout > action
534     # # set quotas                                534     # # set quotas
535     # echo 10 > quotas/ms                         535     # echo 10 > quotas/ms
536     # echo $((1024*1024*1024)) > quotas/bytes     536     # echo $((1024*1024*1024)) > quotas/bytes
537     # echo 1000 > quotas/reset_interval_ms        537     # echo 1000 > quotas/reset_interval_ms
538     # # set watermark                             538     # # set watermark
539     # echo free_mem_rate > watermarks/metric      539     # echo free_mem_rate > watermarks/metric
540     # echo 5000000 > watermarks/interval_us       540     # echo 5000000 > watermarks/interval_us
541     # echo 600 > watermarks/high                  541     # echo 600 > watermarks/high
542     # echo 500 > watermarks/mid                   542     # echo 500 > watermarks/mid
543     # echo 300 > watermarks/low                   543     # echo 300 > watermarks/low
544                                                   544 
545 Please note that it's highly recommended to us    545 Please note that it's highly recommended to use user space tools like `damo
546 <https://github.com/damonitor/damo>`_ rather t    546 <https://github.com/damonitor/damo>`_ rather than manually reading and writing
547 the files as above.  Above is only for an exam    547 the files as above.  Above is only for an example.
548                                                   548 
549 .. _tracepoint:                                   549 .. _tracepoint:
550                                                   550 
551 Tracepoints for Monitoring Results                551 Tracepoints for Monitoring Results
552 ==================================                552 ==================================
553                                                   553 
554 Users can get the monitoring results via the :    554 Users can get the monitoring results via the :ref:`tried_regions
555 <sysfs_schemes_tried_regions>`.  The interface    555 <sysfs_schemes_tried_regions>`.  The interface is useful for getting a
556 snapshot, but it could be inefficient for full    556 snapshot, but it could be inefficient for fully recording all the monitoring
557 results.  For the purpose, two trace points, n    557 results.  For the purpose, two trace points, namely ``damon:damon_aggregated``
558 and ``damon:damos_before_apply``, are provided    558 and ``damon:damos_before_apply``, are provided.  ``damon:damon_aggregated``
559 provides the whole monitoring results, while `    559 provides the whole monitoring results, while ``damon:damos_before_apply``
560 provides the monitoring results for regions th    560 provides the monitoring results for regions that each DAMON-based Operation
561 Scheme (:ref:`DAMOS <damon_design_damos>`) is     561 Scheme (:ref:`DAMOS <damon_design_damos>`) is gonna be applied.  Hence,
562 ``damon:damos_before_apply`` is more useful fo    562 ``damon:damos_before_apply`` is more useful for recording internal behavior of
563 DAMOS, or DAMOS target access                     563 DAMOS, or DAMOS target access
564 :ref:`pattern <damon_design_damos_access_patte    564 :ref:`pattern <damon_design_damos_access_pattern>` based query-like efficient
565 monitoring results recording.                     565 monitoring results recording.
566                                                   566 
567 While the monitoring is turned on, you could r    567 While the monitoring is turned on, you could record the tracepoint events and
568 show results using tracepoint supporting tools    568 show results using tracepoint supporting tools like ``perf``.  For example::
569                                                   569 
570     # echo on > kdamonds/0/state                  570     # echo on > kdamonds/0/state
571     # perf record -e damon:damon_aggregated &     571     # perf record -e damon:damon_aggregated &
572     # sleep 5                                     572     # sleep 5
573     # kill 9 $(pidof perf)                        573     # kill 9 $(pidof perf)
574     # echo off > kdamonds/0/state                 574     # echo off > kdamonds/0/state
575     # perf script                                 575     # perf script
576     kdamond.0 46568 [027] 79357.842179: damon:    576     kdamond.0 46568 [027] 79357.842179: damon:damon_aggregated: target_id=0 nr_regions=11 122509119488-135708762112: 0 864
577     [...]                                         577     [...]
578                                                   578 
579 Each line of the perf script output represents    579 Each line of the perf script output represents each monitoring region.  The
580 first five fields are as usual other tracepoin    580 first five fields are as usual other tracepoint outputs.  The sixth field
581 (``target_id=X``) shows the ide of the monitor    581 (``target_id=X``) shows the ide of the monitoring target of the region.  The
582 seventh field (``nr_regions=X``) shows the tot    582 seventh field (``nr_regions=X``) shows the total number of monitoring regions
583 for the target.  The eighth field (``X-Y:``) s    583 for the target.  The eighth field (``X-Y:``) shows the start (``X``) and end
584 (``Y``) addresses of the region in bytes.  The    584 (``Y``) addresses of the region in bytes.  The ninth field (``X``) shows the
585 ``nr_accesses`` of the region (refer to           585 ``nr_accesses`` of the region (refer to
586 :ref:`design <damon_design_region_based_sampli    586 :ref:`design <damon_design_region_based_sampling>` for more details of the
587 counter).  Finally the tenth field (``X``) sho    587 counter).  Finally the tenth field (``X``) shows the ``age`` of the region
588 (refer to :ref:`design <damon_design_age_track    588 (refer to :ref:`design <damon_design_age_tracking>` for more details of the
589 counter).                                         589 counter).
590                                                   590 
591 If the event was ``damon:damos_beofre_apply``,    591 If the event was ``damon:damos_beofre_apply``, the ``perf script`` output would
592 be somewhat like below::                          592 be somewhat like below::
593                                                   593 
594     kdamond.0 47293 [000] 80801.060214: damon:    594     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
595     [...]                                         595     [...]
596                                                   596 
597 Each line of the output represents each monito    597 Each line of the output represents each monitoring region that each DAMON-based
598 Operation Scheme was about to be applied at th    598 Operation Scheme was about to be applied at the traced time.  The first five
599 fields are as usual.  It shows the index of th    599 fields are as usual.  It shows the index of the DAMON context (``ctx_idx=X``)
600 of the scheme in the list of the contexts of t    600 of the scheme in the list of the contexts of the context's kdamond, the index
601 of the scheme (``scheme_idx=X``) in the list o    601 of the scheme (``scheme_idx=X``) in the list of the schemes of the context, in
602 addition to the output of ``damon_aggregated``    602 addition to the output of ``damon_aggregated`` tracepoint.
603                                                   603 
604                                                   604 
605 .. _debugfs_interface:                            605 .. _debugfs_interface:
606                                                   606 
607 debugfs Interface (DEPRECATED!)                   607 debugfs Interface (DEPRECATED!)
608 ===============================                   608 ===============================
609                                                   609 
610 .. note::                                         610 .. note::
611                                                   611 
612   THIS IS DEPRECATED!                             612   THIS IS DEPRECATED!
613                                                   613 
614   DAMON debugfs interface is deprecated, so us    614   DAMON debugfs interface is deprecated, so users should move to the
615   :ref:`sysfs interface <sysfs_interface>`.  I    615   :ref:`sysfs interface <sysfs_interface>`.  If you depend on this and cannot
616   move, please report your usecase to damon@li    616   move, please report your usecase to damon@lists.linux.dev and
617   linux-mm@kvack.org.                             617   linux-mm@kvack.org.
618                                                   618 
619 DAMON exports nine files, ``DEPRECATED``, ``at    619 DAMON exports nine files, ``DEPRECATED``, ``attrs``, ``target_ids``,
620 ``init_regions``, ``schemes``, ``monitor_on_DE    620 ``init_regions``, ``schemes``, ``monitor_on_DEPRECATED``, ``kdamond_pid``,
621 ``mk_contexts`` and ``rm_contexts`` under its     621 ``mk_contexts`` and ``rm_contexts`` under its debugfs directory,
622 ``<debugfs>/damon/``.                             622 ``<debugfs>/damon/``.
623                                                   623 
624                                                   624 
625 ``DEPRECATED`` is a read-only file for the DAM    625 ``DEPRECATED`` is a read-only file for the DAMON debugfs interface deprecation
626 notice.  Reading it returns the deprecation no    626 notice.  Reading it returns the deprecation notice, as below::
627                                                   627 
628     # cat DEPRECATED                              628     # cat DEPRECATED
629     DAMON debugfs interface is deprecated, so     629     DAMON debugfs interface is deprecated, so users should move to DAMON_SYSFS. If you cannot, please report your usecase to damon@lists.linux.dev and linux-mm@kvack.org.
630                                                   630 
631                                                   631 
632 Attributes                                        632 Attributes
633 ----------                                        633 ----------
634                                                   634 
635 Users can get and set the ``sampling interval`    635 Users can get and set the ``sampling interval``, ``aggregation interval``,
636 ``update interval``, and min/max number of mon    636 ``update interval``, and min/max number of monitoring target regions by
637 reading from and writing to the ``attrs`` file    637 reading from and writing to the ``attrs`` file.  To know about the monitoring
638 attributes in detail, please refer to the :doc    638 attributes in detail, please refer to the :doc:`/mm/damon/design`.  For
639 example, below commands set those values to 5     639 example, below commands set those values to 5 ms, 100 ms, 1,000 ms, 10 and
640 1000, and then check it again::                   640 1000, and then check it again::
641                                                   641 
642     # cd <debugfs>/damon                          642     # cd <debugfs>/damon
643     # echo 5000 100000 1000000 10 1000 > attrs    643     # echo 5000 100000 1000000 10 1000 > attrs
644     # cat attrs                                   644     # cat attrs
645     5000 100000 1000000 10 1000                   645     5000 100000 1000000 10 1000
646                                                   646 
647                                                   647 
648 Target IDs                                        648 Target IDs
649 ----------                                        649 ----------
650                                                   650 
651 Some types of address spaces supports multiple    651 Some types of address spaces supports multiple monitoring target.  For example,
652 the virtual memory address spaces monitoring c    652 the virtual memory address spaces monitoring can have multiple processes as the
653 monitoring targets.  Users can set the targets    653 monitoring targets.  Users can set the targets by writing relevant id values of
654 the targets to, and get the ids of the current    654 the targets to, and get the ids of the current targets by reading from the
655 ``target_ids`` file.  In case of the virtual a    655 ``target_ids`` file.  In case of the virtual address spaces monitoring, the
656 values should be pids of the monitoring target    656 values should be pids of the monitoring target processes.  For example, below
657 commands set processes having pids 42 and 4242    657 commands set processes having pids 42 and 4242 as the monitoring targets and
658 check it again::                                  658 check it again::
659                                                   659 
660     # cd <debugfs>/damon                          660     # cd <debugfs>/damon
661     # echo 42 4242 > target_ids                   661     # echo 42 4242 > target_ids
662     # cat target_ids                              662     # cat target_ids
663     42 4242                                       663     42 4242
664                                                   664 
665 Users can also monitor the physical memory add    665 Users can also monitor the physical memory address space of the system by
666 writing a special keyword, "``paddr\n``" to th    666 writing a special keyword, "``paddr\n``" to the file.  Because physical address
667 space monitoring doesn't support multiple targ    667 space monitoring doesn't support multiple targets, reading the file will show a
668 fake value, ``42``, as below::                    668 fake value, ``42``, as below::
669                                                   669 
670     # cd <debugfs>/damon                          670     # cd <debugfs>/damon
671     # echo paddr > target_ids                     671     # echo paddr > target_ids
672     # cat target_ids                              672     # cat target_ids
673     42                                            673     42
674                                                   674 
675 Note that setting the target ids doesn't start    675 Note that setting the target ids doesn't start the monitoring.
676                                                   676 
677                                                   677 
678 Initial Monitoring Target Regions                 678 Initial Monitoring Target Regions
679 ---------------------------------                 679 ---------------------------------
680                                                   680 
681 In case of the virtual address space monitorin    681 In case of the virtual address space monitoring, DAMON automatically sets and
682 updates the monitoring target regions so that     682 updates the monitoring target regions so that entire memory mappings of target
683 processes can be covered.  However, users can     683 processes can be covered.  However, users can want to limit the monitoring
684 region to specific address ranges, such as the    684 region to specific address ranges, such as the heap, the stack, or specific
685 file-mapped area.  Or, some users can know the    685 file-mapped area.  Or, some users can know the initial access pattern of their
686 workloads and therefore want to set optimal in    686 workloads and therefore want to set optimal initial regions for the 'adaptive
687 regions adjustment'.                              687 regions adjustment'.
688                                                   688 
689 In contrast, DAMON do not automatically sets a    689 In contrast, DAMON do not automatically sets and updates the monitoring target
690 regions in case of physical memory monitoring.    690 regions in case of physical memory monitoring.  Therefore, users should set the
691 monitoring target regions by themselves.          691 monitoring target regions by themselves.
692                                                   692 
693 In such cases, users can explicitly set the in    693 In such cases, users can explicitly set the initial monitoring target regions
694 as they want, by writing proper values to the     694 as they want, by writing proper values to the ``init_regions`` file.  The input
695 should be a sequence of three integers separat    695 should be a sequence of three integers separated by white spaces that represent
696 one region in below form.::                       696 one region in below form.::
697                                                   697 
698     <target idx> <start address> <end address>    698     <target idx> <start address> <end address>
699                                                   699 
700 The ``target idx`` should be the index of the     700 The ``target idx`` should be the index of the target in ``target_ids`` file,
701 starting from ``0``, and the regions should be    701 starting from ``0``, and the regions should be passed in address order.  For
702 example, below commands will set a couple of a    702 example, below commands will set a couple of address ranges, ``1-100`` and
703 ``100-200`` as the initial monitoring target r    703 ``100-200`` as the initial monitoring target region of pid 42, which is the
704 first one (index ``0``) in ``target_ids``, and    704 first one (index ``0``) in ``target_ids``, and another couple of address
705 ranges, ``20-40`` and ``50-100`` as that of pi    705 ranges, ``20-40`` and ``50-100`` as that of pid 4242, which is the second one
706 (index ``1``) in ``target_ids``.::                706 (index ``1``) in ``target_ids``.::
707                                                   707 
708     # cd <debugfs>/damon                          708     # cd <debugfs>/damon
709     # cat target_ids                              709     # cat target_ids
710     42 4242                                       710     42 4242
711     # echo "0   1       100 \                     711     # echo "0   1       100 \
712             0   100     200 \                     712             0   100     200 \
713             1   20      40  \                     713             1   20      40  \
714             1   50      100" > init_regions       714             1   50      100" > init_regions
715                                                   715 
716 Note that this sets the initial monitoring tar    716 Note that this sets the initial monitoring target regions only.  In case of
717 virtual memory monitoring, DAMON will automati    717 virtual memory monitoring, DAMON will automatically updates the boundary of the
718 regions after one ``update interval``.  Theref    718 regions after one ``update interval``.  Therefore, users should set the
719 ``update interval`` large enough in this case,    719 ``update interval`` large enough in this case, if they don't want the
720 update.                                           720 update.
721                                                   721 
722                                                   722 
723 Schemes                                           723 Schemes
724 -------                                           724 -------
725                                                   725 
726 Users can get and set the DAMON-based operatio    726 Users can get and set the DAMON-based operation :ref:`schemes
727 <damon_design_damos>` by reading from and writ    727 <damon_design_damos>` by reading from and writing to ``schemes`` debugfs file.
728 Reading the file also shows the statistics of     728 Reading the file also shows the statistics of each scheme.  To the file, each
729 of the schemes should be represented in each l    729 of the schemes should be represented in each line in below form::
730                                                   730 
731     <target access pattern> <action> <quota> <    731     <target access pattern> <action> <quota> <watermarks>
732                                                   732 
733 You can disable schemes by simply writing an e    733 You can disable schemes by simply writing an empty string to the file.
734                                                   734 
735 Target Access Pattern                             735 Target Access Pattern
736 ~~~~~~~~~~~~~~~~~~~~~                             736 ~~~~~~~~~~~~~~~~~~~~~
737                                                   737 
738 The target access :ref:`pattern <damon_design_    738 The target access :ref:`pattern <damon_design_damos_access_pattern>` of the
739 scheme.  The ``<target access pattern>`` is co    739 scheme.  The ``<target access pattern>`` is constructed with three ranges in
740 below form::                                      740 below form::
741                                                   741 
742     min-size max-size min-acc max-acc min-age     742     min-size max-size min-acc max-acc min-age max-age
743                                                   743 
744 Specifically, bytes for the size of regions (`    744 Specifically, bytes for the size of regions (``min-size`` and ``max-size``),
745 number of monitored accesses per aggregate int    745 number of monitored accesses per aggregate interval for access frequency
746 (``min-acc`` and ``max-acc``), number of aggre    746 (``min-acc`` and ``max-acc``), number of aggregate intervals for the age of
747 regions (``min-age`` and ``max-age``) are spec    747 regions (``min-age`` and ``max-age``) are specified.  Note that the ranges are
748 closed interval.                                  748 closed interval.
749                                                   749 
750 Action                                            750 Action
751 ~~~~~~                                            751 ~~~~~~
752                                                   752 
753 The ``<action>`` is a predefined integer for m    753 The ``<action>`` is a predefined integer for memory management :ref:`actions
754 <damon_design_damos_action>`.  The mapping bet    754 <damon_design_damos_action>`.  The mapping between the ``<action>`` values and
755 the memory management actions is as below.  Fo    755 the memory management actions is as below.  For the detailed meaning of the
756 action and DAMON operations set supporting eac    756 action and DAMON operations set supporting each action, please refer to the
757 list on :ref:`design doc <damon_design_damos_a    757 list on :ref:`design doc <damon_design_damos_action>`.
758                                                   758 
759  - 0: ``willneed``                                759  - 0: ``willneed``
760  - 1: ``cold``                                    760  - 1: ``cold``
761  - 2: ``pageout``                                 761  - 2: ``pageout``
762  - 3: ``hugepage``                                762  - 3: ``hugepage``
763  - 4: ``nohugepage``                              763  - 4: ``nohugepage``
764  - 5: ``stat``                                    764  - 5: ``stat``
765                                                   765 
766 Quota                                             766 Quota
767 ~~~~~                                             767 ~~~~~
768                                                   768 
769 Users can set the :ref:`quotas <damon_design_d    769 Users can set the :ref:`quotas <damon_design_damos_quotas>` of the given scheme
770 via the ``<quota>`` in below form::               770 via the ``<quota>`` in below form::
771                                                   771 
772     <ms> <sz> <reset interval> <priority weigh    772     <ms> <sz> <reset interval> <priority weights>
773                                                   773 
774 This makes DAMON to try to use only up to ``<m    774 This makes DAMON to try to use only up to ``<ms>`` milliseconds for applying
775 the action to memory regions of the ``target a    775 the action to memory regions of the ``target access pattern`` within the
776 ``<reset interval>`` milliseconds, and to appl    776 ``<reset interval>`` milliseconds, and to apply the action to only up to
777 ``<sz>`` bytes of memory regions within the ``    777 ``<sz>`` bytes of memory regions within the ``<reset interval>``.  Setting both
778 ``<ms>`` and ``<sz>`` zero disables the quota     778 ``<ms>`` and ``<sz>`` zero disables the quota limits.
779                                                   779 
780 For the :ref:`prioritization <damon_design_dam    780 For the :ref:`prioritization <damon_design_damos_quotas_prioritization>`, users
781 can set the weights for the three properties i    781 can set the weights for the three properties in ``<priority weights>`` in below
782 form::                                            782 form::
783                                                   783 
784     <size weight> <access frequency weight> <a    784     <size weight> <access frequency weight> <age weight>
785                                                   785 
786 Watermarks                                        786 Watermarks
787 ~~~~~~~~~~                                        787 ~~~~~~~~~~
788                                                   788 
789 Users can specify :ref:`watermarks <damon_desi    789 Users can specify :ref:`watermarks <damon_design_damos_watermarks>` of the
790 given scheme via ``<watermarks>`` in below for    790 given scheme via ``<watermarks>`` in below form::
791                                                   791 
792     <metric> <check interval> <high mark> <mid    792     <metric> <check interval> <high mark> <middle mark> <low mark>
793                                                   793 
794 ``<metric>`` is a predefined integer for the m    794 ``<metric>`` is a predefined integer for the metric to be checked.  The
795 supported numbers and their meanings are as be    795 supported numbers and their meanings are as below.
796                                                   796 
797  - 0: Ignore the watermarks                       797  - 0: Ignore the watermarks
798  - 1: System's free memory rate (per thousand)    798  - 1: System's free memory rate (per thousand)
799                                                   799 
800 The value of the metric is checked every ``<ch    800 The value of the metric is checked every ``<check interval>`` microseconds.
801                                                   801 
802 If the value is higher than ``<high mark>`` or    802 If the value is higher than ``<high mark>`` or lower than ``<low mark>``, the
803 scheme is deactivated.  If the value is lower     803 scheme is deactivated.  If the value is lower than ``<mid mark>``, the scheme
804 is activated.                                     804 is activated.
805                                                   805 
806 .. _damos_stats:                                  806 .. _damos_stats:
807                                                   807 
808 Statistics                                        808 Statistics
809 ~~~~~~~~~~                                        809 ~~~~~~~~~~
810                                                   810 
811 It also counts the total number and bytes of r    811 It also counts the total number and bytes of regions that each scheme is tried
812 to be applied, the two numbers for the regions    812 to be applied, the two numbers for the regions that each scheme is successfully
813 applied, and the total number of the quota lim    813 applied, and the total number of the quota limit exceeds.  This statistics can
814 be used for online analysis or tuning of the s    814 be used for online analysis or tuning of the schemes.
815                                                   815 
816 The statistics can be shown by reading the ``s    816 The statistics can be shown by reading the ``schemes`` file.  Reading the file
817 will show each scheme you entered in each line    817 will show each scheme you entered in each line, and the five numbers for the
818 statistics will be added at the end of each li    818 statistics will be added at the end of each line.
819                                                   819 
820 Example                                           820 Example
821 ~~~~~~~                                           821 ~~~~~~~
822                                                   822 
823 Below commands applies a scheme saying "If a m    823 Below commands applies a scheme saying "If a memory region of size in [4KiB,
824 8KiB] is showing accesses per aggregate interv    824 8KiB] is showing accesses per aggregate interval in [0, 5] for aggregate
825 interval in [10, 20], page out the region.  Fo    825 interval in [10, 20], page out the region.  For the paging out, use only up to
826 10ms per second, and also don't page out more     826 10ms per second, and also don't page out more than 1GiB per second.  Under the
827 limitation, page out memory regions having lon    827 limitation, page out memory regions having longer age first.  Also, check the
828 free memory rate of the system every 5 seconds    828 free memory rate of the system every 5 seconds, start the monitoring and paging
829 out when the free memory rate becomes lower th    829 out when the free memory rate becomes lower than 50%, but stop it if the free
830 memory rate becomes larger than 60%, or lower     830 memory rate becomes larger than 60%, or lower than 30%".::
831                                                   831 
832     # cd <debugfs>/damon                          832     # cd <debugfs>/damon
833     # scheme="4096 8192  0 5    10 20    2"  #    833     # scheme="4096 8192  0 5    10 20    2"  # target access pattern and action
834     # scheme+=" 10 $((1024*1024*1024)) 1000" #    834     # scheme+=" 10 $((1024*1024*1024)) 1000" # quotas
835     # scheme+=" 0 0 100"                     #    835     # scheme+=" 0 0 100"                     # prioritization weights
836     # scheme+=" 1 5000000 600 500 300"       #    836     # scheme+=" 1 5000000 600 500 300"       # watermarks
837     # echo "$scheme" > schemes                    837     # echo "$scheme" > schemes
838                                                   838 
839                                                   839 
840 Turning On/Off                                    840 Turning On/Off
841 --------------                                    841 --------------
842                                                   842 
843 Setting the files as described above doesn't i    843 Setting the files as described above doesn't incur effect unless you explicitly
844 start the monitoring.  You can start, stop, an    844 start the monitoring.  You can start, stop, and check the current status of the
845 monitoring by writing to and reading from the     845 monitoring by writing to and reading from the ``monitor_on_DEPRECATED`` file.
846 Writing ``on`` to the file starts the monitori    846 Writing ``on`` to the file starts the monitoring of the targets with the
847 attributes.  Writing ``off`` to the file stops    847 attributes.  Writing ``off`` to the file stops those.  DAMON also stops if
848 every target process is terminated.  Below exa    848 every target process is terminated.  Below example commands turn on, off, and
849 check the status of DAMON::                       849 check the status of DAMON::
850                                                   850 
851     # cd <debugfs>/damon                          851     # cd <debugfs>/damon
852     # echo on > monitor_on_DEPRECATED             852     # echo on > monitor_on_DEPRECATED
853     # echo off > monitor_on_DEPRECATED            853     # echo off > monitor_on_DEPRECATED
854     # cat monitor_on_DEPRECATED                   854     # cat monitor_on_DEPRECATED
855     off                                           855     off
856                                                   856 
857 Please note that you cannot write to the above    857 Please note that you cannot write to the above-mentioned debugfs files while
858 the monitoring is turned on.  If you write to     858 the monitoring is turned on.  If you write to the files while DAMON is running,
859 an error code such as ``-EBUSY`` will be retur    859 an error code such as ``-EBUSY`` will be returned.
860                                                   860 
861                                                   861 
862 Monitoring Thread PID                             862 Monitoring Thread PID
863 ---------------------                             863 ---------------------
864                                                   864 
865 DAMON does requested monitoring with a kernel     865 DAMON does requested monitoring with a kernel thread called ``kdamond``.  You
866 can get the pid of the thread by reading the `    866 can get the pid of the thread by reading the ``kdamond_pid`` file.  When the
867 monitoring is turned off, reading the file ret    867 monitoring is turned off, reading the file returns ``none``. ::
868                                                   868 
869     # cd <debugfs>/damon                          869     # cd <debugfs>/damon
870     # cat monitor_on_DEPRECATED                   870     # cat monitor_on_DEPRECATED
871     off                                           871     off
872     # cat kdamond_pid                             872     # cat kdamond_pid
873     none                                          873     none
874     # echo on > monitor_on_DEPRECATED             874     # echo on > monitor_on_DEPRECATED
875     # cat kdamond_pid                             875     # cat kdamond_pid
876     18594                                         876     18594
877                                                   877 
878                                                   878 
879 Using Multiple Monitoring Threads                 879 Using Multiple Monitoring Threads
880 ---------------------------------                 880 ---------------------------------
881                                                   881 
882 One ``kdamond`` thread is created for each mon    882 One ``kdamond`` thread is created for each monitoring context.  You can create
883 and remove monitoring contexts for multiple ``    883 and remove monitoring contexts for multiple ``kdamond`` required use case using
884 the ``mk_contexts`` and ``rm_contexts`` files.    884 the ``mk_contexts`` and ``rm_contexts`` files.
885                                                   885 
886 Writing the name of the new context to the ``m    886 Writing the name of the new context to the ``mk_contexts`` file creates a
887 directory of the name on the DAMON debugfs dir    887 directory of the name on the DAMON debugfs directory.  The directory will have
888 DAMON debugfs files for the context. ::           888 DAMON debugfs files for the context. ::
889                                                   889 
890     # cd <debugfs>/damon                          890     # cd <debugfs>/damon
891     # ls foo                                      891     # ls foo
892     # ls: cannot access 'foo': No such file or    892     # ls: cannot access 'foo': No such file or directory
893     # echo foo > mk_contexts                      893     # echo foo > mk_contexts
894     # ls foo                                      894     # ls foo
895     # attrs  init_regions  kdamond_pid  scheme    895     # attrs  init_regions  kdamond_pid  schemes  target_ids
896                                                   896 
897 If the context is not needed anymore, you can     897 If the context is not needed anymore, you can remove it and the corresponding
898 directory by putting the name of the context t    898 directory by putting the name of the context to the ``rm_contexts`` file. ::
899                                                   899 
900     # echo foo > rm_contexts                      900     # echo foo > rm_contexts
901     # ls foo                                      901     # ls foo
902     # ls: cannot access 'foo': No such file or    902     # ls: cannot access 'foo': No such file or directory
903                                                   903 
904 Note that ``mk_contexts``, ``rm_contexts``, an    904 Note that ``mk_contexts``, ``rm_contexts``, and ``monitor_on_DEPRECATED`` files
905 are in the root directory only.                   905 are in the root directory only.
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php