From 60a7e9e94e49215b1e6ac6e33b69c3bd0a426b5e Mon Sep 17 00:00:00 2001 From: Gerald Schaefer Date: Wed, 27 Sep 2017 19:44:44 +0200 Subject: lsmem/chmem: add memory zone awareness With this patch, valid memory zones can be shown with lsmem, and chmem can set memory online/offline in a specific memory zone, if allowed by the kernel. The valid memory zones are read from the "valid_zones" sysfs attribute, and setting memory online to a specific zone is done by echoing "online_kernel" or "online_movable" to the "state" sysfs attribute, in addition to the previous "online". This patch also changes the default behavior of chmem, when setting memory online without specifying a memory zone. If valid, memory will be set online to the zone Movable. This zone is preferable for memory hotplug, as it makes memory offline much more likely to succeed. Signed-off-by: Gerald Schaefer --- sys-utils/chmem.8 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sys-utils/chmem.8') diff --git a/sys-utils/chmem.8 b/sys-utils/chmem.8 index a116bc9e7..dae7413d4 100644 --- a/sys-utils/chmem.8 +++ b/sys-utils/chmem.8 @@ -5,6 +5,7 @@ chmem \- configure memory .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. . @@ -25,6 +26,19 @@ and 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. @@ -51,6 +65,11 @@ Set the specified \fIRANGE\fP, \fISIZE\fP, or \fIBLOCKRANGE\fP of memory offline .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 -- cgit v1.2.3-55-g7522