← Documents Documentation/admin-guide/mm/memory-hotplug.rst GitHub 원문 ↗

Linux 6.18.37 · Administration / Memory Management

Memory Hot(Un)Plug

System RAM hotplug·hotunplug 단계, memory block sysfs, online policy, ZONE_MOVABLE 비율과 offlining 실패 조건을 설명합니다.

Source pathDocumentation/admin-guide/mm/memory-hotplug.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

운영 핵심

memory-hotplug.rst:1-696

Memory hotplug는 물리 메모리를 Linux에 등록하는 add와 page allocator에 공개하는 online을 구분합니다. 제거 경로도 offline과 remove가 분리되며, 실제 운영에서는 block 단위와 zone 배치, unmovable allocation 때문에 생기는 실패 가능성을 함께 관리해야 합니다.

관점핵심
단위SPARSEMEM section을 묶은 동일 크기 memory block
추가add로 metadata·sysfs를 만들고 online으로 page allocator에 공개
제거offline으로 page를 migrate·격리한 뒤 block과 metadata를 remove
정책online_policy와 auto_movable_ratio로 kernel/MOVABLE zone 균형 제어
신뢰성ZONE_MOVABLE이 offlining 성공률을 높이지만 절대 보장하지는 않음

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 ==================
2 Memory Hot(Un)Plug
3 ==================
4
5 This document describes generic Linux support for memory hot(un)plug with
6 a focus on System RAM, including ZONE_MOVABLE support.
7
8 .. contents:: :local:
9
10 Introduction
11 ============
12
13 Memory hot(un)plug allows for increasing and decreasing the size of physical
14 memory available to a machine at runtime. In the simplest case, it consists of
15 physically plugging or unplugging a DIMM at runtime, coordinated with the
16 operating system.
17
18 Memory hot(un)plug is used for various purposes:
19
20 - The physical memory available to a machine can be adjusted at runtime, up- or
21 downgrading the memory capacity. This dynamic memory resizing, sometimes
22 referred to as "capacity on demand", is frequently used with virtual machines
23 and logical partitions.
24
25 - Replacing hardware, such as DIMMs or whole NUMA nodes, without downtime. One
26 example is replacing failing memory modules.
27
28 - Reducing energy consumption either by physically unplugging memory modules or
29 by logically unplugging (parts of) memory modules from Linux.
30
31 Further, the basic memory hot(un)plug infrastructure in Linux is nowadays also
32 used to expose persistent memory, other performance-differentiated memory and
33 reserved memory regions as ordinary system RAM to Linux.
34
35 Linux only supports memory hot(un)plug on selected 64 bit architectures, such as
36 x86_64, arm64, ppc64 and s390x.
37
38 Memory Hot(Un)Plug Granularity
39 ------------------------------
40
41 Memory hot(un)plug in Linux uses the SPARSEMEM memory model, which divides the
42 physical memory address space into chunks of the same size: memory sections. The
43 size of a memory section is architecture dependent. For example, x86_64 uses
44 128 MiB and ppc64 uses 16 MiB.
45
46 Memory sections are combined into chunks referred to as "memory blocks". The
47 size of a memory block is architecture dependent and corresponds to the smallest
48 granularity that can be hot(un)plugged. The default size of a memory block is
49 the same as memory section size, unless an architecture specifies otherwise.
50
51 All memory blocks have the same size.
52
53 Phases of Memory Hotplug
54 ------------------------
55
56 Memory hotplug consists of two phases:
57
58 (1) Adding the memory to Linux
59 (2) Onlining memory blocks
60
61 In the first phase, metadata, such as the memory map ("memmap") and page tables
62 for the direct mapping, is allocated and initialized, and memory blocks are
63 created; the latter also creates sysfs files for managing newly created memory
64 blocks.
65
66 In the second phase, added memory is exposed to the page allocator. After this
67 phase, the memory is visible in memory statistics, such as free and total
68 memory, of the system.
69
70 Phases of Memory Hotunplug
71 --------------------------
72
73 Memory hotunplug consists of two phases:
74
75 (1) Offlining memory blocks
76 (2) Removing the memory from Linux
77
78 In the first phase, memory is "hidden" from the page allocator again, for
79 example, by migrating busy memory to other memory locations and removing all
80 relevant free pages from the page allocator After this phase, the memory is no
81 longer visible in memory statistics of the system.
82
83 In the second phase, the memory blocks are removed and metadata is freed.
84
85 Memory Hotplug Notifications
86 ============================
87
88 There are various ways how Linux is notified about memory hotplug events such
89 that it can start adding hotplugged memory. This description is limited to
90 systems that support ACPI; mechanisms specific to other firmware interfaces or
91 virtual machines are not described.
92
93 ACPI Notifications
94 ------------------
95
96 Platforms that support ACPI, such as x86_64, can support memory hotplug
97 notifications via ACPI.
98
99 In general, a firmware supporting memory hotplug defines a memory class object
100 HID "PNP0C80". When notified about hotplug of a new memory device, the ACPI
101 driver will hotplug the memory to Linux.
102
103 If the firmware supports hotplug of NUMA nodes, it defines an object _HID
104 "ACPI0004", "PNP0A05", or "PNP0A06". When notified about an hotplug event, all
105 assigned memory devices are added to Linux by the ACPI driver.
106
107 Similarly, Linux can be notified about requests to hotunplug a memory device or
108 a NUMA node via ACPI. The ACPI driver will try offlining all relevant memory
109 blocks, and, if successful, hotunplug the memory from Linux.
110
111 Manual Probing
112 --------------
113
114 On some architectures, the firmware may not be able to notify the operating
115 system about a memory hotplug event. Instead, the memory has to be manually
116 probed from user space.
117
118 The probe interface is located at::
119
120 /sys/devices/system/memory/probe
121
122 Only complete memory blocks can be probed. Individual memory blocks are probed
123 by providing the physical start address of the memory block::
124
125 % echo addr > /sys/devices/system/memory/probe
126
127 Which results in a memory block for the range [addr, addr + memory_block_size)
128 being created.
129
130 .. note::
131
132 Using the probe interface is discouraged as it is easy to crash the kernel,
133 because Linux cannot validate user input; this interface might be removed in
134 the future.
135
136 Onlining and Offlining Memory Blocks
137 ====================================
138
139 After a memory block has been created, Linux has to be instructed to actually
140 make use of that memory: the memory block has to be "online".
141
142 Before a memory block can be removed, Linux has to stop using any memory part of
143 the memory block: the memory block has to be "offlined".
144
145 The Linux kernel can be configured to automatically online added memory blocks
146 and drivers automatically trigger offlining of memory blocks when trying
147 hotunplug of memory. Memory blocks can only be removed once offlining succeeded
148 and drivers may trigger offlining of memory blocks when attempting hotunplug of
149 memory.
150
151 Onlining Memory Blocks Manually
152 -------------------------------
153
154 If auto-onlining of memory blocks isn't enabled, user-space has to manually
155 trigger onlining of memory blocks. Often, udev rules are used to automate this
156 task in user space.
157
158 Onlining of a memory block can be triggered via::
159
160 % echo online > /sys/devices/system/memory/memoryXXX/state
161
162 Or alternatively::
163
164 % echo 1 > /sys/devices/system/memory/memoryXXX/online
165
166 The kernel will select the target zone automatically, depending on the
167 configured ``online_policy``.
168
169 One can explicitly request to associate an offline memory block with
170 ZONE_MOVABLE by::
171
172 % echo online_movable > /sys/devices/system/memory/memoryXXX/state
173
174 Or one can explicitly request a kernel zone (usually ZONE_NORMAL) by::
175
176 % echo online_kernel > /sys/devices/system/memory/memoryXXX/state
177
178 In any case, if onlining succeeds, the state of the memory block is changed to
179 be "online". If it fails, the state of the memory block will remain unchanged
180 and the above commands will fail.
181
182 Onlining Memory Blocks Automatically
183 ------------------------------------
184
185 The kernel can be configured to try auto-onlining of newly added memory blocks.
186 If this feature is disabled, the memory blocks will stay offline until
187 explicitly onlined from user space.
188
189 The configured auto-online behavior can be observed via::
190
191 % cat /sys/devices/system/memory/auto_online_blocks
192
193 Auto-onlining can be enabled by writing ``online``, ``online_kernel`` or
194 ``online_movable`` to that file, like::
195
196 % echo online > /sys/devices/system/memory/auto_online_blocks
197
198 Similarly to manual onlining, with ``online`` the kernel will select the
199 target zone automatically, depending on the configured ``online_policy``.
200
201 Modifying the auto-online behavior will only affect all subsequently added
202 memory blocks only.
203
204 .. note::
205
206 In corner cases, auto-onlining can fail. The kernel won't retry. Note that
207 auto-onlining is not expected to fail in default configurations.
208
209 .. note::
210
211 DLPAR on ppc64 ignores the ``offline`` setting and will still online added
212 memory blocks; if onlining fails, memory blocks are removed again.
213
214 Offlining Memory Blocks
215 -----------------------
216
217 In the current implementation, Linux's memory offlining will try migrating all
218 movable pages off the affected memory block. As most kernel allocations, such as
219 page tables, are unmovable, page migration can fail and, therefore, inhibit
220 memory offlining from succeeding.
221
222 Having the memory provided by memory block managed by ZONE_MOVABLE significantly
223 increases memory offlining reliability; still, memory offlining can fail in
224 some corner cases.
225
226 Further, memory offlining might retry for a long time (or even forever), until
227 aborted by the user.
228
229 Offlining of a memory block can be triggered via::
230
231 % echo offline > /sys/devices/system/memory/memoryXXX/state
232
233 Or alternatively::
234
235 % echo 0 > /sys/devices/system/memory/memoryXXX/online
236
237 If offlining succeeds, the state of the memory block is changed to be "offline".
238 If it fails, the state of the memory block will remain unchanged and the above
239 commands will fail, for example, via::
240
241 bash: echo: write error: Device or resource busy
242
243 or via::
244
245 bash: echo: write error: Invalid argument
246
247 Observing the State of Memory Blocks
248 ------------------------------------
249
250 The state (online/offline/going-offline) of a memory block can be observed
251 either via::
252
253 % cat /sys/devices/system/memory/memoryXXX/state
254
255 Or alternatively (1/0) via::
256
257 % cat /sys/devices/system/memory/memoryXXX/online
258
259 For an online memory block, the managing zone can be observed via::
260
261 % cat /sys/devices/system/memory/memoryXXX/valid_zones
262
263 Configuring Memory Hot(Un)Plug
264 ==============================
265
266 There are various ways how system administrators can configure memory
267 hot(un)plug and interact with memory blocks, especially, to online them.
268
269 Memory Hot(Un)Plug Configuration via Sysfs
270 ------------------------------------------
271
272 Some memory hot(un)plug properties can be configured or inspected via sysfs in::
273
274 /sys/devices/system/memory/
275
276 The following files are currently defined:
277
278 ====================== =========================================================
279 ``auto_online_blocks`` read-write: set or get the default state of new memory
280 blocks; configure auto-onlining.
281
282 The default value depends on the
283 CONFIG_MHP_DEFAULT_ONLINE_TYPE kernel configuration
284 options.
285
286 See the ``state`` property of memory blocks for details.
287 ``block_size_bytes`` read-only: the size in bytes of a memory block.
288 ``probe`` write-only: add (probe) selected memory blocks manually
289 from user space by supplying the physical start address.
290
291 Availability depends on the CONFIG_ARCH_MEMORY_PROBE
292 kernel configuration option.
293 ``uevent`` read-write: generic udev file for device subsystems.
294 ``crash_hotplug`` read-only: when changes to the system memory map
295 occur due to hot un/plug of memory, this file contains
296 '1' if the kernel updates the kdump capture kernel memory
297 map itself (via elfcorehdr and other relevant kexec
298 segments), or '0' if userspace must update the kdump
299 capture kernel memory map.
300
301 Availability depends on the CONFIG_MEMORY_HOTPLUG kernel
302 configuration option.
303 ====================== =========================================================
304
305 .. note::
306
307 When the CONFIG_MEMORY_FAILURE kernel configuration option is enabled, two
308 additional files ``hard_offline_page`` and ``soft_offline_page`` are available
309 to trigger hwpoisoning of pages, for example, for testing purposes. Note that
310 this functionality is not really related to memory hot(un)plug or actual
311 offlining of memory blocks.
312
313 Memory Block Configuration via Sysfs
314 ------------------------------------
315
316 Each memory block is represented as a memory block device that can be
317 onlined or offlined. All memory blocks have their device information located in
318 sysfs. Each present memory block is listed under
319 ``/sys/devices/system/memory`` as::
320
321 /sys/devices/system/memory/memoryXXX
322
323 where XXX is the memory block id; the number of digits is variable.
324
325 A present memory block indicates that some memory in the range is present;
326 however, a memory block might span memory holes. A memory block spanning memory
327 holes cannot be offlined.
328
329 For example, assume 1 GiB memory block size. A device for a memory starting at
330 0x100000000 is ``/sys/devices/system/memory/memory4``::
331
332 (0x100000000 / 1Gib = 4)
333
334 This device covers address range [0x100000000 ... 0x140000000)
335
336 The following files are currently defined:
337
338 =================== ============================================================
339 ``online`` read-write: simplified interface to trigger onlining /
340 offlining and to observe the state of a memory block.
341 When onlining, the zone is selected automatically.
342 ``phys_device`` read-only: legacy interface only ever used on s390x to
343 expose the covered storage increment.
344 ``phys_index`` read-only: the memory block id (XXX).
345 ``removable`` read-only: legacy interface that indicated whether a memory
346 block was likely to be offlineable or not. Nowadays, the
347 kernel return ``1`` if and only if it supports memory
348 offlining.
349 ``state`` read-write: advanced interface to trigger onlining /
350 offlining and to observe the state of a memory block.
351
352 When writing, ``online``, ``offline``, ``online_kernel`` and
353 ``online_movable`` are supported.
354
355 ``online_movable`` specifies onlining to ZONE_MOVABLE.
356 ``online_kernel`` specifies onlining to the default kernel
357 zone for the memory block, such as ZONE_NORMAL.
358 ``online`` let's the kernel select the zone automatically.
359
360 When reading, ``online``, ``offline`` and ``going-offline``
361 may be returned.
362 ``uevent`` read-write: generic uevent file for devices.
363 ``valid_zones`` read-only: when a block is online, shows the zone it
364 belongs to; when a block is offline, shows what zone will
365 manage it when the block will be onlined.
366
367 For online memory blocks, ``DMA``, ``DMA32``, ``Normal``,
368 ``Movable`` and ``none`` may be returned. ``none`` indicates
369 that memory provided by a memory block is managed by
370 multiple zones or spans multiple nodes; such memory blocks
371 cannot be offlined. ``Movable`` indicates ZONE_MOVABLE.
372 Other values indicate a kernel zone.
373
374 For offline memory blocks, the first column shows the
375 zone the kernel would select when onlining the memory block
376 right now without further specifying a zone.
377
378 Availability depends on the CONFIG_MEMORY_HOTREMOVE
379 kernel configuration option.
380 =================== ============================================================
381
382 .. note::
383
384 If the CONFIG_NUMA kernel configuration option is enabled, the memoryXXX/
385 directories can also be accessed via symbolic links located in the
386 ``/sys/devices/system/node/node*`` directories.
387
388 For example::
389
390 /sys/devices/system/node/node0/memory9 -> ../../memory/memory9
391
392 A backlink will also be created::
393
394 /sys/devices/system/memory/memory9/node0 -> ../../node/node0
395
396 Command Line Parameters
397 -----------------------
398
399 Some command line parameters affect memory hot(un)plug handling. The following
400 command line parameters are relevant:
401
402 ======================== =======================================================
403 ``memhp_default_state`` configure auto-onlining by essentially setting
404 ``/sys/devices/system/memory/auto_online_blocks``.
405 ``movable_node`` configure automatic zone selection in the kernel when
406 using the ``contig-zones`` online policy. When
407 set, the kernel will default to ZONE_MOVABLE when
408 onlining a memory block, unless other zones can be kept
409 contiguous.
410 ======================== =======================================================
411
412 See Documentation/admin-guide/kernel-parameters.txt for a more generic
413 description of these command line parameters.
414
415 Module Parameters
416 ------------------
417
418 Instead of additional command line parameters or sysfs files, the
419 ``memory_hotplug`` subsystem now provides a dedicated namespace for module
420 parameters. Module parameters can be set via the command line by predicating
421 them with ``memory_hotplug.`` such as::
422
423 memory_hotplug.memmap_on_memory=1
424
425 and they can be observed (and some even modified at runtime) via::
426
427 /sys/module/memory_hotplug/parameters/
428
429 The following module parameters are currently defined:
430
431 ================================ ===============================================
432 ``memmap_on_memory`` read-write: Allocate memory for the memmap from
433 the added memory block itself. Even if enabled,
434 actual support depends on various other system
435 properties and should only be regarded as a
436 hint whether the behavior would be desired.
437
438 While allocating the memmap from the memory
439 block itself makes memory hotplug less likely
440 to fail and keeps the memmap on the same NUMA
441 node in any case, it can fragment physical
442 memory in a way that huge pages in bigger
443 granularity cannot be formed on hotplugged
444 memory.
445
446 With value "force" it could result in memory
447 wastage due to memmap size limitations. For
448 example, if the memmap for a memory block
449 requires 1 MiB, but the pageblock size is 2
450 MiB, 1 MiB of hotplugged memory will be wasted.
451 Note that there are still cases where the
452 feature cannot be enforced: for example, if the
453 memmap is smaller than a single page, or if the
454 architecture does not support the forced mode
455 in all configurations.
456
457 ``online_policy`` read-write: Set the basic policy used for
458 automatic zone selection when onlining memory
459 blocks without specifying a target zone.
460 ``contig-zones`` has been the kernel default
461 before this parameter was added. After an
462 online policy was configured and memory was
463 online, the policy should not be changed
464 anymore.
465
466 When set to ``contig-zones``, the kernel will
467 try keeping zones contiguous. If a memory block
468 intersects multiple zones or no zone, the
469 behavior depends on the ``movable_node`` kernel
470 command line parameter: default to ZONE_MOVABLE
471 if set, default to the applicable kernel zone
472 (usually ZONE_NORMAL) if not set.
473
474 When set to ``auto-movable``, the kernel will
475 try onlining memory blocks to ZONE_MOVABLE if
476 possible according to the configuration and
477 memory device details. With this policy, one
478 can avoid zone imbalances when eventually
479 hotplugging a lot of memory later and still
480 wanting to be able to hotunplug as much as
481 possible reliably, very desirable in
482 virtualized environments. This policy ignores
483 the ``movable_node`` kernel command line
484 parameter and isn't really applicable in
485 environments that require it (e.g., bare metal
486 with hotunpluggable nodes) where hotplugged
487 memory might be exposed via the
488 firmware-provided memory map early during boot
489 to the system instead of getting detected,
490 added and onlined later during boot (such as
491 done by virtio-mem or by some hypervisors
492 implementing emulated DIMMs). As one example, a
493 hotplugged DIMM will be onlined either
494 completely to ZONE_MOVABLE or completely to
495 ZONE_NORMAL, not a mixture.
496 As another example, as many memory blocks
497 belonging to a virtio-mem device will be
498 onlined to ZONE_MOVABLE as possible,
499 special-casing units of memory blocks that can
500 only get hotunplugged together. *This policy
501 does not protect from setups that are
502 problematic with ZONE_MOVABLE and does not
503 change the zone of memory blocks dynamically
504 after they were onlined.*
505 ``auto_movable_ratio`` read-write: Set the maximum MOVABLE:KERNEL
506 memory ratio in % for the ``auto-movable``
507 online policy. Whether the ratio applies only
508 for the system across all NUMA nodes or also
509 per NUMA nodes depends on the
510 ``auto_movable_numa_aware`` configuration.
511
512 All accounting is based on present memory pages
513 in the zones combined with accounting per
514 memory device. Memory dedicated to the CMA
515 allocator is accounted as MOVABLE, although
516 residing on one of the kernel zones. The
517 possible ratio depends on the actual workload.
518 The kernel default is "301" %, for example,
519 allowing for hotplugging 24 GiB to a 8 GiB VM
520 and automatically onlining all hotplugged
521 memory to ZONE_MOVABLE in many setups. The
522 additional 1% deals with some pages being not
523 present, for example, because of some firmware
524 allocations.
525
526 Note that ZONE_NORMAL memory provided by one
527 memory device does not allow for more
528 ZONE_MOVABLE memory for a different memory
529 device. As one example, onlining memory of a
530 hotplugged DIMM to ZONE_NORMAL will not allow
531 for another hotplugged DIMM to get onlined to
532 ZONE_MOVABLE automatically. In contrast, memory
533 hotplugged by a virtio-mem device that got
534 onlined to ZONE_NORMAL will allow for more
535 ZONE_MOVABLE memory within *the same*
536 virtio-mem device.
537 ``auto_movable_numa_aware`` read-write: Configure whether the
538 ``auto_movable_ratio`` in the ``auto-movable``
539 online policy also applies per NUMA
540 node in addition to the whole system across all
541 NUMA nodes. The kernel default is "Y".
542
543 Disabling NUMA awareness can be helpful when
544 dealing with NUMA nodes that should be
545 completely hotunpluggable, onlining the memory
546 completely to ZONE_MOVABLE automatically if
547 possible.
548
549 Parameter availability depends on CONFIG_NUMA.
550 ================================ ===============================================
551
552 ZONE_MOVABLE
553 ============
554
555 ZONE_MOVABLE is an important mechanism for more reliable memory offlining.
556 Further, having system RAM managed by ZONE_MOVABLE instead of one of the
557 kernel zones can increase the number of possible transparent huge pages and
558 dynamically allocated huge pages.
559
560 Most kernel allocations are unmovable. Important examples include the memory
561 map (usually 1/64ths of memory), page tables, and kmalloc(). Such allocations
562 can only be served from the kernel zones.
563
564 Most user space pages, such as anonymous memory, and page cache pages are
565 movable. Such allocations can be served from ZONE_MOVABLE and the kernel zones.
566
567 Only movable allocations are served from ZONE_MOVABLE, resulting in unmovable
568 allocations being limited to the kernel zones. Without ZONE_MOVABLE, there is
569 absolutely no guarantee whether a memory block can be offlined successfully.
570
571 Zone Imbalances
572 ---------------
573
574 Having too much system RAM managed by ZONE_MOVABLE is called a zone imbalance,
575 which can harm the system or degrade performance. As one example, the kernel
576 might crash because it runs out of free memory for unmovable allocations,
577 although there is still plenty of free memory left in ZONE_MOVABLE.
578
579 Usually, MOVABLE:KERNEL ratios of up to 3:1 or even 4:1 are fine. Ratios of 63:1
580 are definitely impossible due to the overhead for the memory map.
581
582 Actual safe zone ratios depend on the workload. Extreme cases, like excessive
583 long-term pinning of pages, might not be able to deal with ZONE_MOVABLE at all.
584
585 .. note::
586
587 CMA memory part of a kernel zone essentially behaves like memory in
588 ZONE_MOVABLE and similar considerations apply, especially when combining
589 CMA with ZONE_MOVABLE.
590
591 ZONE_MOVABLE Sizing Considerations
592 ----------------------------------
593
594 We usually expect that a large portion of available system RAM will actually
595 be consumed by user space, either directly or indirectly via the page cache. In
596 the normal case, ZONE_MOVABLE can be used when allocating such pages just fine.
597
598 With that in mind, it makes sense that we can have a big portion of system RAM
599 managed by ZONE_MOVABLE. However, there are some things to consider when using
600 ZONE_MOVABLE, especially when fine-tuning zone ratios:
601
602 - Having a lot of offline memory blocks. Even offline memory blocks consume
603 memory for metadata and page tables in the direct map; having a lot of offline
604 memory blocks is not a typical case, though.
605
606 - Memory ballooning without balloon compaction is incompatible with
607 ZONE_MOVABLE. Only some implementations, such as virtio-balloon and
608 pseries CMM, fully support balloon compaction.
609
610 Further, the CONFIG_BALLOON_COMPACTION kernel configuration option might be
611 disabled. In that case, balloon inflation will only perform unmovable
612 allocations and silently create a zone imbalance, usually triggered by
613 inflation requests from the hypervisor.
614
615 - Gigantic pages are unmovable, resulting in user space consuming a
616 lot of unmovable memory.
617
618 - Huge pages are unmovable when an architectures does not support huge
619 page migration, resulting in a similar issue as with gigantic pages.
620
621 - Page tables are unmovable. Excessive swapping, mapping extremely large
622 files or ZONE_DEVICE memory can be problematic, although only really relevant
623 in corner cases. When we manage a lot of user space memory that has been
624 swapped out or is served from a file/persistent memory/... we still need a lot
625 of page tables to manage that memory once user space accessed that memory.
626
627 - In certain DAX configurations the memory map for the device memory will be
628 allocated from the kernel zones.
629
630 - KASAN can have a significant memory overhead, for example, consuming 1/8th of
631 the total system memory size as (unmovable) tracking metadata.
632
633 - Long-term pinning of pages. Techniques that rely on long-term pinnings
634 (especially, RDMA and vfio/mdev) are fundamentally problematic with
635 ZONE_MOVABLE, and therefore, memory offlining. Pinned pages cannot reside
636 on ZONE_MOVABLE as that would turn these pages unmovable. Therefore, they
637 have to be migrated off that zone while pinning. Pinning a page can fail
638 even if there is plenty of free memory in ZONE_MOVABLE.
639
640 In addition, using ZONE_MOVABLE might make page pinning more expensive,
641 because of the page migration overhead.
642
643 By default, all the memory configured at boot time is managed by the kernel
644 zones and ZONE_MOVABLE is not used.
645
646 To enable ZONE_MOVABLE to include the memory present at boot and to control the
647 ratio between movable and kernel zones there are two command line options:
648 ``kernelcore=`` and ``movablecore=``. See
649 Documentation/admin-guide/kernel-parameters.rst for their description.
650
651 Memory Offlining and ZONE_MOVABLE
652 ---------------------------------
653
654 Even with ZONE_MOVABLE, there are some corner cases where offlining a memory
655 block might fail:
656
657 - Memory blocks with memory holes; this applies to memory blocks present during
658 boot and can apply to memory blocks hotplugged via the XEN balloon and the
659 Hyper-V balloon.
660
661 - Mixed NUMA nodes and mixed zones within a single memory block prevent memory
662 offlining; this applies to memory blocks present during boot only.
663
664 - Special memory blocks prevented by the system from getting offlined. Examples
665 include any memory available during boot on arm64 or memory blocks spanning
666 the crashkernel area on s390x; this usually applies to memory blocks present
667 during boot only.
668
669 - Memory blocks overlapping with CMA areas cannot be offlined, this applies to
670 memory blocks present during boot only.
671
672 - Concurrent activity that operates on the same physical memory area, such as
673 allocating gigantic pages, can result in temporary offlining failures.
674
675 - Out of memory when dissolving huge pages, especially when HugeTLB Vmemmap
676 Optimization (HVO) is enabled.
677
678 Offlining code may be able to migrate huge page contents, but may not be able
679 to dissolve the source huge page because it fails allocating (unmovable) pages
680 for the vmemmap, because the system might not have free memory in the kernel
681 zones left.
682
683 Users that depend on memory offlining to succeed for movable zones should
684 carefully consider whether the memory savings gained from this feature are
685 worth the risk of possibly not being able to offline memory in certain
686 situations.
687
688 Further, when running into out of memory situations while migrating pages, or
689 when still encountering permanently unmovable pages within ZONE_MOVABLE
690 (-> BUG), memory offlining will keep retrying until it eventually succeeds.
691
692 When offlining is triggered from user space, the offlining context can be
693 terminated by sending a signal. A timeout based offlining can easily be
694 implemented via::
695
696 % timeout $TIMEOUT offline_block | failure_handling
697

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

