Skip to content

Commit a89107c

Browse files
davidhildenbrandtorvalds
authored andcommitted
Documentation: sysfs/memory: clarify some memory block device properties
In commit 53cdc1c ("drivers/base/memory.c: indicate all memory blocks as removable") we changed the output of the "removable" property of memory devices to return "1" if and only if the kernel supports memory offlining. Let's update documentation, stating that the interface is legacy. Also update documentation of the "state" property and "valid_zones" properties. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: David Hildenbrand <[email protected]> Acked-by: Michal Hocko <[email protected]> Reviewed-by: Oscar Salvador <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Jonathan Cameron <[email protected]> Cc: Ilya Dryomov <[email protected]> Cc: Mauro Carvalho Chehab <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent e9a2e48 commit a89107c

File tree

2 files changed

+41
-28
lines changed

2 files changed

+41
-28
lines changed

Documentation/ABI/testing/sysfs-devices-memory

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ What: /sys/devices/system/memory/memoryX/removable
1313
Date: June 2008
1414
Contact: Badari Pulavarty <[email protected]>
1515
Description:
16-
The file /sys/devices/system/memory/memoryX/removable
17-
indicates whether this memory block is removable or not.
18-
This is useful for a user-level agent to determine
19-
identify removable sections of the memory before attempting
20-
potentially expensive hot-remove memory operation
16+
The file /sys/devices/system/memory/memoryX/removable is a
17+
legacy interface used to indicated whether a memory block is
18+
likely to be offlineable or not. Newer kernel versions return
19+
"1" if and only if the kernel supports memory offlining.
2120
Users: hotplug memory remove tools
2221
http://www.ibm.com/developerworks/wikis/display/LinuxP/powerpc-utils
22+
lsmem/chmem part of util-linux
2323

2424
What: /sys/devices/system/memory/memoryX/phys_device
2525
Date: September 2008
@@ -44,23 +44,25 @@ Date: September 2008
4444
Contact: Badari Pulavarty <[email protected]>
4545
Description:
4646
The file /sys/devices/system/memory/memoryX/state
47-
is read-write. When read, its contents show the
48-
online/offline state of the memory section. When written,
49-
root can toggle the the online/offline state of a removable
50-
memory section (see removable file description above)
51-
using the following commands::
47+
is read-write. When read, it returns the online/offline
48+
state of the memory block. When written, root can toggle
49+
the online/offline state of a memory block using the following
50+
commands::
5251

5352
# echo online > /sys/devices/system/memory/memoryX/state
5453
# echo offline > /sys/devices/system/memory/memoryX/state
5554

56-
For example, if /sys/devices/system/memory/memory22/removable
57-
contains a value of 1 and
58-
/sys/devices/system/memory/memory22/state contains the
59-
string "online" the following command can be executed by
60-
by root to offline that section::
61-
62-
# echo offline > /sys/devices/system/memory/memory22/state
63-
55+
On newer kernel versions, advanced states can be specified
56+
when onlining to select a target zone: "online_movable"
57+
selects the movable zone. "online_kernel" selects the
58+
applicable kernel zone (DMA, DMA32, or Normal). However,
59+
after successfully setting one of the advanced states,
60+
reading the file will return "online"; the zone information
61+
can be obtained via "valid_zones" instead.
62+
63+
While onlining is unlikely to fail, there are no guarantees
64+
that offlining will succeed. Offlining is more likely to
65+
succeed if "valid_zones" indicates "Movable".
6466
Users: hotplug memory remove tools
6567
http://www.ibm.com/developerworks/wikis/display/LinuxP/powerpc-utils
6668

@@ -70,8 +72,19 @@ Date: July 2014
7072
Contact: Zhang Zhen <[email protected]>
7173
Description:
7274
The file /sys/devices/system/memory/memoryX/valid_zones is
73-
read-only and is designed to show which zone this memory
74-
block can be onlined to.
75+
read-only.
76+
77+
For online memory blocks, it returns in which zone memory
78+
provided by a memory block is managed. If multiple zones
79+
apply (not applicable for hotplugged memory), "None" is returned
80+
and the memory block cannot be offlined.
81+
82+
For offline memory blocks, it returns by which zone memory
83+
provided by a memory block can be managed when onlining.
84+
The first returned zone ("default") will be used when setting
85+
the state of an offline memory block to "online". Only one of
86+
the kernel zones (DMA, DMA32, Normal) is applicable for a single
87+
memory block.
7588

7689
What: /sys/devices/system/memoryX/nodeY
7790
Date: October 2009

Documentation/admin-guide/mm/memory-hotplug.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@ Under each memory block, you can see 5 files:
162162
which will be performed on all sections in the block.
163163
``phys_device`` read-only: legacy interface only ever used on s390x to
164164
expose the covered storage increment.
165-
``removable`` read-only: contains an integer value indicating
166-
whether the memory block is removable or not
167-
removable. A value of 1 indicates that the memory
168-
block is removable and a value of 0 indicates that
169-
it is not removable. A memory block is removable only if
170-
every section in the block is removable.
171-
``valid_zones`` read-only: designed to show which zones this memory block
172-
can be onlined to.
165+
``removable`` read-only: legacy interface that indicated whether a memory
166+
block was likely to be offlineable or not. Newer kernel
167+
versions return "1" if and only if the kernel supports
168+
memory offlining.
169+
``valid_zones`` read-only: designed to show by which zone memory provided by
170+
a memory block is managed, and to show by which zone memory
171+
provided by an offline memory block could be managed when
172+
onlining.
173173

174174
The first column shows it`s default zone.
175175

0 commit comments

Comments
 (0)