brintos

brintos / linux-shallow public Read only

0
0
Text · 5.9 KiB · 57d36bf Raw
126 lines · plain
1.. SPDX-License-Identifier: GPL-2.02.. include:: ../../../disclaimer-zh_TW.rst3 4:Original: Documentation/admin-guide/mm/damon/start.rst5 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/masim46    $ 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 stdout61    2222222222222222222222222222222222222221111111111111111111111111111111111111110062    4444444444444444444444444444444444444443444444444444444444444444444444444444320063    4444444444444444444444444444444444444443344444444444444444444444444444444444420064    3333333333333333333333333333333333333334455555555555555555555555555555555555520065    3333333333333333333333333333333333334444444444444444444444444444444444444444420066    2222222222222222222222222222222222222335555555555555555555555555555555555555520067    0000000000000000000000000000000000000028888888888888888888888888888888888888840068    0000000000000000000000000000000000000028888888888888888888888888888888888888840069    3333333333333333333333333333333333333335555555555555555555555555555555555555520070    8888888888888888888888888888888888888860000000000000000000000000000000000000000071    8888888888888888888888888888888888888860000000000000000000000000000000000000000072    3333333333333333333333333333333333333344444444444444444444444444444444444444320073    0000000000000000000000000000000000000028888888888888888888888888888888888888840074    [...]75    # access_frequency:  0  1  2  3  4  5  6  7  8  976    # 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 1083    # <percentile> <wss>84    # target_id     1844663210378944307285    # avr:  107.708 MiB86      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 time101    # <percentile> <wss>102    # target_id     18446632103789443072103    # avr:  107.708 MiB104      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_scheme123    $ echo "4K        max      0       0       60s     max     pageout" >> test_scheme124    $ damo schemes -c test_scheme <pid of your workload>125 126