문서 개요

1-9

이 문서는 System RAM과 ZONE_MOVABLE 지원을 중심으로 Linux의 일반적인 memory hotplug 및 hotunplug 기능을 설명합니다. 아래 내용은 원문의 local contents가 가리키는 구성·상태·정책·실패 조건을 순서대로 번역합니다.

소개와 사용 목적

10-37

Memory hot(un)plug는 실행 중인 machine에서 사용할 수 있는 physical memory 크기를 늘리거나 줄입니다. 가장 단순한 형태는 operating system과 조율하면서 runtime에 DIMM을 물리적으로 꽂거나 빼는 것입니다.

목적설명
동적 용량runtime에 physical memory를 증감하는 "capacity on demand"; virtual machine과 logical partition에서 흔히 사용
무중단 교체고장 난 DIMM 또는 전체 NUMA node 같은 hardware를 downtime 없이 교체
전력 절감memory module을 물리적으로 제거하거나 일부를 Linux에서 논리적으로 분리
System RAM 노출persistent memory, 성능 특성이 다른 memory, reserved region을 일반 System RAM으로 제공

Linux의 기본 memory hot(un)plug infrastructure는 이제 persistent memory, 성능 특성이 다른 memory와 reserved memory region을 일반 System RAM으로 노출하는 데도 쓰입니다. 지원 범위는 x86_64, arm64, ppc64, s390x 같은 일부 64-bit architecture로 한정됩니다.

