Skip to content

Commit 2d33820

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton: "147 patches, based on 7d2a07b. Subsystems affected by this patch series: mm (memory-hotplug, rmap, ioremap, highmem, cleanups, secretmem, kfence, damon, and vmscan), alpha, percpu, procfs, misc, core-kernel, MAINTAINERS, lib, checkpatch, epoll, init, nilfs2, coredump, fork, pids, criu, kconfig, selftests, ipc, and scripts" * emailed patches from Andrew Morton <[email protected]>: (94 commits) scripts: check_extable: fix typo in user error message mm/workingset: correct kernel-doc notations ipc: replace costly bailout check in sysvipc_find_ipc() selftests/memfd: remove unused variable Kconfig.debug: drop selecting non-existing HARDLOCKUP_DETECTOR_ARCH configs: remove the obsolete CONFIG_INPUT_POLLDEV prctl: allow to setup brk for et_dyn executables pid: cleanup the stale comment mentioning pidmap_init(). kernel/fork.c: unexport get_{mm,task}_exe_file coredump: fix memleak in dump_vma_snapshot() fs/coredump.c: log if a core dump is aborted due to changed file permissions nilfs2: use refcount_dec_and_lock() to fix potential UAF nilfs2: fix memory leak in nilfs_sysfs_delete_snapshot_group nilfs2: fix memory leak in nilfs_sysfs_create_snapshot_group nilfs2: fix memory leak in nilfs_sysfs_delete_##name##_group nilfs2: fix memory leak in nilfs_sysfs_create_##name##_group nilfs2: fix NULL pointer in nilfs_##name##_attr_release nilfs2: fix memory leak in nilfs_sysfs_create_device_group trap: cleanup trap_init() init: move usermodehelper_enable() to populate_rootfs() ...
2 parents cc09ee8 + b285437 commit 2d33820

File tree

149 files changed

