Skip to content

Commit 512b793

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge misc updates from Andrew Morton: "257 patches. Subsystems affected by this patch series: scripts, ocfs2, vfs, and mm (slab-generic, slab, slub, kconfig, dax, kasan, debug, pagecache, gup, swap, memcg, pagemap, mprotect, mremap, iomap, tracing, vmalloc, pagealloc, memory-failure, hugetlb, userfaultfd, vmscan, tools, memblock, oom-kill, hugetlbfs, migration, thp, readahead, nommu, ksm, vmstat, madvise, memory-hotplug, rmap, zsmalloc, highmem, zram, cleanups, kfence, and damon)" * emailed patches from Andrew Morton <[email protected]>: (257 commits) mm/damon: remove return value from before_terminate callback mm/damon: fix a few spelling mistakes in comments and a pr_debug message mm/damon: simplify stop mechanism Docs/admin-guide/mm/pagemap: wordsmith page flags descriptions Docs/admin-guide/mm/damon/start: simplify the content Docs/admin-guide/mm/damon/start: fix a wrong link Docs/admin-guide/mm/damon/start: fix wrong example commands mm/damon/dbgfs: add adaptive_targets list check before enable monitor_on mm/damon: remove unnecessary variable initialization Documentation/admin-guide/mm/damon: add a document for DAMON_RECLAIM mm/damon: introduce DAMON-based Reclamation (DAMON_RECLAIM) selftests/damon: support watermarks mm/damon/dbgfs: support watermarks mm/damon/schemes: activate schemes based on a watermarks mechanism tools/selftests/damon: update for regions prioritization of schemes mm/damon/dbgfs: support prioritization weights mm/damon/vaddr,paddr: support pageout prioritization mm/damon/schemes: prioritize regions within the quotas mm/damon/selftests: support schemes quotas mm/damon/dbgfs: support quotas of schemes ...
2 parents fe91c47 + 658f9ae commit 512b793

File tree

249 files changed

+6062
-2090
lines changed

Some content is hidden

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

249 files changed

+6062
-2090
lines changed

Documentation/admin-guide/blockdev/zram.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@ as idle::
328328
From now on, any pages on zram are idle pages. The idle mark
329329
will be removed until someone requests access of the block.
330330
IOW, unless there is access request, those pages are still idle pages.
331+
Additionally, when CONFIG_ZRAM_MEMORY_TRACKING is enabled pages can be
332+
marked as idle based on how long (in seconds) it's been since they were
333+
last accessed::
334+
335+
echo 86400 > /sys/block/zramX/idle
336+
337+
In this example all pages which haven't been accessed in more than 86400
338+
seconds (one day) will be marked idle.
331339

332340
Admin can request writeback of those idle pages at right timing via::
333341

Documentation/admin-guide/cgroup-v1/memory.rst

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,8 @@ Brief summary of control files.
8787
memory.oom_control set/show oom controls.
8888
memory.numa_stat show the number of memory usage per numa
8989
node
90-
memory.kmem.limit_in_bytes set/show hard limit for kernel memory
91-
This knob is deprecated and shouldn't be
92-
used. It is planned that this be removed in
93-
the foreseeable future.
90+
memory.kmem.limit_in_bytes This knob is deprecated and writing to
91+
it will return -ENOTSUPP.
9492
memory.kmem.usage_in_bytes show current kernel memory allocation
9593
memory.kmem.failcnt show the number of kernel memory usage
9694
hits limits
@@ -518,11 +516,6 @@ will be charged as a new owner of it.
518516
charged file caches. Some out-of-use page caches may keep charged until
519517
memory pressure happens. If you want to avoid that, force_empty will be useful.
520518

521-
Also, note that when memory.kmem.limit_in_bytes is set the charges due to
522-
kernel pages will still be seen. This is not considered a failure and the
523-
write will still return success. In this case, it is expected that
524-
memory.kmem.usage_in_bytes == memory.usage_in_bytes.
525-
526519
5.2 stat file
527520
-------------
528521

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,8 +1582,10 @@
15821582
registers. Default set by CONFIG_HPET_MMAP_DEFAULT.
15831583

15841584
hugetlb_cma= [HW,CMA] The size of a CMA area used for allocation
1585-
of gigantic hugepages.
1586-
Format: nn[KMGTPE]
1585+
of gigantic hugepages. Or using node format, the size
1586+
of a CMA area per node can be specified.
1587+
Format: nn[KMGTPE] or (node format)
1588+
<node>:nn[KMGTPE][,<node>:nn[KMGTPE]]
15871589

15881590
Reserve a CMA area of given size and allocate gigantic
15891591
hugepages using the CMA allocator. If enabled, the
@@ -1594,9 +1596,11 @@
15941596
the number of pages of hugepagesz to be allocated.
15951597
If this is the first HugeTLB parameter on the command
15961598
line, it specifies the number of pages to allocate for
1597-
the default huge page size. See also
1598-
Documentation/admin-guide/mm/hugetlbpage.rst.
1599-
Format: <integer>
1599+
the default huge page size. If using node format, the
1600+
number of pages to allocate per-node can be specified.
1601+
See also Documentation/admin-guide/mm/hugetlbpage.rst.
1602+
Format: <integer> or (node format)
1603+
<node>:<integer>[,<node>:<integer>]
16001604

