Lines Matching refs:memory

6 Add description of notifier of memory hotplug	Oct 11 2007
8 This document is about memory hotplug including how-to-use and current status.
13 1.1 purpose of memory hotplug
14 1.2. Phases of memory hotplug
17 3. sysfs files for memory hotplug
18 4. Physical memory hot-add phase
20 4.2 Notify memory hot-add event by hand
22 5.1. State of memory
23 5.2. How to online memory
24 6. Logical memory remove
26 6.2. How to offline memory
27 7. Physical memory remove
31 Note(1): x86_64's has special implementation for memory hotplug.
40 1.1 purpose of memory hotplug
42 Memory Hotplug allows users to increase/decrease the amount of memory.
45 (A) For changing the amount of memory.
51 hardware which supports memory power management.
53 Linux memory hotplug is designed for both purpose.
56 1.2. Phases of memory hotplug
63 environment for hotplugged memory. Basically, this phase is necessary
67 When memory is hotplugged, the kernel recognizes new memory, makes new memory
68 management tables, and makes sysfs files for new memory's operation.
70 If firmware supports notification of connection of new memory to OS,
75 Logical Memory Hotplug phase is to change memory state into
76 available/unavailable for users. Amount of memory from user's view is
77 changed by this phase. The kernel makes all memory in it as free pages
78 when a memory range is available.
85 (However, if you writes udev's hotplug scripts for memory hotplug, these
91 Memory hotplug uses SPARSEMEM memory model which allows memory to be divided
93 a memory section is architecture dependent. For example, power uses 16MiB, ia64
96 Memory sections are combined into chunks referred to as "memory blocks". The
97 size of a memory block is architecture dependent and represents the logical
98 unit upon which memory online/offline operations are to be performed. The
99 default size of a memory block is the same as memory section size unless an
102 To determine the size (in bytes) of a memory block please read this file:
104 /sys/devices/system/memory/block_size_bytes
110 To use memory hotplug feature, kernel must be compiled with following
113 - For all memory hotplug
115 Allow for memory hot-add (CONFIG_MEMORY_HOTPLUG)
117 - To enable memory removal, the followings are also necessary
118 Allow for memory hot remove (CONFIG_MEMORY_HOTREMOVE)
121 - For ACPI memory hotplug, the followings are also necessary
133 3 sysfs files for memory hotplug
135 All memory blocks have their device information in sysfs. Each memory block
136 is described under /sys/devices/system/memory as
138 /sys/devices/system/memory/memoryXXX
139 (XXX is the memory block id.)
141 For the memory block covered by the sysfs directory. It is expected that all
142 memory sections in this range are present and no memory holes exist in the
143 range. Currently there is no way to determine if there is a memory hole, but
144 the existence of one should not affect the hotplug capabilities of the memory
147 For example, assume 1GiB memory block size. A device for a memory starting at
148 0x100000000 is /sys/device/system/memory/memory4
152 Under each memory block, you can see 5 files:
154 /sys/devices/system/memory/memoryXXX/phys_index
155 /sys/devices/system/memory/memoryXXX/phys_device
156 /sys/devices/system/memory/memoryXXX/state
157 /sys/devices/system/memory/memoryXXX/removable
158 /sys/devices/system/memory/memoryXXX/valid_zones
160 'phys_index' : read-only and contains memory block id, same as XXX.
162 at read: contains online/offline state of memory.
166 'phys_device' : read-only: designed to show the name of physical memory
169 whether the memory block is removable or not
170 removable. A value of 1 indicates that the memory
172 it is not removable. A memory block is removable only if
174 'valid_zones' : read-only: designed to show which zones this memory block
185 These directories/files appear after physical memory hotplug phase.
191 /sys/devices/system/node/node0/memory9 -> ../../memory/memory9
194 /sys/devices/system/memory/memory9/node0 -> ../../node/node0
198 4. Physical memory hot-add phase
203 On x86_64/ia64 platform, memory hotplug by ACPI is supported.
205 In general, the firmware (ACPI) which supports memory hotplug defines
206 memory class object of _HID "PNP0C80". When a notify is asserted to PNP0C80,
207 Linux's ACPI handler does hot-add memory to the system and calls a hotplug udev
210 But scripts for memory hotplug are not contained in generic udev package(now).
211 You may have to write it by yourself or online/offline memory by hand.
212 Please see "How to online memory", "How to offline memory" in this text.
217 If memory device is found, memory hotplug code will be called.
220 4.2 Notify memory hot-add event by hand
222 On some architectures, the firmware may not notify the kernel of a memory
223 hotplug event. Therefore, the memory "probe" interface is supported to
230 /sys/devices/system/memory/probe
232 You can tell the physical address of new memory to the kernel by
234 % echo start_address_of_new_memory > /sys/devices/system/memory/probe
237 memory_block_size] memory range is hot-added. In this case, hotplug script is
238 not called (in current implementation). You'll have to online memory by
239 yourself. Please see "How to online memory" in this text.
246 5.1. State of memory
248 To see (online/offline) state of a memory block, read 'state' file.
250 % cat /sys/device/system/memory/memoryXXX/state
253 If the memory block is online, you'll read "online".
254 If the memory block is offline, you'll read "offline".
257 5.2. How to online memory
259 Even if the memory is hot-added, it is not at ready-to-use state.
260 For using newly added memory, you have to "online" the memory block.
262 For onlining, you have to write "online" to the memory block's state file as:
264 % echo online > /sys/devices/system/memory/memoryXXX/state
266 This onlining will not change the ZONE type of the target memory block,
267 If the memory block is in ZONE_NORMAL, you can change it to ZONE_MOVABLE:
269 % echo online_movable > /sys/devices/system/memory/memoryXXX/state
270 (NOTE: current limit: this memory block must be adjacent to ZONE_MOVABLE)
272 And if the memory block is in ZONE_MOVABLE, you can change it to ZONE_NORMAL:
274 % echo online_kernel > /sys/devices/system/memory/memoryXXX/state
275 (NOTE: current limit: this memory block must be adjacent to ZONE_NORMAL)
277 After this, memory block XXX's state will be 'online' and the amount of
278 available memory will be increased.
280 Currently, newly added memory is added as ZONE_NORMAL (for powerpc, ZONE_DMA).
286 6. Logical memory remove
291 Memory offlining is more complicated than memory online. Because memory offline
292 has to make the whole memory block be unused, memory offline can fail if
293 the memory block includes memory which cannot be freed.
295 In general, memory offline can use 2 techniques.
297 (1) reclaim and free all memory in the memory block.
298 (2) migrate all pages in the memory block.
300 In the current implementation, Linux's memory offline uses method (2), freeing
301 all pages in the memory block by page migration. But not all pages are
303 page caches. For offlining a memory block by migration, the kernel has to
304 guarantee that the memory block contains only migratable pages.
306 Now, a boot option for making a memory block which consists of migratable pages
311 Assume the system has "TOTAL" amount of memory at boot time, this boot option
315 Size of memory not for movable pages (not for offline) is YYYY.
316 Size of memory for movable pages (for offline) is TOTAL-YYYY.
319 Size of memory not for movable pages (not for offline) is TOTAL - ZZZZ.
320 Size of memory for movable pages (for offline) is ZZZZ.
323 Note: Unfortunately, there is no information to show which memory block belongs
327 6.2. How to offline memory
329 You can offline a memory block by using the same sysfs interface that was used
330 in memory onlining.
332 % echo offline > /sys/devices/system/memory/memoryXXX/state
334 If offline succeeds, the state of the memory block is changed to be "offline".
336 Even if a memory block does not belong to ZONE_MOVABLE, you can try to offline
337 it. If it doesn't contain 'unmovable' memory, you'll get success.
339 A memory block under ZONE_MOVABLE is considered to be able to be offlined
340 easily. But under some busy state, it may return -EBUSY. Even if a memory
346 Memory hotplug's design direction is to make the possibility of memory offlining
347 higher and to guarantee unplugging memory under any situation. But it needs
349 can decide to retry more or not by himself. Currently, memory offlining code
353 7. Physical memory remove
364 There are six types of notification defined in include/linux/memory.h:
367 Generated before new memory becomes available in order to be able to
368 prepare subsystems to handle memory. The page allocator is still unable
369 to allocate from the new memory.
375 Generated when memory has successfully brought online. The callback may
376 allocate pages from the new memory.
379 Generated to begin the process of offlining memory. Allocations are no
380 longer possible from the memory but some of the memory to be offlined
381 is still in use. The callback can be used to free memory known to a
382 subsystem from the indicated memory block.
386 the memory block that we attempted to offline.
389 Generated after offlining memory is complete.
416 start_pfn is start_pfn of online/offline memory.
417 nr_pages is # of pages of online/offline memory.
423 set/clear. It means a new(memoryless) node gets new memory by online and a
424 node loses all memory. If this is -1, then nodemask status is not changed.
443 - allowing memory hot-add to ZONE_MOVABLE. maybe we need some switch like
445 - showing memory block and physical device relationship.
446 - test and make it better memory offlining.
448 - memmap removing at memory offline.
449 - physical remove memory.