+5341
-930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+5341
-930
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
========================
4+
Monitoring Data Accesses
5+
========================
6+
7+
:doc:`DAMON </vm/damon/index>` allows light-weight data access monitoring.
8+
Using DAMON, users can analyze the memory access patterns of their systems and
9+
optimize those.
10+
11+
.. toctree::
12+
:maxdepth: 2
13+
14+
start
15+
usage
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
===============
4+
Getting Started
5+
===============
6+
7+
This document briefly describes how you can use DAMON by demonstrating its
8+
default user space tool. Please note that this document describes only a part
9+
of its features for brevity. Please refer to :doc:`usage` for more details.
10+
11+
12+
TL; DR
13+
======
14+
15+
Follow the commands below to monitor and visualize the memory access pattern of
16+
your workload. ::
17+
18+
# # build the kernel with CONFIG_DAMON_*=y, install it, and reboot
19+
# mount -t debugfs none /sys/kernel/debug/
20+
# git clone https://github.com/awslabs/damo
21+
# ./damo/damo record $(pidof <your workload>)
22+
# ./damo/damo report heat --plot_ascii
23+
24+
The final command draws the access heatmap of ``<your workload>``. The heatmap
25+
shows which memory region (x-axis) is accessed when (y-axis) and how frequently
26+
(number; the higher the more accesses have been observed). ::
27+
28+
111111111111111111111111111111111111111111111111111111110000
29+
111121111111111111111111111111211111111111111111111111110000
30+
000000000000000000000000000000000000000000000000001555552000
31+
000000000000000000000000000000000000000000000222223555552000
32+
000000000000000000000000000000000000000011111677775000000000
33+
000000000000000000000000000000000000000488888000000000000000
34+
000000000000000000000000000000000177888400000000000000000000
35+
000000000000000000000000000046666522222100000000000000000000
36+
000000000000000000000014444344444300000000000000000000000000
37+
000000000000000002222245555510000000000000000000000000000000
38+
# access_frequency: 0 1 2 3 4 5 6 7 8 9
39+
# x-axis: space (140286319947776-140286426374096: 101.496 MiB)
40+
# y-axis: time (605442256436361-605479951866441: 37.695430s)
41+
# resolution: 60x10 (1.692 MiB and 3.770s for each character)
42+
43+
44+
Prerequisites
45+
=============
46+
47+
Kernel
48+
------
49+
50+
You should first ensure your system is running on a kernel built with
51+
``CONFIG_DAMON_*=y``.
52+
53+
54+
User Space Tool
55+
---------------
56+
57+
For the demonstration, we will use the default user space tool for DAMON,
58+
called DAMON Operator (DAMO). It is available at
59+
https://github.com/awslabs/damo. The examples below assume that ``damo`` is on
60+
your ``$PATH``. It's not mandatory, though.
61+
62+
Because DAMO is using the debugfs interface (refer to :doc:`usage` for the
63+
detail) of DAMON, you should ensure debugfs is mounted. Mount it manually as
64+
below::
65+
66+
# mount -t debugfs none /sys/kernel/debug/
67+
68+
or append the following line to your ``/etc/fstab`` file so that your system
69+
can automatically mount debugfs upon booting::
70+
71+
debugfs /sys/kernel/debug debugfs defaults 0 0
72+
73+
74+
Recording Data Access Patterns
75+
==============================
76+
77+
The commands below record the memory access patterns of a program and save the
78+
monitoring results to a file. ::
79+
80+
$ git clone https://github.com/sjp38/masim
81+
$ cd masim; make; ./masim ./configs/zigzag.cfg &
82+
$ sudo damo record -o damon.data $(pidof masim)
83+
84+
The first two lines of the commands download an artificial memory access
85+
generator program and run it in the background. The generator will repeatedly
86+
access two 100 MiB sized memory regions one by one. You can substitute this
87+
with your real workload. The last line asks ``damo`` to record the access
88+
pattern in the ``damon.data`` file.
89+
90+
91+
Visualizing Recorded Patterns
92+
=============================
93+
94+
The following three commands visualize the recorded access patterns and save
95+
the results as separate image files. ::
96+
97+
$ damo report heats --heatmap access_pattern_heatmap.png
98+
$ damo report wss --range 0 101 1 --plot wss_dist.png
99+
$ damo report wss --range 0 101 1 --sortby time --plot wss_chron_change.png
100+
101+
- ``access_pattern_heatmap.png`` will visualize the data access pattern in a
102+
heatmap, showing which memory region (y-axis) got accessed when (x-axis)
103+
and how frequently (color).
104+
- ``wss_dist.png`` will show the distribution of the working set size.
105+
- ``wss_chron_change.png`` will show how the working set size has
106+
chronologically changed.
107+
108+
You can view the visualizations of this example workload at [1]_.
109+
Visualizations of other realistic workloads are available at [2]_ [3]_ [4]_.
110+
111+
.. [1] https://damonitor.github.io/doc/html/v17/admin-guide/mm/damon/start.html#visualizing-recorded-patterns
112+
.. [2] https://damonitor.github.io/test/result/visual/latest/rec.heatmap.1.png.html
113+
.. [3] https://damonitor.github.io/test/result/visual/latest/rec.wss_sz.png.html
114+
.. [4] https://damonitor.github.io/test/result/visual/latest/rec.wss_time.png.html
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
===============
4+
Detailed Usages
5+
===============
6+
7+
DAMON provides below three interfaces for different users.
8+
9+
- *DAMON user space tool.*
10+
This is for privileged people such as system administrators who want a
11+
just-working human-friendly interface. Using this, users can use the DAMON’s
12+
major features in a human-friendly way. It may not be highly tuned for
13+
special cases, though. It supports only virtual address spaces monitoring.
14+
- *debugfs interface.*
15+
This is for privileged user space programmers who want more optimized use of
16+
DAMON. Using this, users can use DAMON’s major features by reading
17+
from and writing to special debugfs files. Therefore, you can write and use
18+
your personalized DAMON debugfs wrapper programs that reads/writes the
19+
debugfs files instead of you. The DAMON user space tool is also a reference
20+
implementation of such programs. It supports only virtual address spaces
21+
monitoring.
22+
- *Kernel Space Programming Interface.*
23+
This is for kernel space programmers. Using this, users can utilize every
24+
feature of DAMON most flexibly and efficiently by writing kernel space
25+
DAMON application programs for you. You can even extend DAMON for various
26+
address spaces.
27+
28+
Nevertheless, you could write your own user space tool using the debugfs
29+
interface. A reference implementation is available at
30+
https://github.com/awslabs/damo. If you are a kernel programmer, you could
31+
refer to :doc:`/vm/damon/api` for the kernel space programming interface. For
32+
the reason, this document describes only the debugfs interface
33+
34+
debugfs Interface
35+
=================
36+
37+
DAMON exports three files, ``attrs``, ``target_ids``, and ``monitor_on`` under
38+
its debugfs directory, ``<debugfs>/damon/``.
39+
40+
41+
Attributes
42+
----------
43+
44+
Users can get and set the ``sampling interval``, ``aggregation interval``,
45+
``regions update interval``, and min/max number of monitoring target regions by
46+
reading from and writing to the ``attrs`` file. To know about the monitoring
47+
attributes in detail, please refer to the :doc:`/vm/damon/design`. For
48+
example, below commands set those values to 5 ms, 100 ms, 1,000 ms, 10 and
49+
1000, and then check it again::
50+
51+
# cd <debugfs>/damon
52+
# echo 5000 100000 1000000 10 1000 > attrs
53+
# cat attrs
54+
5000 100000 1000000 10 1000
55+
56+
57+
Target IDs
58+
----------
59+
60+
Some types of address spaces supports multiple monitoring target. For example,
61+
the virtual memory address spaces monitoring can have multiple processes as the
62+
monitoring targets. Users can set the targets by writing relevant id values of
63+
the targets to, and get the ids of the current targets by reading from the
64+
``target_ids`` file. In case of the virtual address spaces monitoring, the
65+
values should be pids of the monitoring target processes. For example, below
66+
commands set processes having pids 42 and 4242 as the monitoring targets and
67+
check it again::
68+
69+
# cd <debugfs>/damon
70+
# echo 42 4242 > target_ids
71+
# cat target_ids
72+
42 4242
73+
74+
Note that setting the target ids doesn't start the monitoring.
75+
76+
77+
Turning On/Off
78+
--------------
79+
80+
Setting the files as described above doesn't incur effect unless you explicitly
81+
start the monitoring. You can start, stop, and check the current status of the
82+
monitoring by writing to and reading from the ``monitor_on`` file. Writing
83+
``on`` to the file starts the monitoring of the targets with the attributes.
84+
Writing ``off`` to the file stops those. DAMON also stops if every target
85+
process is terminated. Below example commands turn on, off, and check the
86+
status of DAMON::
87+
88+
# cd <debugfs>/damon
89+
# echo on > monitor_on
90+
# echo off > monitor_on
91+
# cat monitor_on
92+
off
93+
94+
Please note that you cannot write to the above-mentioned debugfs files while
95+
the monitoring is turned on. If you write to the files while DAMON is running,
96+
an error code such as ``-EBUSY`` will be returned.
97+
98+
99+
Tracepoint for Monitoring Results
100+
=================================
101+
102+
DAMON provides the monitoring results via a tracepoint,
103+
``damon:damon_aggregated``. While the monitoring is turned on, you could
104+
record the tracepoint events and show results using tracepoint supporting tools
105+
like ``perf``. For example::
106+
107+
# echo on > monitor_on
108+
# perf record -e damon:damon_aggregated &
109+
# sleep 5
110+
# kill 9 $(pidof perf)
111+
# echo off > monitor_on
112+
# perf script

Documentation/admin-guide/mm/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ the Linux memory management.
2727

2828
concepts
2929
cma_debugfs
30+
damon/index
3031
hugetlbpage
3132
idle_page_tracking
3233
ksm

0 commit comments

Comments
 (0)