Memory block 단위

38-52

Linux memory hot(un)plug는 physical address space를 같은 크기의 memory section으로 나누는 SPARSEMEM model을 사용합니다. section 크기는 architecture별로 다르며, 예를 들어 x86_64는 128 MiB, ppc64는 16 MiB입니다.

여러 memory section은 memory block으로 결합됩니다. memory block 크기는 architecture가 hot(un)plug할 수 있는 최소 단위이며, 별도 지정이 없으면 memory section 크기와 같습니다. 한 system의 모든 memory block 크기는 동일합니다.

Memory hotplug 단계

53-69

Memory hotplug는 (1) memory를 Linux에 추가하고 (2) memory block을 online하는 두 단계로 진행됩니다.

단계처리
addmemory map("memmap") 같은 metadata와 direct mapping용 page table을 할당·초기화하고 memory block 및 관리용 sysfs 파일을 생성
online추가된 memory를 page allocator에 공개하여 system의 free·total memory 통계에 반영

Memory hotunplug 단계

70-84

Memory hotunplug는 (1) memory block을 offline하고 (2) Linux에서 memory를 제거하는 두 단계입니다.

단계처리
offline사용 중인 memory를 다른 위치로 migrate하고 관련 free page를 page allocator에서 제거하여 memory 통계에서 숨김
removememory block을 제거하고 metadata를 해제

Hotplug notification

85-110

Linux가 hotplug된 memory를 추가하려면 event를 통지받아야 합니다. 이 절은 ACPI를 지원하는 system만 다루며 다른 firmware interface나 virtual machine 전용 mechanism은 설명하지 않습니다.

x86_64 같은 ACPI platform에서 firmware는 일반적으로 HID "PNP0C80"인 memory class object를 정의합니다. 새 memory device의 hotplug notification을 받으면 ACPI driver가 해당 memory를 Linux에 hotplug합니다.

NUMA node hotplug를 지원하는 firmware는 _HID "ACPI0004", "PNP0A05" 또는 "PNP0A06" object를 정의합니다. event가 오면 ACPI driver가 배정된 모든 memory device를 추가합니다. 반대로 memory device나 NUMA node의 hotunplug 요청도 ACPI로 받을 수 있고, driver는 관련 block을 모두 offline한 뒤 성공한 경우에만 Linux에서 memory를 제거합니다.

수동 probe

111-135

일부 architecture의 firmware는 memory hotplug event를 OS에 통지하지 못하므로 user space에서 수동 probe해야 합니다. probe interface는 다음 위치입니다.

/sys/devices/system/memory/probe

완전한 memory block만 probe할 수 있습니다. block의 physical 시작 주소 addr를 다음처럼 기록합니다.

% echo addr > /sys/devices/system/memory/probe

그 결과 [addr, addr + memory_block_size) 범위의 memory block이 생성됩니다.

Linux는 user input을 검증할 수 없어 kernel crash를 일으키기 쉬우므로 probe interface 사용은 권장되지 않습니다. 이 interface는 앞으로 제거될 수 있습니다.

Online과 offline의 의미

136-150

memory block을 만든 뒤 Linux가 실제로 사용하려면 block을 online해야 합니다. 반대로 제거하기 전에는 block에 속한 어떤 memory도 Linux가 사용하지 않도록 offline해야 합니다.

Kernel은 새 block을 자동 online하도록 구성할 수 있고, driver는 memory hotunplug를 시도할 때 자동으로 offline을 시작할 수 있습니다. memory block은 offlining에 성공한 뒤에만 제거할 수 있습니다.

수동 online

151-181

auto-onlining이 꺼져 있으면 user space가 online을 직접 실행해야 하며, 보통 udev rule로 자동화합니다. 기본 state interface는 다음과 같습니다.

% echo online > /sys/devices/system/memory/memoryXXX/state

단순 online interface에서는 1을 기록합니다.

% echo 1 > /sys/devices/system/memory/memoryXXX/online

target zone을 지정하지 않으면 kernel이 설정된 online_policy에 따라 자동 선택합니다. ZONE_MOVABLE을 명시하려면 다음 명령을 사용합니다.

