aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorLi Zhong <zhong@linux.vnet.ibm.com>2014-06-04 19:07:03 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 19:53:58 -0400
commit56a3c655a3d31cb1afef25b530b5ef6a1e7ddefd (patch)
treea4239563e740cce14dc52d5468a7fd880582a92d /Documentation
parente4f674229ce63dac60be0c4ddfb5ef8d1225d30d (diff)
memory-hotplug: update documentation to hide information about SECTIONS and remove end_phys_index
Seems we all agree that information about SECTION, e.g. section size, sections per memory block should be kept as kernel internals, and not exposed to userspace. This patch updates Documentation/memory-hotplug.txt to refer to memory blocks instead of memory sections where appropriate and added a paragraph to explain that memory blocks are made of memory sections. The documentation update is mostly provided by Nathan. Also, as end_phys_index in code is actually not the end section id, but the end memory block id, which should always be the same as phys_index. So it is removed here. Signed-off-by: Li Zhong <zhong@linux.vnet.ibm.com> Reviewed-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/memory-hotplug.txt125
1 files changed, 61 insertions, 64 deletions
diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt
index 58340d50f8a6..f304edb8fbe7 100644
--- a/Documentation/memory-hotplug.txt
+++ b/Documentation/memory-hotplug.txt
@@ -88,16 +88,21 @@ phase by hand.
88 88
891.3. Unit of Memory online/offline operation 891.3. Unit of Memory online/offline operation
90------------ 90------------
91Memory hotplug uses SPARSEMEM memory model. SPARSEMEM divides the whole memory 91Memory hotplug uses SPARSEMEM memory model which allows memory to be divided
92into chunks of the same size. The chunk is called a "section". The size of 92into chunks of the same size. These chunks are called "sections". The size of
93a section is architecture dependent. For example, power uses 16MiB, ia64 uses 93a memory section is architecture dependent. For example, power uses 16MiB, ia64
941GiB. The unit of online/offline operation is "one section". (see Section 3.) 94uses 1GiB.
95 95
96To determine the size of sections, please read this file: 96Memory sections are combined into chunks referred to as "memory blocks". The
97size of a memory block is architecture dependent and represents the logical
98unit upon which memory online/offline operations are to be performed. The
99default size of a memory block is the same as memory section size unless an
100architecture specifies otherwise. (see Section 3.)
101
102To determine the size (in bytes) of a memory block please read this file:
97 103
98/sys/devices/system/memory/block_size_bytes 104/sys/devices/system/memory/block_size_bytes
99 105
100This file shows the size of sections in byte.
101 106
102----------------------- 107-----------------------
1032. Kernel Configuration 1082. Kernel Configuration
@@ -123,42 +128,35 @@ config options.
123 (CONFIG_ACPI_CONTAINER). 128 (CONFIG_ACPI_CONTAINER).
124 This option can be kernel module too. 129 This option can be kernel module too.
125 130
131
126-------------------------------- 132--------------------------------
1274 sysfs files for memory hotplug 1333 sysfs files for memory hotplug
128-------------------------------- 134--------------------------------
129All sections have their device information in sysfs. Each section is part of 135All memory blocks have their device information in sysfs. Each memory block
130a memory block under /sys/devices/system/memory as 136is described under /sys/devices/system/memory as
131 137
132/sys/devices/system/memory/memoryXXX 138/sys/devices/system/memory/memoryXXX
133(XXX is the section id.) 139(XXX is the memory block id.)
134 140
135Now, XXX is defined as (start_address_of_section / section_size) of the first 141For the memory block covered by the sysfs directory. It is expected that all
136section contained in the memory block. The files 'phys_index' and
137'end_phys_index' under each directory report the beginning and end section id's
138for the memory block covered by the sysfs directory. It is expected that all
139memory sections in this range are present and no memory holes exist in the 142memory sections in this range are present and no memory holes exist in the
140range. Currently there is no way to determine if there is a memory hole, but 143range. Currently there is no way to determine if there is a memory hole, but
141the existence of one should not affect the hotplug capabilities of the memory 144the existence of one should not affect the hotplug capabilities of the memory
142block. 145block.
143 146
144For example, assume 1GiB section size. A device for a memory starting at 147For example, assume 1GiB memory block size. A device for a memory starting at
1450x100000000 is /sys/device/system/memory/memory4 1480x100000000 is /sys/device/system/memory/memory4
146(0x100000000 / 1Gib = 4) 149(0x100000000 / 1Gib = 4)
147This device covers address range [0x100000000 ... 0x140000000) 150This device covers address range [0x100000000 ... 0x140000000)
148 151
149Under each section, you can see 4 or 5 files, the end_phys_index file being 152Under each memory block, you can see 4 files:
150a recent addition and not present on older kernels.
151 153
152/sys/devices/system/memory/memoryXXX/start_phys_index 154/sys/devices/system/memory/memoryXXX/phys_index
153/sys/devices/system/memory/memoryXXX/end_phys_index
154/sys/devices/system/memory/memoryXXX/phys_device 155/sys/devices/system/memory/memoryXXX/phys_device
155/sys/devices/system/memory/memoryXXX/state 156/sys/devices/system/memory/memoryXXX/state
156/sys/devices/system/memory/memoryXXX/removable 157/sys/devices/system/memory/memoryXXX/removable
157 158
158'phys_index' : read-only and contains section id of the first section 159'phys_index' : read-only and contains memory block id, same as XXX.
159 in the memory block, same as XXX.
160'end_phys_index' : read-only and contains section id of the last section
161 in the memory block.
162'state' : read-write 160'state' : read-write
163 at read: contains online/offline state of memory. 161 at read: contains online/offline state of memory.
164 at write: user can specify "online_kernel", 162 at write: user can specify "online_kernel",
@@ -185,6 +183,7 @@ For example:
185A backlink will also be created: 183A backlink will also be created:
186/sys/devices/system/memory/memory9/node0 -> ../../node/node0 184/sys/devices/system/memory/memory9/node0 -> ../../node/node0
187 185
186
188-------------------------------- 187--------------------------------
1894. Physical memory hot-add phase 1884. Physical memory hot-add phase
190-------------------------------- 189--------------------------------
@@ -227,11 +226,10 @@ You can tell the physical address of new memory to the kernel by
227 226
228% echo start_address_of_new_memory > /sys/devices/system/memory/probe 227% echo start_address_of_new_memory > /sys/devices/system/memory/probe
229 228
230Then, [start_address_of_new_memory, start_address_of_new_memory + section_size) 229Then, [start_address_of_new_memory, start_address_of_new_memory +
231memory range is hot-added. In this case, hotplug script is not called (in 230memory_block_size] memory range is hot-added. In this case, hotplug script is
232current implementation). You'll have to online memory by yourself. 231not called (in current implementation). You'll have to online memory by
233Please see "How to online memory" in this text. 232yourself. Please see "How to online memory" in this text.
234
235 233
236 234
237------------------------------ 235------------------------------
@@ -240,36 +238,36 @@ Please see "How to online memory" in this text.
240 238
2415.1. State of memory 2395.1. State of memory
242------------ 240------------
243To see (online/offline) state of memory section, read 'state' file. 241To see (online/offline) state of a memory block, read 'state' file.
244 242
245% cat /sys/device/system/memory/memoryXXX/state 243% cat /sys/device/system/memory/memoryXXX/state
246 244
247 245
248If the memory section is online, you'll read "online". 246If the memory block is online, you'll read "online".
249If the memory section is offline, you'll read "offline". 247If the memory block is offline, you'll read "offline".
250 248
251 249
2525.2. How to online memory 2505.2. How to online memory
253------------ 251------------
254Even if the memory is hot-added, it is not at ready-to-use state. 252Even if the memory is hot-added, it is not at ready-to-use state.
255For using newly added memory, you have to "online" the memory section. 253For using newly added memory, you have to "online" the memory block.
256 254
257For onlining, you have to write "online" to the section's state file as: 255For onlining, you have to write "online" to the memory block's state file as:
258 256
259% echo online > /sys/devices/system/memory/memoryXXX/state 257% echo online > /sys/devices/system/memory/memoryXXX/state
260 258
261This onlining will not change the ZONE type of the target memory section, 259This onlining will not change the ZONE type of the target memory block,
262If the memory section is in ZONE_NORMAL, you can change it to ZONE_MOVABLE: 260If the memory block is in ZONE_NORMAL, you can change it to ZONE_MOVABLE:
263 261
264% echo online_movable > /sys/devices/system/memory/memoryXXX/state 262% echo online_movable > /sys/devices/system/memory/memoryXXX/state
265(NOTE: current limit: this memory section must be adjacent to ZONE_MOVABLE) 263(NOTE: current limit: this memory block must be adjacent to ZONE_MOVABLE)
266 264
267And if the memory section is in ZONE_MOVABLE, you can change it to ZONE_NORMAL: 265And if the memory block is in ZONE_MOVABLE, you can change it to ZONE_NORMAL:
268 266
269% echo online_kernel > /sys/devices/system/memory/memoryXXX/state 267% echo online_kernel > /sys/devices/system/memory/memoryXXX/state
270(NOTE: current limit: this memory section must be adjacent to ZONE_NORMAL) 268(NOTE: current limit: this memory block must be adjacent to ZONE_NORMAL)
271 269
272After this, section memoryXXX's state will be 'online' and the amount of 270After this, memory block XXX's state will be 'online' and the amount of
273available memory will be increased. 271available memory will be increased.
274 272
275Currently, newly added memory is added as ZONE_NORMAL (for powerpc, ZONE_DMA). 273Currently, newly added memory is added as ZONE_NORMAL (for powerpc, ZONE_DMA).
@@ -284,22 +282,22 @@ This may be changed in future.
2846.1 Memory offline and ZONE_MOVABLE 2826.1 Memory offline and ZONE_MOVABLE
285------------ 283------------
286Memory offlining is more complicated than memory online. Because memory offline 284Memory offlining is more complicated than memory online. Because memory offline
287has to make the whole memory section be unused, memory offline can fail if 285has to make the whole memory block be unused, memory offline can fail if
288the section includes memory which cannot be freed. 286the memory block includes memory which cannot be freed.
289 287
290In general, memory offline can use 2 techniques. 288In general, memory offline can use 2 techniques.
291 289
292(1) reclaim and free all memory in the section. 290(1) reclaim and free all memory in the memory block.
293(2) migrate all pages in the section. 291(2) migrate all pages in the memory block.
294 292
295In the current implementation, Linux's memory offline uses method (2), freeing 293In the current implementation, Linux's memory offline uses method (2), freeing
296all pages in the section by page migration. But not all pages are 294all pages in the memory block by page migration. But not all pages are
297migratable. Under current Linux, migratable pages are anonymous pages and 295migratable. Under current Linux, migratable pages are anonymous pages and
298page caches. For offlining a section by migration, the kernel has to guarantee 296page caches. For offlining a memory block by migration, the kernel has to
299that the section contains only migratable pages. 297guarantee that the memory block contains only migratable pages.
300 298
301Now, a boot option for making a section which consists of migratable pages is 299Now, a boot option for making a memory block which consists of migratable pages
302supported. By specifying "kernelcore=" or "movablecore=" boot option, you can 300is supported. By specifying "kernelcore=" or "movablecore=" boot option, you can
303create ZONE_MOVABLE...a zone which is just used for movable pages. 301create ZONE_MOVABLE...a zone which is just used for movable pages.
304(See also Documentation/kernel-parameters.txt) 302(See also Documentation/kernel-parameters.txt)
305 303
@@ -315,28 +313,27 @@ creates ZONE_MOVABLE as following.
315 Size of memory for movable pages (for offline) is ZZZZ. 313 Size of memory for movable pages (for offline) is ZZZZ.
316 314
317 315
318Note) Unfortunately, there is no information to show which section belongs 316Note: Unfortunately, there is no information to show which memory block belongs
319to ZONE_MOVABLE. This is TBD. 317to ZONE_MOVABLE. This is TBD.
320 318
321 319
3226.2. How to offline memory 3206.2. How to offline memory
323------------ 321------------
324You can offline a section by using the same sysfs interface that was used in 322You can offline a memory block by using the same sysfs interface that was used
325memory onlining. 323in memory onlining.
326 324
327% echo offline > /sys/devices/system/memory/memoryXXX/state 325% echo offline > /sys/devices/system/memory/memoryXXX/state
328 326
329If offline succeeds, the state of the memory section is changed to be "offline". 327If offline succeeds, the state of the memory block is changed to be "offline".
330If it fails, some error core (like -EBUSY) will be returned by the kernel. 328If it fails, some error core (like -EBUSY) will be returned by the kernel.
331Even if a section does not belong to ZONE_MOVABLE, you can try to offline it. 329Even if a memory block does not belong to ZONE_MOVABLE, you can try to offline
332If it doesn't contain 'unmovable' memory, you'll get success. 330it. If it doesn't contain 'unmovable' memory, you'll get success.
333 331
334A section under ZONE_MOVABLE is considered to be able to be offlined easily. 332A memory block under ZONE_MOVABLE is considered to be able to be offlined
335But under some busy state, it may return -EBUSY. Even if a memory section 333easily. But under some busy state, it may return -EBUSY. Even if a memory
336cannot be offlined due to -EBUSY, you can retry offlining it and may be able to 334block cannot be offlined due to -EBUSY, you can retry offlining it and may be
337offline it (or not). 335able to offline it (or not). (For example, a page is referred to by some kernel
338(For example, a page is referred to by some kernel internal call and released 336internal call and released soon.)
339 soon.)
340 337
341Consideration: 338Consideration:
342Memory hotplug's design direction is to make the possibility of memory offlining 339Memory hotplug's design direction is to make the possibility of memory offlining
@@ -373,11 +370,11 @@ MEMORY_GOING_OFFLINE
373 Generated to begin the process of offlining memory. Allocations are no 370 Generated to begin the process of offlining memory. Allocations are no
374 longer possible from the memory but some of the memory to be offlined 371 longer possible from the memory but some of the memory to be offlined
375 is still in use. The callback can be used to free memory known to a 372 is still in use. The callback can be used to free memory known to a
376 subsystem from the indicated memory section. 373 subsystem from the indicated memory block.
377 374
378MEMORY_CANCEL_OFFLINE 375MEMORY_CANCEL_OFFLINE
379 Generated if MEMORY_GOING_OFFLINE fails. Memory is available again from 376 Generated if MEMORY_GOING_OFFLINE fails. Memory is available again from
380 the section that we attempted to offline. 377 the memory block that we attempted to offline.
381 378
382MEMORY_OFFLINE 379MEMORY_OFFLINE
383 Generated after offlining memory is complete. 380 Generated after offlining memory is complete.
@@ -413,8 +410,8 @@ node if necessary.
413-------------- 410--------------
414 - allowing memory hot-add to ZONE_MOVABLE. maybe we need some switch like 411 - allowing memory hot-add to ZONE_MOVABLE. maybe we need some switch like
415 sysctl or new control file. 412 sysctl or new control file.
416 - showing memory section and physical device relationship. 413 - showing memory block and physical device relationship.
417 - showing memory section is under ZONE_MOVABLE or not 414 - showing memory block is under ZONE_MOVABLE or not
418 - test and make it better memory offlining. 415 - test and make it better memory offlining.
419 - support HugeTLB page migration and offlining. 416 - support HugeTLB page migration and offlining.
420 - memmap removing at memory offline. 417 - memmap removing at memory offline.