요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
=======================
Linux Init (Early Boot)
=======================
Linux configuration is split into two major steps: Early-Boot and everything else.
During early boot, Linux sets up immutable resources (such as numa nodes), while
later operations include things like driver probe and memory hotplug. Linux may
read EFI and ACPI information throughout this process to configure logical
representations of the devices.
During Linux Early Boot stage (functions in the kernel that have the __init
decorator), the system takes the resources created by EFI/BIOS
(:doc:`ACPI tables <../platform/acpi>`) and turns them into resources that the
kernel can consume.
BIOS, Build and Boot Options
============================
There are 4 pre-boot options that need to be considered during kernel build
which dictate how memory will be managed by Linux during early boot.
* EFI_MEMORY_SP
* BIOS/EFI Option that dictates whether memory is SystemRAM or
Specific Purpose. Specific Purpose memory will be deferred to
drivers to manage - and not immediately exposed as system RAM.
* CONFIG_EFI_SOFT_RESERVE
* Linux Build config option that dictates whether the kernel supports
Specific Purpose memory.
* CONFIG_MHP_DEFAULT_ONLINE_TYPE
* Linux Build config that dictates whether and how Specific Purpose memory
converted to a dax device should be managed (left as DAX or onlined as
SystemRAM in ZONE_NORMAL or ZONE_MOVABLE).
* nosoftreserve
* Linux kernel boot option that dictates whether Soft Reserve should be
supported. Similar to CONFIG_EFI_SOFT_RESERVE.
Memory Map Creation
===================
While the kernel parses the EFI memory map, if :code:`Specific Purpose` memory
is supported and detected, it will set this region aside as
:code:`SOFT_RESERVED`.
If :code:`EFI_MEMORY_SP=0`, :code:`CONFIG_EFI_SOFT_RESERVE=n`, or
:code:`nosoftreserve=y` - Linux will default a CXL device memory region to
SystemRAM. This will expose the memory to the kernel page allocator in
:code:`ZONE_NORMAL`, making it available for use for most allocations (including
:code:`struct page` and page tables).
If `Specific Purpose` is set and supported, :code:`CONFIG_MHP_DEFAULT_ONLINE_TYPE_*`
dictates whether the memory is onlined by default (:code:`_OFFLINE` or
:code:`_ONLINE_*`), and if online which zone to online this memory to by default
(:code:`_NORMAL` or :code:`_MOVABLE`).
If placed in :code:`ZONE_MOVABLE`, the memory will not be available for most
kernel allocations (such as :code:`struct page` or page tables). This may
significant impact performance depending on the memory capacity of the system.
NUMA Node Reservation
=====================
Linux refers to the proximity domains (:code:`PXM`) defined in the :doc:`SRAT
<../platform/acpi/srat>` to create NUMA nodes in :code:`acpi_numa_init`.
Typically, there is a 1:1 relation between :code:`PXM` and NUMA node IDs.
The SRAT is the only ACPI defined way of defining Proximity Domains. Linux
chooses to, at most, map those 1:1 with NUMA nodes.
:doc:`CEDT <../platform/acpi/cedt>` adds a description of SPA ranges which
Linux may map to one or more NUMA nodes.
If there are CXL ranges in the CFMWS but not in SRAT, then a fake :code:`PXM`
is created (as of v6.15). In the future, Linux may reject CFMWS not described
by SRAT due to the ambiguity of proximity domain association.
It is important to note that NUMA node creation cannot be done at runtime. All
possible NUMA nodes are identified at :code:`__init` time, more specifically
during :code:`mm_init`. The CEDT and SRAT must contain sufficient :code:`PXM`
data for Linux to identify NUMA nodes their associated memory regions.
The relevant code exists in: :code:`linux/drivers/acpi/numa/srat.c`.
See :doc:`Example Platform Configurations <../platform/example-configs>`
for more info.
Memory Tiers Creation
=====================
Memory tiers are a collection of NUMA nodes grouped by performance characteristics.
During :code:`__init`, Linux initializes the system with a default memory tier that
contains all nodes marked :code:`N_MEMORY`.
:code:`memory_tier_init` is called at boot for all nodes with memory online by
default. :code:`memory_tier_late_init` is called during late-init for nodes setup
during driver configuration.
Nodes are only marked :code:`N_MEMORY` if they have *online* memory.
Tier membership can be inspected in ::
/sys/devices/virtual/memory_tiering/memory_tierN/nodelist
0-1
If nodes are grouped which have clear difference in performance, check the
:doc:`HMAT <../platform/acpi/hmat>` and CDAT information for the CXL nodes. All
nodes default to the DRAM tier, unless HMAT/CDAT information is reported to the
memory_tier component via `access_coordinates`.
For more, see :doc:`CXL access coordinates documentation
<../linux/access-coordinates>`.
Contiguous Memory Allocation
============================
The contiguous memory allocator (CMA) enables reservation of contiguous memory
regions on NUMA nodes during early boot. However, CMA cannot reserve memory
on NUMA nodes that are not online during early boot. ::
void __init hugetlb_cma_reserve(int order) {
if (!node_online(nid))
/* do not allow reservations */
}
This means if users intend to defer management of CXL memory to the driver, CMA
cannot be used to guarantee huge page allocations. If enabling CXL memory as
SystemRAM in `ZONE_NORMAL` during early boot, CMA reservations per-node can be
made with the :code:`cma_pernuma` or :code:`numa_cma` kernel command line
parameters.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Linux 초기화와 early boot
1-19.. SPDX-License-Identifier: GPL-2.0
Linux 구성은 크게 Early-Boot 단계와 그 이후의 모든 단계로 나뉩니다.
early boot 동안 Linux는 NUMA node와 같은 변경 불가능한 resource를 설정합니다. 이후 작업에는 driver probe와 memory hotplug 등이 포함됩니다. Linux는 이 전 과정에서 EFI와 ACPI 정보를 읽어 장치의 논리적 표현을 구성할 수 있습니다.
Linux Early Boot 단계, 즉 kernel에서 `__init` decorator가 붙은 함수가 실행되는 동안 system은 EFI/BIOS가 만든 resource인 `ACPI table <../platform/acpi>`을 kernel이 사용할 수 있는 resource로 변환합니다.
BIOS, build, boot option
20-47kernel을 build할 때 고려해야 하는 pre-boot option은 네 가지이며, early boot 동안 Linux가 memory를 관리하는 방식을 결정합니다.
- `EFI_MEMORY_SP`: memory를 SystemRAM으로 볼지 Specific Purpose로 볼지 결정하는 BIOS/EFI option입니다. Specific Purpose memory는 즉시 system RAM으로 노출하지 않고 driver가 관리하도록 미룹니다.
- `CONFIG_EFI_SOFT_RESERVE`: kernel이 Specific Purpose memory를 지원할지 결정하는 Linux build configuration option입니다.
- `CONFIG_MHP_DEFAULT_ONLINE_TYPE`: DAX device로 변환한 Specific Purpose memory를 어떻게 관리할지 결정하는 Linux build configuration입니다. DAX 상태로 둘지, `ZONE_NORMAL` 또는 `ZONE_MOVABLE`의 SystemRAM으로 online할지를 지정합니다.
- `nosoftreserve`: Soft Reserve 지원 여부를 결정하는 Linux kernel boot option입니다. 역할은 `CONFIG_EFI_SOFT_RESERVE`와 비슷합니다.
Memory map 생성
48-70kernel이 EFI memory map을 해석할 때 `Specific Purpose` memory가 지원되고 감지되면 해당 region을 `SOFT_RESERVED`로 따로 둡니다.
`EFI_MEMORY_SP=0`, `CONFIG_EFI_SOFT_RESERVE=n`, 또는 `nosoftreserve=y`이면 Linux는 CXL device memory region을 기본적으로 SystemRAM으로 취급합니다. 이 memory는 `ZONE_NORMAL`의 kernel page allocator에 노출되므로 `struct page`와 page table을 포함한 대부분의 할당에 사용할 수 있습니다.
`Specific Purpose`가 설정되고 지원되면 `CONFIG_MHP_DEFAULT_ONLINE_TYPE_*`가 memory를 기본적으로 online할지(`_OFFLINE` 또는 `_ONLINE_*`) 결정합니다. online한다면 기본적으로 어느 zone에 둘지도 `_NORMAL` 또는 `_MOVABLE`로 정합니다.
`ZONE_MOVABLE`에 배치한 memory는 `struct page`나 page table 같은 대부분의 kernel 할당에 사용할 수 없습니다. system의 memory capacity에 따라 성능에 큰 영향을 줄 수 있습니다.
NUMA node 예약
71-96Linux는 `SRAT <../platform/acpi/srat>`에 정의된 proximity domain인 `PXM`을 참조해 `acpi_numa_init`에서 NUMA node를 생성합니다. 일반적으로 `PXM`과 NUMA node ID는 1:1 관계입니다.
SRAT는 Proximity Domain을 정의하는 ACPI의 유일한 방법이며, Linux는 이를 많아야 NUMA node와 1:1로 mapping합니다. `CEDT <../platform/acpi/cedt>`는 Linux가 하나 이상의 NUMA node에 mapping할 수 있는 SPA range 설명을 추가합니다.
CFMWS에는 있지만 SRAT에는 없는 CXL range가 있으면 v6.15부터 가짜 `PXM`을 생성합니다. 앞으로는 proximity domain 연결이 모호하므로 Linux가 SRAT에 기술되지 않은 CFMWS를 거부할 수 있습니다.
NUMA node는 runtime에 생성할 수 없다는 점이 중요합니다. 가능한 모든 NUMA node는 `__init` 시점, 더 구체적으로는 `mm_init` 동안 식별됩니다. CEDT와 SRAT에는 Linux가 NUMA node와 연결된 memory region을 식별하기에 충분한 `PXM` data가 있어야 합니다.
관련 코드는 `linux/drivers/acpi/numa/srat.c`에 있습니다. 자세한 내용은 `Example Platform Configurations <../platform/example-configs>`를 참조하십시오.
Memory tier 생성
97-121memory tier는 성능 특성에 따라 묶은 NUMA node의 집합입니다. `__init` 동안 Linux는 `N_MEMORY`로 표시된 모든 node를 포함하는 기본 memory tier로 system을 초기화합니다.
`memory_tier_init`은 부팅할 때 기본적으로 memory가 online인 모든 node에 대해 호출됩니다. `memory_tier_late_init`은 driver 구성 중 설정된 node를 대상으로 late-init 동안 호출됩니다.
node는 *online* memory가 있을 때만 `N_MEMORY`로 표시됩니다.
tier membership은 다음 경로에서 확인할 수 있습니다.
/sys/devices/virtual/memory_tiering/memory_tierN/nodelist
0-1
성능 차이가 뚜렷한 node가 같은 tier로 묶였다면 CXL node의 `HMAT <../platform/acpi/hmat>`와 CDAT 정보를 확인하십시오. `access_coordinates`를 통해 HMAT/CDAT 정보를 memory_tier component에 보고하지 않으면 모든 node는 기본적으로 DRAM tier에 속합니다.
자세한 내용은 `CXL access coordinates documentation <../linux/access-coordinates>`을 참조하십시오.
Contiguous Memory Allocation
122-137contiguous memory allocator(CMA)는 early boot 동안 NUMA node에 연속 memory region을 예약할 수 있게 합니다. 하지만 early boot 중 online이 아닌 NUMA node에는 CMA가 memory를 예약할 수 없습니다.
void __init hugetlb_cma_reserve(int order) {
if (!node_online(nid))
/* do not allow reservations */
}
따라서 CXL memory 관리를 driver에 미루려는 경우에는 CMA로 huge page 할당을 보장할 수 없습니다. early boot 동안 CXL memory를 `ZONE_NORMAL`의 SystemRAM으로 활성화한다면 `cma_pernuma` 또는 `numa_cma` kernel command-line parameter로 node별 CMA reservation을 만들 수 있습니다.
요약과 해설
early-boot.rst:1-137CXL memory가 SystemRAM, soft-reserved DAX capacity, 또는 hotplug 대상 중 무엇이 되는지는 firmware 표시와 build·boot option의 조합으로 결정됩니다. NUMA node는 runtime에 새로 만들 수 없으므로 SRAT와 CEDT의 PXM 정보가 early boot에 충분해야 하며, offline node에서는 CMA 예약도 제한됩니다.