% echo online_movable > /sys/devices/system/memory/memoryXXX/state

보통 ZONE_NORMAL인 kernel zone을 명시하려면 다음과 같이 합니다.

% echo online_kernel > /sys/devices/system/memory/memoryXXX/state

성공하면 block state가 online으로 바뀝니다. 실패하면 상태는 그대로이며 명령도 실패로 끝납니다.

자동 online

182-213

Kernel은 새로 추가한 memory block을 자동 online하도록 구성할 수 있습니다. 기능이 꺼져 있으면 user space가 명시적으로 online할 때까지 block은 offline에 머뭅니다. 현재 동작은 다음처럼 확인합니다.

% cat /sys/devices/system/memory/auto_online_blocks

online, online_kernel 또는 online_movable을 기록해 auto-onlining을 켤 수 있습니다.

% echo online > /sys/devices/system/memory/auto_online_blocks

online 값은 online_policy에 따라 target zone을 자동 선택합니다. 설정 변경은 이후에 추가되는 memory block에만 적용됩니다.

Corner case에서 auto-onlining이 실패할 수 있으며 kernel은 재시도하지 않습니다. 다만 기본 구성에서는 실패하지 않을 것으로 예상합니다.

ppc64의 DLPAR는 offline 설정을 무시하고 추가된 block을 계속 online합니다. online이 실패하면 그 block을 다시 제거합니다.

Memory block offline

214-246

현재 구현은 대상 block에서 모든 movable page를 다른 곳으로 migrate합니다. page table을 포함한 대부분의 kernel allocation은 unmovable이므로 migration과 offlining이 실패할 수 있습니다.

block의 memory를 ZONE_MOVABLE에서 관리하면 성공 신뢰성이 크게 높아지지만 corner case 실패는 남습니다. offlining은 사용자가 중단할 때까지 매우 오래, 심하면 영원히 재시도할 수도 있습니다.

% echo offline > /sys/devices/system/memory/memoryXXX/state

단순 interface에서는 0을 기록합니다.

% echo 0 > /sys/devices/system/memory/memoryXXX/online

성공하면 state가 offline으로 바뀌고, 실패하면 상태가 유지되며 명령은 다음 오류 중 하나를 낼 수 있습니다.

bash: echo: write error: Device or resource busy
bash: echo: write error: Invalid argument

Memory block 상태 관찰

247-262

memory block의 online, offline, going-offline 상태는 state에서 확인합니다.

% cat /sys/devices/system/memory/memoryXXX/state

1 또는 0으로 보는 대체 interface는 online입니다.

% cat /sys/devices/system/memory/memoryXXX/online

online block을 관리하는 zone은 valid_zones로 확인합니다.

% cat /sys/devices/system/memory/memoryXXX/valid_zones

전역 sysfs 구성

263-312

System administrator는 여러 interface로 memory hot(un)plug를 구성하고 block, 특히 online 동작을 제어할 수 있습니다. 전역 속성은 다음 directory에 있습니다.

/sys/devices/system/memory/
파일접근기능
auto_online_blocksread-write새 memory block의 기본 상태와 auto-onlining을 설정·조회. 기본값은 CONFIG_MHP_DEFAULT_ONLINE_TYPE에 따르며 자세한 값은 block의 state 속성과 동일
block_size_bytesread-onlymemory block 크기를 byte 단위로 표시
probewrite-onlyphysical 시작 주소를 받아 user space에서 block을 수동 probe. CONFIG_ARCH_MEMORY_PROBE에 의존
ueventread-writedevice subsystem용 일반 udev 파일
crash_hotplugread-onlymemory map 변경 시 kernel이 elfcorehdr와 관련 kexec segment를 포함한 kdump capture-kernel map을 갱신하면 1, user space가 갱신해야 하면 0. CONFIG_MEMORY_HOTPLUG에 의존

CONFIG_MEMORY_FAILURE가 켜져 있으면 test 목적의 page hwpoisoning을 실행하는 hard_offline_page와 soft_offline_page가 추가됩니다. 이 기능은 memory block의 실제 offlining이나 memory hot(un)plug 자체와 직접 관련되지는 않습니다.

Block별 sysfs 구성

313-395

각 memory block은 online 또는 offline할 수 있는 block device로 표현되며 device 정보는 sysfs에 있습니다. 존재하는 block은 다음 경로에 나열됩니다.

/sys/devices/system/memory/memoryXXX

XXX는 자릿수가 가변인 memory block id입니다. present block은 해당 범위에 일부 memory가 있음을 뜻하지만 memory hole을 포함할 수 있고, hole을 가로지르는 block은 offline할 수 없습니다.

예를 들어 block 크기가 1 GiB이고 시작 주소가 0x100000000이면 id는 다음 계산으로 4가 됩니다.

(0x100000000 / 1Gib = 4)

따라서 /sys/devices/system/memory/memory4는 [0x100000000 ... 0x140000000) 주소 범위를 담당합니다.

파일접근기능
onlineread-writeonline/offline을 실행하고 상태를 보는 단순 interface. online 시 zone은 자동 선택
phys_deviceread-onlys390x에서 covered storage increment를 노출하던 legacy interface
phys_indexread-onlymemory block id인 XXX
removableread-only과거 offline 가능성을 추정하던 legacy interface. 현재는 kernel이 memory offlining을 지원할 때만 1
stateread-write고급 상태 interface. write: online, offline, online_kernel, online_movable. read: online, offline, going-offline
ueventread-writedevice용 일반 uevent 파일
valid_zonesread-onlyonline block은 현재 zone, offline block은 지금 online할 때 선택될 zone을 표시. DMA, DMA32, Normal, Movable, none을 반환하며 CONFIG_MEMORY_HOTREMOVE에 의존

state에 online_movable을 쓰면 ZONE_MOVABLE, online_kernel을 쓰면 ZONE_NORMAL 같은 기본 kernel zone에 배치합니다. online은 자동 선택합니다. valid_zones의 Movable은 ZONE_MOVABLE이고 DMA, DMA32, Normal은 kernel zone입니다. none은 여러 zone이나 node에 걸쳐 있어 offline할 수 없음을 뜻합니다. offline block에서는 첫 column이 지금 zone을 지정하지 않고 online할 때 kernel이 고를 zone입니다.

CONFIG_NUMA가 켜져 있으면 memoryXXX directory를 /sys/devices/system/node/node* 아래 symbolic link로도 접근할 수 있습니다.

/sys/devices/system/node/node0/memory9 -> ../../memory/memory9

memory block 쪽에는 NUMA node로 돌아가는 backlink도 생성됩니다.

/sys/devices/system/memory/memory9/node0 -> ../../node/node0

Kernel command line

396-414

memory hot(un)plug 처리에 영향을 주는 command line parameter는 다음 두 가지입니다.

매개변수기능
memhp_default_state/sys/devices/system/memory/auto_online_blocks를 설정하는 방식으로 auto-onlining 구성
movable_nodecontig-zones policy에서 자동 zone 선택을 구성. 다른 zone의 연속성을 유지할 수 없으면 ZONE_MOVABLE을 기본 선택

더 일반적인 설명은 Documentation/admin-guide/kernel-parameters.txt를 참조합니다.

Module parameter

415-551

memory_hotplug subsystem은 추가 command line option이나 sysfs file 대신 전용 module parameter namespace를 제공합니다. boot command line에서는 memory_hotplug. prefix를 붙입니다.

memory_hotplug.memmap_on_memory=1

parameter는 다음 directory에서 확인하며 일부는 runtime에 바꿀 수 있습니다.

/sys/module/memory_hotplug/parameters/
매개변수접근기능
memmap_on_memoryread-write추가한 block 자체에서 memmap을 할당하도록 요청하는 hint. hotplug 실패 가능성과 NUMA 원격 배치를 줄이지만 큰 huge page를 만들 물리 메모리를 단편화할 수 있음. force는 pageblock 정렬 때문에 메모리를 낭비할 수 있으며 모든 구성에서 강제되지는 않음
online_policyread-writetarget zone을 지정하지 않은 online의 기본 정책. contig-zones는 zone 연속성을 우선하고 movable_node에 따라 fallback하며, auto-movable은 장치 단위와 ratio를 고려해 가능한 block을 ZONE_MOVABLE로 배치
auto_movable_ratioread-writeauto-movable의 최대 MOVABLE:KERNEL 비율(%). 기본 301이며 present page, device별 회계, CMA를 MOVABLE로 계산. 서로 다른 장치의 ZONE_NORMAL은 다른 장치의 MOVABLE 허용량을 늘리지 않음
auto_movable_numa_awareread-writeauto_movable_ratio를 전체 system뿐 아니라 NUMA node별로도 적용할지 선택. 기본 Y이며 CONFIG_NUMA에 의존

memmap_on_memory를 사용하면 memmap이 같은 NUMA node에 남고 hotplug가 실패할 가능성이 낮아지지만, 예를 들어 memmap 1 MiB를 pageblock 2 MiB에 맞추면 1 MiB가 낭비됩니다. force라도 memmap이 한 page보다 작거나 architecture가 해당 구성을 지원하지 않으면 강제할 수 없습니다.

online_policy=contig-zones는 zone을 연속으로 유지하려 합니다. block이 여러 zone과 교차하거나 어느 zone에도 속하지 않으면 movable_node가 설정된 경우 ZONE_MOVABLE, 아니면 보통 ZONE_NORMAL인 kernel zone을 선택합니다. memory를 online한 뒤에는 policy를 바꾸지 않아야 합니다.

online_policy=auto-movable은 구성과 device 정보를 바탕으로 가능한 block을 ZONE_MOVABLE로 online하여 대량 hotplug 뒤의 zone imbalance를 피하면서 reliable hotunplug 범위를 넓히려는 virtualization용 정책입니다. movable_node는 무시하므로 firmware memory map으로 boot 초기에 hotpluggable node가 노출되는 bare-metal 구성에는 적합하지 않습니다.

hotplug DIMM은 전체가 ZONE_MOVABLE 또는 전체가 ZONE_NORMAL이 되며 둘을 섞지 않습니다. virtio-mem은 함께 hotunplug해야 하는 block unit을 특별 처리하면서 가능한 많은 block을 ZONE_MOVABLE에 둡니다. 이 정책은 ZONE_MOVABLE 자체가 문제인 구성을 보호하지 않으며, 한번 online한 block의 zone을 동적으로 바꾸지도 않습니다.

auto_movable_ratio는 auto-movable의 최대 MOVABLE:KERNEL 비율을 percent로 정합니다. 회계는 zone의 present page와 device별 수치를 결합하고 kernel zone 안의 CMA memory도 MOVABLE로 셉니다. 기본값 301%는 여러 구성에서 8 GiB VM에 24 GiB를 hotplug해 전부 ZONE_MOVABLE로 online할 수 있게 하며, 추가 1%는 firmware allocation 등으로 present가 아닌 page를 보정합니다.

한 memory device가 제공한 ZONE_NORMAL memory는 다른 device의 ZONE_MOVABLE 허용량을 늘리지 않습니다. 한 hotplug DIMM을 ZONE_NORMAL로 online해도 다른 DIMM의 자동 MOVABLE 배치를 허용하지 않습니다. 반면 virtio-mem device 내부에서 ZONE_NORMAL로 online된 memory는 같은 device의 ZONE_MOVABLE 허용량을 늘릴 수 있습니다.

auto_movable_numa_aware=Y가 기본이며 ratio를 system 전체뿐 아니라 NUMA node별로도 적용합니다. 완전히 hotunplug할 node를 다룰 때 이를 끄면 가능한 경우 node memory 전체를 ZONE_MOVABLE로 자동 online하는 데 도움이 됩니다. 이 parameter는 CONFIG_NUMA에 의존합니다.

ZONE_MOVABLE 기본 원리

552-570

ZONE_MOVABLE은 memory offlining의 신뢰성을 높이는 핵심 mechanism입니다. System RAM을 kernel zone 대신 ZONE_MOVABLE에서 관리하면 만들 수 있는 transparent huge page와 동적 huge page 수가 늘어날 수도 있습니다.

memory map은 보통 전체 memory의 1/64을 차지하며 page table과 kmalloc()도 대표적인 unmovable kernel allocation입니다. 이들은 kernel zone에서만 제공할 수 있습니다. 반면 anonymous memory와 page cache 같은 대부분의 user-space page는 movable이어서 ZONE_MOVABLE과 kernel zone 양쪽에서 할당할 수 있습니다.

ZONE_MOVABLE은 movable allocation만 받아 unmovable allocation을 kernel zone에 제한합니다. ZONE_MOVABLE이 없으면 어떤 memory block의 offlining 성공도 보장할 수 없습니다.

Zone imbalance

571-590

System RAM을 ZONE_MOVABLE에서 지나치게 많이 관리하는 상태를 zone imbalance라고 하며 system을 손상시키거나 성능을 낮출 수 있습니다. ZONE_MOVABLE에 free memory가 충분해도 unmovable allocation용 kernel-zone memory가 고갈되어 kernel이 crash할 수 있습니다.

일반적으로 MOVABLE:KERNEL 비율 3:1 또는 4:1까지는 괜찮지만 memory map overhead 때문에 63:1은 명백히 불가능합니다. 실제 안전 비율은 workload에 달려 있고, 과도한 long-term page pinning 같은 극단적 사례는 ZONE_MOVABLE을 전혀 감당하지 못할 수 있습니다.

kernel zone 안의 CMA memory는 본질적으로 ZONE_MOVABLE memory처럼 동작하므로, 특히 CMA와 ZONE_MOVABLE을 함께 쓸 때 같은 비율 검토가 필요합니다.

ZONE_MOVABLE 크기 산정

591-650

보통 available System RAM의 큰 부분은 user space가 직접 사용하거나 page cache를 통해 간접 사용합니다. 이런 page는 일반적으로 ZONE_MOVABLE에서 문제없이 할당할 수 있으므로 상당한 RAM을 MOVABLE로 관리하는 것이 합리적입니다. 다만 zone ratio를 조정할 때 다음 항목을 검토해야 합니다.

검토 항목영향
많은 offline blockoffline 상태도 metadata와 direct-map page table을 소비하지만 일반적인 구성은 아님
balloon compaction 없음ZONE_MOVABLE과 호환되지 않음. virtio-balloon과 pseries CMM 등 일부만 완전 지원하며 CONFIG_BALLOON_COMPACTION이 꺼지면 inflation이 unmovable allocation으로 zone imbalance를 만듦
gigantic pageunmovable이므로 user space가 kernel-zone memory를 많이 소비
huge page migration 없음architecture가 migration을 지원하지 않으면 huge page도 unmovable
page tableunmovable. 과도한 swapping, 매우 큰 file 또는 ZONE_DEVICE mapping은 corner case에서 kernel zone을 압박
DAX일부 구성에서는 device memory의 memory map을 kernel zone에서 할당
KASANtracking metadata가 total system memory의 1/8 같은 큰 unmovable overhead를 만들 수 있음
장기 page pinningRDMA와 vfio/mdev는 ZONE_MOVABLE 및 offlining과 근본적으로 충돌. pin 전에 page를 zone 밖으로 migrate해야 하며 여유 MOVABLE memory가 있어도 실패하거나 비용이 증가할 수 있음

Long-term pinning은 pinned page를 ZONE_MOVABLE에 둘 수 없으므로 pin하는 동안 zone 밖으로 migrate해야 합니다. 그 결과 free MOVABLE memory가 충분해도 pin이 실패할 수 있고 migration overhead로 비용이 커집니다.

기본적으로 boot 때 구성된 모든 memory는 kernel zone에서 관리하며 ZONE_MOVABLE은 사용하지 않습니다. boot memory를 ZONE_MOVABLE에 포함하고 movable/kernel zone 비율을 제어하려면 kernelcore=와 movablecore= command line option을 사용합니다. 설명은 Documentation/admin-guide/kernel-parameters.rst를 참조합니다.

ZONE_MOVABLE에서도 남는 실패 조건

651-696

ZONE_MOVABLE을 사용해도 memory block offlining이 실패하는 corner case가 남습니다.

조건설명
memory holeboot memory block, XEN balloon 또는 Hyper-V balloon으로 hotplug한 block에 적용 가능
혼합 NUMA node·zone한 block에 여러 node 또는 zone이 섞이면 offline 불가. boot 당시 block에만 해당
system 보호 blockarm64 boot memory, s390x crashkernel 영역을 가로지르는 block 등
CMA overlapCMA 영역과 겹치는 boot memory block은 offline 불가
동시 물리 메모리 작업gigantic page 할당처럼 같은 영역을 다루는 activity가 일시 실패를 유발
huge page 해체 OOM특히 HVO 사용 시 source huge page의 vmemmap용 unmovable page를 kernel zone에서 할당하지 못할 수 있음

Offlining code가 huge page 내용은 migrate해도 source huge page를 해체하지 못할 수 있습니다. 특히 HugeTLB Vmemmap Optimization(HVO)이 켜진 상태에서 kernel zone에 vmemmap용 free unmovable page가 없으면 allocation이 실패합니다. movable zone의 offlining 성공에 의존하는 사용자는 HVO의 절감 이득과 offline 불가 위험을 함께 평가해야 합니다.

page migration 중 out-of-memory가 발생하거나 ZONE_MOVABLE 안에서 영구적인 unmovable page를 계속 발견하면 이는 BUG이며, memory offlining은 성공할 때까지 재시도합니다. User space에서 시작한 offlining context는 signal로 종료할 수 있고 timeout 기반 처리는 다음처럼 구현할 수 있습니다.

% timeout $TIMEOUT offline_block | failure_handling