Skip to content

Commit 995d739

Browse files
sjp38torvalds
authored andcommitted
Docs/admin-guide/mm/damon/usage: update for kdamond_pid and (mk|rm)_contexts
The DAMON debugfs usage document is missing descriptions for 'kdamond_pid', 'mk_contexts', and 'rm_contexts' debugfs files. This commit adds those. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: SeongJae Park <[email protected]> Cc: Jonathan Corbet <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4492bf4 commit 995d739

File tree

1 file changed

+49
-3
lines changed

1 file changed

+49
-3
lines changed

Documentation/admin-guide/mm/damon/usage.rst

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ DAMON provides below three interfaces for different users.
3838
debugfs Interface
3939
=================
4040

41-
DAMON exports five files, ``attrs``, ``target_ids``, ``init_regions``,
42-
``schemes`` and ``monitor_on`` under its debugfs directory,
43-
``<debugfs>/damon/``.
41+
DAMON exports eight files, ``attrs``, ``target_ids``, ``init_regions``,
42+
``schemes``, ``monitor_on``, ``kdamond_pid``, ``mk_contexts`` and
43+
``rm_contexts`` under its debugfs directory, ``<debugfs>/damon/``.
4444

4545

4646
Attributes
@@ -273,6 +273,52 @@ the monitoring is turned on. If you write to the files while DAMON is running,
273273
an error code such as ``-EBUSY`` will be returned.
274274

275275

276+
Monitoring Thread PID
277+
---------------------
278+
279+
DAMON does requested monitoring with a kernel thread called ``kdamond``. You
280+
can get the pid of the thread by reading the ``kdamond_pid`` file. When the
281+
monitoring is turned off, reading the file returns ``none``. ::
282+
283+
# cd <debugfs>/damon
284+
# cat monitor_on
285+
off
286+
# cat kdamond_pid
287+
none
288+
# echo on > monitor_on
289+
# cat kdamond_pid
290+
18594
291+
292+
293+
Using Multiple Monitoring Threads
294+
---------------------------------
295+
296+
One ``kdamond`` thread is created for each monitoring context. You can create
297+
and remove monitoring contexts for multiple ``kdamond`` required use case using
298+
the ``mk_contexts`` and ``rm_contexts`` files.
299+
300+
Writing the name of the new context to the ``mk_contexts`` file creates a
301+
directory of the name on the DAMON debugfs directory. The directory will have
302+
DAMON debugfs files for the context. ::
303+
304+
# cd <debugfs>/damon
305+
# ls foo
306+
# ls: cannot access 'foo': No such file or directory
307+
# echo foo > mk_contexts
308+
# ls foo
309+
# attrs init_regions kdamond_pid schemes target_ids
310+
311+
If the context is not needed anymore, you can remove it and the corresponding
312+
directory by putting the name of the context to the ``rm_contexts`` file. ::
313+
314+
# echo foo > rm_contexts
315+
# ls foo
316+
# ls: cannot access 'foo': No such file or directory
317+
318+
Note that ``mk_contexts``, ``rm_contexts``, and ``monitor_on`` files are in the
319+
root directory only.
320+
321+
276322
.. _tracepoint:
277323

278324
Tracepoint for Monitoring Results

0 commit comments

Comments
 (0)