File Index
Files and directories
Sign in
FILE

start.rst

File preview with syntax highlighting.

linux-6.19.14/Documentation/translations/zh_CN/admin-guide/mm/damon/start.rst RESTRUCTUREDTEXT
  1.. SPDX-License-Identifier: GPL-2.0
  2.. include:: ../../../disclaimer-zh_CN.rst
  3
  4:Original: Documentation/admin-guide/mm/damon/start.rst
  5
  6:翻译:
  7
  8 司延腾 Yanteng Si <siyanteng@loongson.cn>
  9
 10:校译:
 11
 12========
 13入门指南
 14========
 15
 16本文通过演示DAMON的默认用户空间工具,简要地介绍了如何使用DAMON。请注意,为了简洁
 17起见,本文档只描述了它的部分功能。更多细节请参考该工具的使用文档。
 18`doc <https://github.com/damonitor/damo/blob/next/USAGE.md>`_ .
 19
 20
 21前提条件
 22========
 23
 24内核
 25----
 26
 27首先,你要确保你当前系统中跑的内核构建时选定了这个功能选项 ``CONFIG_DAMON_*=y``.
 28
 29
 30用户空间工具
 31------------
 32
 33在演示中,我们将使用DAMON的默认用户空间工具,称为DAMON Operator(DAMO)。它可以在
 34https://github.com/damonitor/damo找到。下面的例子假设DAMO在你的$PATH上。当然,但
 35这并不是强制性的。
 36
 37因为DAMO使用了DAMON的sysfs接口(详情请参考:doc:`usage`),你应该确保
 38:doc:`sysfs </filesystems/sysfs>` 被挂载。
 39
 40记录数据访问模式
 41================
 42
 43下面的命令记录了一个程序的内存访问模式,并将监测结果保存到文件中。 ::
 44
 45    $ git clone https://github.com/sjp38/masim
 46    $ cd masim; make; ./masim ./configs/zigzag.cfg &
 47    $ sudo damo record -o damon.data $(pidof masim)
 48
 49命令的前两行下载了一个人工内存访问生成器程序并在后台运行。生成器将重复地逐一访问两个
 50100 MiB大小的内存区域。你可以用你的真实工作负载来代替它。最后一行要求 ``damo`` 将
 51访问模式记录在 ``damon.data`` 文件中。
 52
 53
 54将记录的模式可视化
 55==================
 56
 57你可以在heatmap中直观地看到这种模式,显示哪个内存区域(X轴)何时被访问(Y轴)以及访
 58问的频率(数字)。::
 59
 60    $ sudo damo report heats --heatmap stdout
 61    22222222222222222222222222222222222222211111111111111111111111111111111111111100
 62    44444444444444444444444444444444444444434444444444444444444444444444444444443200
 63    44444444444444444444444444444444444444433444444444444444444444444444444444444200
 64    33333333333333333333333333333333333333344555555555555555555555555555555555555200
 65    33333333333333333333333333333333333344444444444444444444444444444444444444444200
 66    22222222222222222222222222222222222223355555555555555555555555555555555555555200
 67    00000000000000000000000000000000000000288888888888888888888888888888888888888400
 68    00000000000000000000000000000000000000288888888888888888888888888888888888888400
 69    33333333333333333333333333333333333333355555555555555555555555555555555555555200
 70    88888888888888888888888888888888888888600000000000000000000000000000000000000000
 71    88888888888888888888888888888888888888600000000000000000000000000000000000000000
 72    33333333333333333333333333333333333333444444444444444444444444444444444444443200
 73    00000000000000000000000000000000000000288888888888888888888888888888888888888400
 74    [...]
 75    # access_frequency:  0  1  2  3  4  5  6  7  8  9
 76    # x-axis: space (139728247021568-139728453431248: 196.848 MiB)
 77    # y-axis: time (15256597248362-15326899978162: 1 m 10.303 s)
 78    # resolution: 80x40 (2.461 MiB and 1.758 s for each character)
 79
 80你也可以直观地看到工作集的大小分布,按大小排序。::
 81
 82    $ sudo damo report wss --range 0 101 10
 83    # <percentile> <wss>
 84    # target_id     18446632103789443072
 85    # avr:  107.708 MiB
 86      0             0 B |                                                           |
 87     10      95.328 MiB |****************************                               |
 88     20      95.332 MiB |****************************                               |
 89     30      95.340 MiB |****************************                               |
 90     40      95.387 MiB |****************************                               |
 91     50      95.387 MiB |****************************                               |
 92     60      95.398 MiB |****************************                               |
 93     70      95.398 MiB |****************************                               |
 94     80      95.504 MiB |****************************                               |
 95     90     190.703 MiB |*********************************************************  |
 96    100     196.875 MiB |***********************************************************|
 97
 98在上述命令中使用 ``--sortby`` 选项,可以显示工作集的大小是如何按时间顺序变化的。::
 99
100    $ sudo damo report wss --range 0 101 10 --sortby time
101    # <percentile> <wss>
102    # target_id     18446632103789443072
103    # avr:  107.708 MiB
104      0       3.051 MiB |                                                           |
105     10     190.703 MiB |***********************************************************|
106     20      95.336 MiB |*****************************                              |
107     30      95.328 MiB |*****************************                              |
108     40      95.387 MiB |*****************************                              |
109     50      95.332 MiB |*****************************                              |
110     60      95.320 MiB |*****************************                              |
111     70      95.398 MiB |*****************************                              |
112     80      95.398 MiB |*****************************                              |
113     90      95.340 MiB |*****************************                              |
114    100      95.398 MiB |*****************************                              |
115
116
117数据访问模式感知的内存管理
118==========================
119
120以下三个命令使每一个大小>=4K的内存区域在你的工作负载中没有被访问>=60秒,就会被换掉。 ::
121
122    $ echo "#min-size max-size min-acc max-acc min-age max-age action" > test_scheme
123    $ echo "4K        max      0       0       60s     max     pageout" >> test_scheme
124    $ damo schemes -c test_scheme <pid of your workload>
~/ Read-only file preview.