Commit c6380721 authored by SeongJae Park's avatar SeongJae Park Committed by Linus Torvalds

Docs/DAMON: document physical memory monitoring support

This updates the DAMON documents for the physical memory address space
monitoring support.

Link: https://lkml.kernel.org/r/20211012205711.29216-8-sj@kernel.orgSigned-off-by: default avatarSeongJae Park <sj@kernel.org>
Cc: Amit Shah <amit@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Brendan Higgins <brendanhiggins@google.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: David Rienjes <rientjes@google.com>
Cc: David Woodhouse <dwmw@amazon.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Leonard Foerster <foersleo@amazon.de>
Cc: Marco Elver <elver@google.com>
Cc: Markus Boehme <markubo@amazon.de>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c026291a
...@@ -10,15 +10,16 @@ DAMON provides below three interfaces for different users. ...@@ -10,15 +10,16 @@ DAMON provides below three interfaces for different users.
This is for privileged people such as system administrators who want a This is for privileged people such as system administrators who want a
just-working human-friendly interface. Using this, users can use the DAMON’s just-working human-friendly interface. Using this, users can use the DAMON’s
major features in a human-friendly way. It may not be highly tuned for major features in a human-friendly way. It may not be highly tuned for
special cases, though. It supports only virtual address spaces monitoring. special cases, though. It supports both virtual and physical address spaces
monitoring.
- *debugfs interface.* - *debugfs interface.*
This is for privileged user space programmers who want more optimized use of This is for privileged user space programmers who want more optimized use of
DAMON. Using this, users can use DAMON’s major features by reading DAMON. Using this, users can use DAMON’s major features by reading
from and writing to special debugfs files. Therefore, you can write and use from and writing to special debugfs files. Therefore, you can write and use
your personalized DAMON debugfs wrapper programs that reads/writes the your personalized DAMON debugfs wrapper programs that reads/writes the
debugfs files instead of you. The DAMON user space tool is also a reference debugfs files instead of you. The DAMON user space tool is also a reference
implementation of such programs. It supports only virtual address spaces implementation of such programs. It supports both virtual and physical
monitoring. address spaces monitoring.
- *Kernel Space Programming Interface.* - *Kernel Space Programming Interface.*
This is for kernel space programmers. Using this, users can utilize every This is for kernel space programmers. Using this, users can utilize every
feature of DAMON most flexibly and efficiently by writing kernel space feature of DAMON most flexibly and efficiently by writing kernel space
...@@ -72,20 +73,34 @@ check it again:: ...@@ -72,20 +73,34 @@ check it again::
# cat target_ids # cat target_ids
42 4242 42 4242
Users can also monitor the physical memory address space of the system by
writing a special keyword, "``paddr\n``" to the file. Because physical address
space monitoring doesn't support multiple targets, reading the file will show a
fake value, ``42``, as below::
# cd <debugfs>/damon
# echo paddr > target_ids
# cat target_ids
42
Note that setting the target ids doesn't start the monitoring. Note that setting the target ids doesn't start the monitoring.
Initial Monitoring Target Regions Initial Monitoring Target Regions
--------------------------------- ---------------------------------
In case of the debugfs based monitoring, DAMON automatically sets and updates In case of the virtual address space monitoring, DAMON automatically sets and
the monitoring target regions so that entire memory mappings of target updates the monitoring target regions so that entire memory mappings of target
processes can be covered. However, users can want to limit the monitoring processes can be covered. However, users can want to limit the monitoring
region to specific address ranges, such as the heap, the stack, or specific region to specific address ranges, such as the heap, the stack, or specific
file-mapped area. Or, some users can know the initial access pattern of their file-mapped area. Or, some users can know the initial access pattern of their
workloads and therefore want to set optimal initial regions for the 'adaptive workloads and therefore want to set optimal initial regions for the 'adaptive
regions adjustment'. regions adjustment'.
In contrast, DAMON do not automatically sets and updates the monitoring target
regions in case of physical memory monitoring. Therefore, users should set the
monitoring target regions by themselves.
In such cases, users can explicitly set the initial monitoring target regions In such cases, users can explicitly set the initial monitoring target regions
as they want, by writing proper values to the ``init_regions`` file. Each line as they want, by writing proper values to the ``init_regions`` file. Each line
of the input should represent one region in below form.:: of the input should represent one region in below form.::
......
...@@ -35,13 +35,17 @@ two parts: ...@@ -35,13 +35,17 @@ two parts:
1. Identification of the monitoring target address range for the address space. 1. Identification of the monitoring target address range for the address space.
2. Access check of specific address range in the target space. 2. Access check of specific address range in the target space.
DAMON currently provides the implementation of the primitives for only the DAMON currently provides the implementations of the primitives for the physical
virtual address spaces. Below two subsections describe how it works. and virtual address spaces. Below two subsections describe how those work.
VMA-based Target Address Range Construction VMA-based Target Address Range Construction
------------------------------------------- -------------------------------------------
This is only for the virtual address space primitives implementation. That for
the physical address space simply asks users to manually set the monitoring
target address ranges.
Only small parts in the super-huge virtual address space of the processes are Only small parts in the super-huge virtual address space of the processes are
mapped to the physical memory and accessed. Thus, tracking the unmapped mapped to the physical memory and accessed. Thus, tracking the unmapped
address regions is just wasteful. However, because DAMON can deal with some address regions is just wasteful. However, because DAMON can deal with some
...@@ -71,15 +75,18 @@ to make a reasonable trade-off. Below shows this in detail:: ...@@ -71,15 +75,18 @@ to make a reasonable trade-off. Below shows this in detail::
PTE Accessed-bit Based Access Check PTE Accessed-bit Based Access Check
----------------------------------- -----------------------------------
The implementation for the virtual address space uses PTE Accessed-bit for Both of the implementations for physical and virtual address spaces use PTE
basic access checks. It finds the relevant PTE Accessed bit from the address Accessed-bit for basic access checks. Only one difference is the way of
by walking the page table for the target task of the address. In this way, the finding the relevant PTE Accessed bit(s) from the address. While the
implementation finds and clears the bit for next sampling target address and implementation for the virtual address walks the page table for the target task
checks whether the bit set again after one sampling period. This could disturb of the address, the implementation for the physical address walks every page
other kernel subsystems using the Accessed bits, namely Idle page tracking and table having a mapping to the address. In this way, the implementations find
the reclaim logic. To avoid such disturbances, DAMON makes it mutually and clear the bit(s) for next sampling target address and checks whether the
exclusive with Idle page tracking and uses ``PG_idle`` and ``PG_young`` page bit(s) set again after one sampling period. This could disturb other kernel
flags to solve the conflict with the reclaim logic, as Idle page tracking does. subsystems using the Accessed bits, namely Idle page tracking and the reclaim
logic. To avoid such disturbances, DAMON makes it mutually exclusive with Idle
page tracking and uses ``PG_idle`` and ``PG_young`` page flags to solve the
conflict with the reclaim logic, as Idle page tracking does.
Address Space Independent Core Mechanisms Address Space Independent Core Mechanisms
......
...@@ -36,10 +36,9 @@ constructions and actual access checks can be implemented and configured on the ...@@ -36,10 +36,9 @@ constructions and actual access checks can be implemented and configured on the
DAMON core by the users. In this way, DAMON users can monitor any address DAMON core by the users. In this way, DAMON users can monitor any address
space with any access check technique. space with any access check technique.
Nonetheless, DAMON provides vma tracking and PTE Accessed bit check based Nonetheless, DAMON provides vma/rmap tracking and PTE Accessed bit check based
implementations of the address space dependent functions for the virtual memory implementations of the address space dependent functions for the virtual memory
by default, for a reference and convenient use. In near future, we will and the physical memory by default, for a reference and convenient use.
provide those for physical memory address space.
Can I simply monitor page granularity? Can I simply monitor page granularity?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment