← Documents Documentation/core-api/kho/concepts.rst GitHub 원문 ↗

Linux 6.18.37 · Core API

Kexec Handover Concepts

Kexec 사이에서 상태 메모리를 보존하는 KHO의 FDT, NUMA별 scratch region, CMA 격리와 finalization phase를 설명합니다.

Source pathDocumentation/core-api/kho/concepts.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약과 해설

concepts.rst:1-74

KHO는 직렬화한 subsystem 상태나 유지해야 할 in-memory data를 물리 메모리에 남기고, 별도의 KHO FDT로 그 위치를 다음 kernel에 전달합니다. 이 FDT는 device tree의 저장 형식과 `libfdt`만 빌리며 일반 device tree property 규칙은 사용하지 않습니다.

새 kernel과 initrd 및 초기 부팅 할당에는 인계 메모리와 겹치지 않는 scratch region을 사용합니다. NUMA node별 영역과 node 비지정 할당용 영역을 준비하고 CMA로 관리하여 고정 위치가 필요한 handover page가 들어오지 못하게 합니다.

현재 상태를 담은 FDT가 생성된 뒤에는 기록된 system property를 바꿀 수 없을 수 있습니다. 이 시점을 KHO finalization phase라 하며, user space 기반 kexec file loader가 실행 전에 인계 정보를 얻도록 하는 핵심 경계입니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0-or-later
2 .. _kho-concepts:
3
4 =======================
5 Kexec Handover Concepts
6 =======================
7
8 Kexec HandOver (KHO) is a mechanism that allows Linux to preserve memory
9 regions, which could contain serialized system states, across kexec.
10
11 It introduces multiple concepts:
12
13 KHO FDT
14 =======
15
16 Every KHO kexec carries a KHO specific flattened device tree (FDT) blob
17 that describes preserved memory regions. These regions contain either
18 serialized subsystem states, or in-memory data that shall not be touched
19 across kexec. After KHO, subsystems can retrieve and restore preserved
20 memory regions from KHO FDT.
21
22 KHO only uses the FDT container format and libfdt library, but does not
23 adhere to the same property semantics that normal device trees do: Properties
24 are passed in native endianness and standardized properties like ``regs`` and
25 ``ranges`` do not exist, hence there are no ``#...-cells`` properties.
26
27 KHO is still under development. The FDT schema is unstable and would change
28 in the future.
29
30 Scratch Regions
31 ===============
32
33 To boot into kexec, we need to have a physically contiguous memory range that
34 contains no handed over memory. Kexec then places the target kernel and initrd
35 into that region. The new kernel exclusively uses this region for memory
36 allocations before during boot up to the initialization of the page allocator.
37
38 We guarantee that we always have such regions through the scratch regions: On
39 first boot KHO allocates several physically contiguous memory regions. Since
40 after kexec these regions will be used by early memory allocations, there is a
41 scratch region per NUMA node plus a scratch region to satisfy allocations
42 requests that do not require particular NUMA node assignment.
43 By default, size of the scratch region is calculated based on amount of memory
44 allocated during boot. The ``kho_scratch`` kernel command line option may be
45 used to explicitly define size of the scratch regions.
46 The scratch regions are declared as CMA when page allocator is initialized so
47 that their memory can be used during system lifetime. CMA gives us the
48 guarantee that no handover pages land in that region, because handover pages
49 must be at a static physical memory location and CMA enforces that only
50 movable pages can be located inside.
51
52 After KHO kexec, we ignore the ``kho_scratch`` kernel command line option and
53 instead reuse the exact same region that was originally allocated. This allows
54 us to recursively execute any amount of KHO kexecs. Because we used this region
55 for boot memory allocations and as target memory for kexec blobs, some parts
56 of that memory region may be reserved. These reservations are irrelevant for
57 the next KHO, because kexec can overwrite even the original kernel.
58
59 .. _kho-finalization-phase:
60
61 KHO finalization phase
62 ======================
63
64 To enable user space based kexec file loader, the kernel needs to be able to
65 provide the FDT that describes the current kernel's state before
66 performing the actual kexec. The process of generating that FDT is
67 called serialization. When the FDT is generated, some properties
68 of the system may become immutable because they are already written down
69 in the FDT. That state is called the KHO finalization phase.
70
71 Public API
72 ==========
73 .. kernel-doc:: kernel/kexec_handover.c
74 :export:
75

3. 한국어 전문 번역

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

Kexec 인계 개념

1-12

SPDX 라이선스 식별자: GPL-2.0-or-later

Kexec 인계 개념 (Kexec Handover Concepts)

Kexec HandOver(KHO)는 직렬화된 시스템 상태를 담을 수 있는 메모리 영역을 Linux가 `kexec` 이후에도 보존할 수 있게 하는 메커니즘입니다.

KHO는 아래의 여러 개념을 도입합니다.

KHO FDT

13-29

모든 KHO kexec에는 보존된 메모리 영역을 기술하는 KHO 전용 FDT(flattened device tree) blob이 포함됩니다. 이 영역에는 직렬화된 subsystem 상태 또는 `kexec` 과정에서 건드리지 않아야 할 in-memory data가 들어 있습니다. KHO 이후 subsystem은 KHO FDT에서 보존된 메모리 영역을 찾아 복원할 수 있습니다.

KHO는 FDT container format과 `libfdt` library만 사용하며 일반 device tree의 property semantics를 따르지는 않습니다. Property는 native endianness로 전달되고, `regs`나 `ranges` 같은 표준 property가 없으므로 `#...-cells` property도 없습니다.

KHO는 아직 개발 중입니다. FDT schema는 안정화되지 않았으며 앞으로 변경될 수 있습니다.

스크래치 영역의 목적

30-37

스크래치 영역 (Scratch Regions)

`kexec`로 부팅하려면 인계되는 메모리를 전혀 포함하지 않는 물리적으로 연속된 메모리 범위가 필요합니다. Kexec는 그 영역에 대상 kernel과 initrd를 배치합니다. 새 kernel은 부팅 중 page allocator가 초기화될 때까지 메모리 할당에 이 영역만 사용합니다.

스크래치 영역 할당

38-45

KHO는 scratch region을 통해 이러한 영역이 항상 존재하도록 보장합니다. 첫 부팅에서 KHO는 물리적으로 연속된 메모리 영역을 여러 개 할당합니다. `kexec` 이후 이 영역을 early memory allocation에 사용하므로 NUMA node마다 scratch region 하나를 두고, 특정 NUMA node 배치를 요구하지 않는 allocation request를 처리할 scratch region도 하나 더 둡니다.

기본적으로 scratch region의 크기는 부팅 중 할당된 메모리 양을 기준으로 계산합니다. `kho_scratch` kernel command line option으로 scratch region의 크기를 명시적으로 지정할 수 있습니다.

CMA와 인계 페이지 격리

46-50

Page allocator를 초기화할 때 scratch region을 CMA로 선언하므로 시스템이 동작하는 동안 그 메모리를 사용할 수 있습니다. 인계 페이지는 고정된 물리 메모리 위치에 있어야 하는 반면 CMA는 movable pages만 내부에 둘 수 있도록 강제합니다. 따라서 CMA는 handover page가 scratch region에 들어오지 않는다는 보장을 제공합니다.

KHO 이후 스크래치 영역 재사용

51-58

KHO kexec 이후에는 `kho_scratch` kernel command line option을 무시하고 처음 할당했던 것과 정확히 같은 영역을 재사용합니다. 따라서 KHO kexec를 횟수 제한 없이 재귀적으로 실행할 수 있습니다.

이 영역을 boot memory allocation과 kexec blob의 대상 메모리로 사용했기 때문에 일부가 예약되어 있을 수 있습니다. 그러나 kexec는 원래 kernel까지 덮어쓸 수 있으므로 이러한 예약은 다음 KHO에는 중요하지 않습니다.

KHO 최종화 단계

59-70

참조 대상: `kho-finalization-phase`

User space 기반 kexec file loader를 지원하려면 실제 `kexec`를 수행하기 전에 kernel이 현재 kernel 상태를 기술하는 FDT를 제공할 수 있어야 합니다. 이 FDT를 생성하는 과정을 serialization이라고 합니다.

FDT가 생성되면 시스템의 일부 property는 이미 FDT에 기록되었으므로 변경할 수 없게 될 수 있습니다. 이 상태를 KHO finalization phase라고 합니다.

공개 API

71-74

공개 API (Public API)

KHO의 공개 API는 `kernel/kexec_handover.c`에서 export된 kernel-doc 항목으로 구성됩니다.

.. kernel-doc:: kernel/kexec_handover.c
   :export: