summaryrefslogtreecommitdiffstats
path: root/sys-utils/chmem.8
blob: 8a3b34d5edd90c396e6f1ce8d124983c6c88f9da (plain) (blame)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
.TH CHMEM 8 "October 2016" "util-linux" "System Administration"
.SH NAME
chmem \- configure memory
.SH SYNOPSIS
.B chmem
.RB [ \-h "] [" \-V "] [" \-v "] [" \-e | \-d "]"
[\fISIZE\fP|\fIRANGE\fP|\fB\-b\fP \fIBLOCKRANGE\fP]
[-z ZONE]
.SH DESCRIPTION
The chmem command sets a particular size or range of memory online or offline.
.
.IP "\(hy" 2
Specify \fISIZE\fP as <size>[m|M|g|G]. With m or M, <size> specifies the memory
size in MiB (1024 x 1024 bytes). With g or G, <size> specifies the memory size
in GiB (1024 x 1024 x 1024 bytes). The default unit is MiB.
.
.IP "\(hy" 2
Specify \fIRANGE\fP in the form 0x<start>-0x<end> as shown in the output of the
\fBlsmem\fP command. <start> is the hexadecimal address of the first byte and <end>
is the hexadecimal address of the last byte in the memory range.
.
.IP "\(hy" 2
Specify \fIBLOCKRANGE\fP in the form <first>-<last> or <block> as shown in the
output of the \fBlsmem\fP command. <first> is the number of the first memory block
and <last> is the number of the last memory block in the memory
range. Alternatively a single block can be specified. \fIBLOCKRANGE\fP requires
the \fB--blocks\fP option.
.
.IP "\(hy" 2
Specify \fIZONE\fP as the name of a memory zone, as shown in the output of the
\fBlsmem -o +ZONES\fP command. The output shows one or more valid memory zones
for each memory range. If multiple zones are shown, then the memory range
currently belongs to the first zone. By default, chmem will set memory online
to the zone Movable, if this is among the valid zones. This default can be
changed by specifying the \fB--zone\fP option with another valid zone.
For memory ballooning, it is recommended to select the zone Movable for memory
online and offline, if possible. Memory in this zone is much more likely to be
able to be offlined again, but it cannot be used for arbitrary kernel
allocations, only for migratable pages (e.g. anonymous and page cache pages).
Use the \fB\-\-help\fR option to see all available zones.
.
.PP
\fISIZE\fP and \fIRANGE\fP must be aligned to the Linux memory block size, as
shown in the output of the \fBlsmem\fP command.

Setting memory online can fail for various reasons. On virtualized systems it
can fail if the hypervisor does not have enough memory left, for example
because memory was overcommitted. Setting memory offline can fail if Linux
cannot free the memory. If only part of the requested memory can be set online
or offline, a message tells you how much memory was set online or offline
instead of the requested amount.

When setting memory online \fBchmem\fP starts with the lowest memory block
numbers. When setting memory offline \fBchmem\fP starts with the highest memory
block numbers.
.SH OPTIONS
.TP
.BR \-b ", " \-\-blocks
Use a \fIBLOCKRANGE\fP parameter instead of \fIRANGE\fP or \fISIZE\fP for the
\fB--enable\fP and \fB--disable\fP options.
.TP
.BR \-d ", " \-\-disable
Set the specified \fIRANGE\fP, \fISIZE\fP, or \fIBLOCKRANGE\fP of memory offline.
.TP
.BR \-e ", " \-\-enable
Set the specified \fIRANGE\fP, \fISIZE\fP, or \fIBLOCKRANGE\fP of memory online.
.TP
.BR \-z ", " \-\-zone
Select the memory \fIZONE\fP where to set the specified \fIRANGE\fP, \fISIZE\fP,
or \fIBLOCKRANGE\fP of memory online or offline. By default, memory will be set
online to the zone Movable, if possible.
.TP
.BR \-h ", " \-\-help
Print a short help text, then exit.
.TP
.BR \-v ", " \-\-verbose
Verbose mode. Causes \fBchmem\fP to print debugging messages about it's
progress.
.TP
.BR \-V ", " \-\-version
Print the version number, then exit.
.SH RETURN CODES
.B chmem
has the following return codes:
.TP
.B 0
success
.TP
.B 1
failure
.TP
.B 64
partial success
.SH EXAMPLES
.TP
.B chmem --enable 1024
This command requests 1024 MiB of memory to be set online.
.TP
.B chmem -e 2g
This command requests 2 GiB of memory to be set online.
.TP
.B chmem --disable 0x00000000e4000000-0x00000000f3ffffff
This command requests the memory range starting with 0x00000000e4000000
and ending with 0x00000000f3ffffff to be set offline.
.TP
.B chmem -b -d 10
This command requests the memory block number 10 to be set offline.
.SH SEE ALSO
.BR lsmem (1)
.SH AVAILABILITY
The \fBchmem\fP command is part of the util-linux package and is available from
.UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
Linux Kernel Archive
.UE .