Repository navigation
Expand file tree
/
Copy pathmem_tier.sh
More file actions
53 lines (48 loc) · 2.05 KB
/
Copy pathmem_tier.sh
File metadata and controls
53 lines (48 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# This script shows example usage of damo for access-aware tiered memory
# management. The script assumes the system has two NUMA nodes of id 0 and 1,
# and node 0 is faster than node 1, for all CPUs. The script asks DAMON to
# migrate hot pages in node 1 to node 0 (promote), while migrating cold pages
# in node 0 to node 1 (demote). The hotness and coldness thresholds are
# auto-tuned aiming ~99.6 percent of node 0 memory utilization. The basic idea
# behind the tiering policy is came from TPP[1]. This script is also
# implemented for DAMON's auto-tune based memory tiering support[2].
#
# To run this, the kernel should have the auto-tuned memory tiering support of
# DAMON[2], which was landed into the mainline since v6.16-rc1.
#
# [1] https://dl.acm.org/doi/10.1145/3582016.3582063
# [2] https://lkml.kernel.org/r/20250420194030.75838-1-sj@kernel.org
set -e
bindir=$(realpath $(dirname "$0"))
damo_bin="$bindir/../damo"
if [ ! -f "$damo_bin" ]
then
echo "damo not found at $damo_bin"
exit 1
fi
"$damo_bin" module stat write enabled N
"$damo_bin" start \
` # demote cold memory from node 0 to node 1 ` \
--kdamond --damon_ctx --monitoring_intervals_goal 4% 3 5ms 10s \
--damon_target --numa_node 0 \
--damos_scheme \
--damos_action migrate_cold 1 \
--damos_access_rate 0% 0% --damos_apply_interval 1s \
` # up to 200 MB per second ` \
--damos_quota_interval 1s --damos_quota_space 200MB \
` # aiming at least 0.5% node 0 free memory ` \
--damos_quota_goal node_mem_free_bp 0.5% 0 \
--damos_filter reject young \
` # promote hot memory from node 1 to node 0 ` \
--kdamond --damon_ctx --monitoring_intervals_goal 4% 3 5ms 10s \
--damon_target --numa_node 1 \
--damos_scheme \
--damos_action migrate_hot 0 \
--damos_access_rate 5% max --damos_apply_interval 1s \
` # up to 200 MB per second ` \
--damos_quota_interval 1s --damos_quota_space 200MB \
` # aiming at least 99.7% node 0 memory utilization ` \
--damos_quota_goal node_mem_used_bp 99.7% 0 \
--damos_filter allow young \