16011605
hugepagesz=
16021606
[HW] The size of the HugeTLB pages. This is used in

Documentation/admin-guide/mm/damon/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ optimize those.
1313

1414
start
1515
usage
16+
reclaim
Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
=======================
4+
DAMON-based Reclamation
5+
=======================
6+
7+
DAMON-based Reclamation (DAMON_RECLAIM) is a static kernel module that aimed to
8+
be used for proactive and lightweight reclamation under light memory pressure.
9+
It doesn't aim to replace the LRU-list based page_granularity reclamation, but
10+
to be selectively used for different level of memory pressure and requirements.
11+
12+
Where Proactive Reclamation is Required?
13+
========================================
14+
15+
On general memory over-committed systems, proactively reclaiming cold pages
16+
helps saving memory and reducing latency spikes that incurred by the direct
17+
reclaim of the process or CPU consumption of kswapd, while incurring only
18+
minimal performance degradation [1]_ [2]_ .
19+
20+
Free Pages Reporting [3]_ based memory over-commit virtualization systems are
21+
good example of the cases. In such systems, the guest VMs reports their free
22+
memory to host, and the host reallocates the reported memory to other guests.
23+
As a result, the memory of the systems are fully utilized. However, the
24+
guests could be not so memory-frugal, mainly because some kernel subsystems and
25+
user-space applications are designed to use as much memory as available. Then,
26+
guests could report only small amount of memory as free to host, results in
27+
memory utilization drop of the systems. Running the proactive reclamation in
28+
guests could mitigate this problem.
29+
30+
How It Works?
31+
=============
32+
33+
DAMON_RECLAIM finds memory regions that didn't accessed for specific time
34+
duration and page out. To avoid it consuming too much CPU for the paging out
35+
operation, a speed limit can be configured. Under the speed limit, it pages
36+
out memory regions that didn't accessed longer time first. System
37+
administrators can also configure under what situation this scheme should
38+
automatically activated and deactivated with three memory pressure watermarks.
39+
40+
Interface: Module Parameters
41+
============================
42+
43+
To use this feature, you should first ensure your system is running on a kernel
44+
that is built with ``CONFIG_DAMON_RECLAIM=y``.
45+
46+
To let sysadmins enable or disable it and tune for the given system,
47+
DAMON_RECLAIM utilizes module parameters. That is, you can put
48+
``damon_reclaim.<parameter>=<value>`` on the kernel boot command line or write
49+
proper values to ``/sys/modules/damon_reclaim/parameters/<parameter>`` files.
50+
51+
Note that the parameter values except ``enabled`` are applied only when
52+
DAMON_RECLAIM starts. Therefore, if you want to apply new parameter values in
53+
runtime and DAMON_RECLAIM is already enabled, you should disable and re-enable
54+
it via ``enabled`` parameter file. Writing of the new values to proper
55+
parameter values should be done before the re-enablement.
56+
57+
Below are the description of each parameter.
58+
59+
enabled
60+
-------
61+
62+
Enable or disable DAMON_RECLAIM.
63+
64+
You can enable DAMON_RCLAIM by setting the value of this parameter as ``Y``.
65+
Setting it as ``N`` disables DAMON_RECLAIM. Note that DAMON_RECLAIM could do
66+
no real monitoring and reclamation due to the watermarks-based activation
67+
condition. Refer to below descriptions for the watermarks parameter for this.
68+
69+
min_age
70+
-------
71+
72+
Time threshold for cold memory regions identification in microseconds.
73+
74+
If a memory region is not accessed for this or longer time, DAMON_RECLAIM
75+
identifies the region as cold, and reclaims it.
76+
77+
120 seconds by default.
78+
79+
quota_ms
80+
--------
81+
82+
Limit of time for the reclamation in milliseconds.
83+
84+
DAMON_RECLAIM tries to use only up to this time within a time window
85+
(quota_reset_interval_ms) for trying reclamation of cold pages. This can be
86+
used for limiting CPU consumption of DAMON_RECLAIM. If the value is zero, the
87+
limit is disabled.
88+
89+
10 ms by default.
90+
91+
quota_sz
92+
--------
93+
94+
Limit of size of memory for the reclamation in bytes.
95+
96+
DAMON_RECLAIM charges amount of memory which it tried to reclaim within a time
97+
window (quota_reset_interval_ms) and makes no more than this limit is tried.
98+
This can be used for limiting consumption of CPU and IO. If this value is
99+
zero, the limit is disabled.
100+
101+
128 MiB by default.
102+
103+
quota_reset_interval_ms
104+
-----------------------
105+
106+
The time/size quota charge reset interval in milliseconds.
107+
108+
The charget reset interval for the quota of time (quota_ms) and size
109+
(quota_sz). That is, DAMON_RECLAIM does not try reclamation for more than
110+
quota_ms milliseconds or quota_sz bytes within quota_reset_interval_ms
111+
milliseconds.
112+
113+
1 second by default.
114+
115+
wmarks_interval
116+
---------------
117+
118+
Minimal time to wait before checking the watermarks, when DAMON_RECLAIM is
119+
enabled but inactive due to its watermarks rule.
120+
121+
wmarks_high
122+
-----------
123+
124+
Free memory rate (per thousand) for the high watermark.
125+
126+
If free memory of the system in bytes per thousand bytes is higher than this,
127+
DAMON_RECLAIM becomes inactive, so it does nothing but only periodically checks
128+
the watermarks.
129+
130+
wmarks_mid
131+
----------
132+
133+
Free memory rate (per thousand) for the middle watermark.
134+
135+
If free memory of the system in bytes per thousand bytes is between this and
136+
the low watermark, DAMON_RECLAIM becomes active, so starts the monitoring and
137+
the reclaiming.
138+
139+
wmarks_low
140+
----------
141+
142+
Free memory rate (per thousand) for the low watermark.
143+
144+
If free memory of the system in bytes per thousand bytes is lower than this,
145+
DAMON_RECLAIM becomes inactive, so it does nothing but periodically checks the
146+
watermarks. In the case, the system falls back to the LRU-list based page
147+
granularity reclamation logic.
148+
149+
sample_interval
150+
---------------
151+
152+
Sampling interval for the monitoring in microseconds.
153+
154+
The sampling interval of DAMON for the cold memory monitoring. Please refer to
155+
the DAMON documentation (:doc:`usage`) for more detail.
156+
157+
aggr_interval
158+
-------------
159+
160+
Aggregation interval for the monitoring in microseconds.
161+
162+
The aggregation interval of DAMON for the cold memory monitoring. Please
163+
refer to the DAMON documentation (:doc:`usage`) for more detail.
164+
165+
min_nr_regions
166+
--------------
167+
168+
Minimum number of monitoring regions.
169+
170+
The minimal number of monitoring regions of DAMON for the cold memory
171+
monitoring. This can be used to set lower-bound of the monitoring quality.
172+
But, setting this too high could result in increased monitoring overhead.
173+
Please refer to the DAMON documentation (:doc:`usage`) for more detail.
174+
175+
max_nr_regions
176+
--------------
177+
178+
Maximum number of monitoring regions.
179+
180+
The maximum number of monitoring regions of DAMON for the cold memory
181+
monitoring. This can be used to set upper-bound of the monitoring overhead.
182+
However, setting this too low could result in bad monitoring quality. Please
183+
refer to the DAMON documentation (:doc:`usage`) for more detail.
184+
185+
monitor_region_start
186+
--------------------
187+
188+
Start of target memory region in physical address.
189+
190+
The start physical address of memory region that DAMON_RECLAIM will do work
191+
against. That is, DAMON_RECLAIM will find cold memory regions in this region
192+
and reclaims. By default, biggest System RAM is used as the region.
193+
194+
monitor_region_end
195+
------------------
196+
197+
End of target memory region in physical address.
198+
199+
The end physical address of memory region that DAMON_RECLAIM will do work
200+
against. That is, DAMON_RECLAIM will find cold memory regions in this region
201+
and reclaims. By default, biggest System RAM is used as the region.
202+
203+
kdamond_pid
204+
-----------
205+
206+
PID of the DAMON thread.
207+
208+
If DAMON_RECLAIM is enabled, this becomes the PID of the worker thread. Else,
209+
-1.
210+
211+
Example
212+
=======
213+
214+
Below runtime example commands make DAMON_RECLAIM to find memory regions that
215+
not accessed for 30 seconds or more and pages out. The reclamation is limited
216+
to be done only up to 1 GiB per second to avoid DAMON_RECLAIM consuming too
217+
much CPU time for the paging out operation. It also asks DAMON_RECLAIM to do
218+
nothing if the system's free memory rate is more than 50%, but start the real
219+
works if it becomes lower than 40%. If DAMON_RECLAIM doesn't make progress and
220+
therefore the free memory rate becomes lower than 20%, it asks DAMON_RECLAIM to
221+
do nothing again, so that we can fall back to the LRU-list based page
222+
granularity reclamation. ::
223+
224+
# cd /sys/modules/damon_reclaim/parameters
225+
# echo 30000000 > min_age
226+
# echo $((1 * 1024 * 1024 * 1024)) > quota_sz
227+
# echo 1000 > quota_reset_interval_ms
228+
# echo 500 > wmarks_high
229+
# echo 400 > wmarks_mid
230+
# echo 200 > wmarks_low
231+
# echo Y > enabled
232+
233+
.. [1] https://research.google/pubs/pub48551/
234+
.. [2] https://lwn.net/Articles/787611/
235+
.. [3] https://www.kernel.org/doc/html/latest/vm/free_page_reporting.html

0 commit comments

Comments
 (0)