mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
c951cd3b89
DAMON's debugfs-based user interface served very well, so far. However, it unnecessarily depends on debugfs, while DAMON is not aimed to be used for only debugging. Also, the interface receives multiple values via one file. For example, schemes file receives 18 values separated by white spaces. As a result, it is ineffient, hard to be used, and difficult to be extended. Especially, keeping backward compatibility of user space tools is getting only challenging. It would be better to implement another reliable and flexible interface and deprecate the debugfs interface in long term. To this end, this commit implements a stub of a part of the new user interface of DAMON using sysfs. Specifically, this commit implements the sysfs control parts for virtual address space monitoring. More specifically, the idea of the new interface is, using directory hierarchies and making one file for one value. The hierarchy that this commit is introducing is as below. In the below figure, parents-children relations are represented with indentations, each directory is having ``/`` suffix, and files in each directory are separated by comma (","). /sys/kernel/mm/damon/admin │ kdamonds/nr_kdamonds │ │ 0/state,pid │ │ │ contexts/nr_contexts │ │ │ │ 0/operations │ │ │ │ │ monitoring_attrs/ │ │ │ │ │ │ intervals/sample_us,aggr_us,update_us │ │ │ │ │ │ nr_regions/min,max │ │ │ │ │ targets/nr_targets │ │ │ │ │ │ 0/pid_target │ │ │ │ │ │ ... │ │ │ │ ... │ │ ... Writing a number <N> to each 'nr' file makes directories of name <0> to <N-1> in the directory of the 'nr' file. That's all this commit does. Writing proper values to relevant files will construct the DAMON contexts, and writing a special keyword, 'on', to 'state' files for each kdamond will ask DAMON to start the constructed contexts. For a short example, using below commands for monitoring virtual address spaces of a given workload is imaginable: # cd /sys/kernel/mm/damon/admin/ # echo 1 > kdamonds/nr_kdamonds # echo 1 > kdamonds/0/contexts/nr_contexts # echo vaddr > kdamonds/0/contexts/0/operations # echo 1 > kdamonds/0/contexts/0/targets/nr_targets # echo $(pidof <workload>) > kdamonds/0/contexts/0/targets/0/pid_target # echo on > kdamonds/0/state Please note that this commit is implementing only the sysfs part stub as abovely mentioned. This commit doesn't implement the special keywords for 'state' files. Following commits will do that. [jiapeng.chong@linux.alibaba.com: fix missing error code in damon_sysfs_attrs_add_dirs()] Link: https://lkml.kernel.org/r/20220302111120.24984-1-jiapeng.chong@linux.alibaba.com Link: https://lkml.kernel.org/r/20220228081314.5770-4-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> Cc: David Rientjes <rientjes@google.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Shuah Khan <skhan@linuxfoundation.org> Cc: Xin Hao <xhao@linux.alibaba.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
96 lines
2.8 KiB
Plaintext
96 lines
2.8 KiB
Plaintext
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
menu "Data Access Monitoring"
|
|
|
|
config DAMON
|
|
bool "DAMON: Data Access Monitoring Framework"
|
|
help
|
|
This builds a framework that allows kernel subsystems to monitor
|
|
access frequency of each memory region. The information can be useful
|
|
for performance-centric DRAM level memory management.
|
|
|
|
See https://damonitor.github.io/doc/html/latest-damon/index.html for
|
|
more information.
|
|
|
|
config DAMON_KUNIT_TEST
|
|
bool "Test for damon" if !KUNIT_ALL_TESTS
|
|
depends on DAMON && KUNIT=y
|
|
default KUNIT_ALL_TESTS
|
|
help
|
|
This builds the DAMON Kunit test suite.
|
|
|
|
For more information on KUnit and unit tests in general, please refer
|
|
to the KUnit documentation.
|
|
|
|
If unsure, say N.
|
|
|
|
config DAMON_VADDR
|
|
bool "Data access monitoring operations for virtual address spaces"
|
|
depends on DAMON && MMU
|
|
select PAGE_IDLE_FLAG
|
|
help
|
|
This builds the default data access monitoring operations for DAMON
|
|
that work for virtual address spaces.
|
|
|
|
config DAMON_PADDR
|
|
bool "Data access monitoring operations for the physical address space"
|
|
depends on DAMON && MMU
|
|
select PAGE_IDLE_FLAG
|
|
help
|
|
This builds the default data access monitoring operations for DAMON
|
|
that works for the physical address space.
|
|
|
|
config DAMON_VADDR_KUNIT_TEST
|
|
bool "Test for DAMON operations" if !KUNIT_ALL_TESTS
|
|
depends on DAMON_VADDR && KUNIT=y
|
|
default KUNIT_ALL_TESTS
|
|
help
|
|
This builds the DAMON virtual addresses operations Kunit test suite.
|
|
|
|
For more information on KUnit and unit tests in general, please refer
|
|
to the KUnit documentation.
|
|
|
|
If unsure, say N.
|
|
|
|
config DAMON_SYSFS
|
|
bool "DAMON sysfs interface"
|
|
depends on DAMON && SYSFS
|
|
help
|
|
This builds the sysfs interface for DAMON. The user space can use
|
|
the interface for arbitrary data access monitoring.
|
|
|
|
config DAMON_DBGFS
|
|
bool "DAMON debugfs interface"
|
|
depends on DAMON_VADDR && DAMON_PADDR && DEBUG_FS
|
|
help
|
|
This builds the debugfs interface for DAMON. The user space admins
|
|
can use the interface for arbitrary data access monitoring.
|
|
|
|
If unsure, say N.
|
|
|
|
config DAMON_DBGFS_KUNIT_TEST
|
|
bool "Test for damon debugfs interface" if !KUNIT_ALL_TESTS
|
|
depends on DAMON_DBGFS && KUNIT=y
|
|
default KUNIT_ALL_TESTS
|
|
help
|
|
This builds the DAMON debugfs interface Kunit test suite.
|
|
|
|
For more information on KUnit and unit tests in general, please refer
|
|
to the KUnit documentation.
|
|
|
|
If unsure, say N.
|
|
|
|
config DAMON_RECLAIM
|
|
bool "Build DAMON-based reclaim (DAMON_RECLAIM)"
|
|
depends on DAMON_PADDR
|
|
help
|
|
This builds the DAMON-based reclamation subsystem. It finds pages
|
|
that not accessed for a long time (cold) using DAMON and reclaim
|
|
those.
|
|
|
|
This is suggested to be used as a proactive and lightweight
|
|
reclamation under light memory pressure, while the traditional page
|
|
scanning-based reclamation is used for heavy pressure.
|
|
|
|
endmenu
|