요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
============
Paravirt_ops
============
Linux provides support for different hypervisor virtualization technologies.
Historically, different binary kernels would be required in order to support
different hypervisors; this restriction was removed with pv_ops.
Linux pv_ops is a virtualization API which enables support for different
hypervisors. It allows each hypervisor to override critical operations and
allows a single kernel binary to run on all supported execution environments
including native machine -- without any hypervisors.
pv_ops provides a set of function pointers which represent operations
corresponding to low-level critical instructions and high-level
functionalities in various areas. pv_ops allows for optimizations at run
time by enabling binary patching of the low-level critical operations
at boot time.
pv_ops operations are classified into three categories:
- simple indirect call
These operations correspond to high-level functionality where it is
known that the overhead of indirect call isn't very important.
- indirect call which allows optimization with binary patch
Usually these operations correspond to low-level critical instructions. They
are called frequently and are performance critical. The overhead is
very important.
- a set of macros for hand written assembly code
Hand written assembly codes (.S files) also need paravirtualization
because they include sensitive instructions or some code paths in
them are very performance critical.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
하나의 커널 바이너리로 여러 실행 환경 지원
1-13Linux는 서로 다른 hypervisor 가상화 기술을 지원합니다. 과거에는 hypervisor마다 별도의 binary kernel을 준비해야 했지만, `pv_ops`가 이 제약을 없애 여러 가상화 환경을 하나의 커널 구성으로 다룰 수 있게 했습니다.
`pv_ops`는 여러 hypervisor를 지원하기 위한 virtualization API입니다. 각 hypervisor는 자신에게 민감한 critical operation을 알맞은 구현으로 override할 수 있고, 나머지 공통 커널 코드는 같은 형태로 유지됩니다.
이 구조의 핵심은 단일 kernel binary가 지원되는 모든 실행 환경에서 동작한다는 점입니다. hypervisor가 없는 native machine도 같은 범위에 포함되므로, 배포 이미지를 실행 환경마다 따로 나눌 필요가 줄어듭니다.
따라서 `pv_ops`는 특정 hypervisor 전용 커널을 만드는 방식이 아니라, 바뀌어야 하는 핵심 연산만 교체 가능한 경계로 모으는 방식입니다. 공통 경로와 환경별 구현의 책임이 명확하게 분리됩니다.
hypervisor별 커널에서 공통 커널과 교체 가능한 연산으로 전환한 결과를 정리합니다.
같은 Linux 이미지가 실행 환경에 맞는 critical operation 구현을 사용합니다.
.. SPDX-License-Identifier: GPL-2.0
============
Paravirt_ops
============
Linux provides support for different hypervisor virtualization technologies.
Historically, different binary kernels would be required in order to support
different hypervisors; this restriction was removed with pv_ops.
Linux pv_ops is a virtualization API which enables support for different
hypervisors. It allows each hypervisor to override critical operations and
allows a single kernel binary to run on all supported execution environments
including native machine -- without any hypervisors.
function pointer와 boot time binary patching
14-19`pv_ops`는 여러 영역의 연산을 나타내는 function pointer 집합을 제공합니다. 이 포인터들은 low-level critical instructions부터 비교적 높은 수준의 functionality까지 가상화 환경에 따라 달라질 수 있는 동작을 대표합니다.
모든 연산을 같은 비용으로 호출하면 빈번한 저수준 경로에서 간접 호출 비용이 누적될 수 있습니다. 그래서 `pv_ops`는 인터페이스의 유연성을 유지하면서 성능에 민감한 경로를 별도로 최적화할 수 있게 설계되었습니다.
핵심 최적화는 boot time에 수행하는 binary patching입니다. 부팅 과정에서 현재 실행 환경이 결정되면, 자주 호출되는 low-level critical operation을 해당 환경에 맞는 효율적인 명령 경로로 패치할 수 있습니다.
이 binary patching은 런타임의 매 호출마다 환경을 판별하는 비용을 줄입니다. 즉 function pointer 기반 추상화가 구현 선택 지점을 제공하고, 부팅 시 패치가 성능이 중요한 호출의 오버헤드를 낮춥니다.
추상화 지점과 성능 최적화가 맡는 역할을 구분합니다.
선택 가능한 인터페이스가 실제 실행 경로로 고정되는 순서입니다.
pv_ops provides a set of function pointers which represent operations
corresponding to low-level critical instructions and high-level
functionalities in various areas. pv_ops allows for optimizations at run
time by enabling binary patching of the low-level critical operations
at boot time.
pv_ops 연산의 세 가지 분류
20-35`pv_ops` operation은 호출 빈도, 성능 민감도, 코드 작성 형태에 따라 세 범주로 분류됩니다. 분류 목적은 모든 가상화 연산에 동일한 최적화 방식을 강제하지 않고 필요한 비용만 지불하게 하는 것입니다.
첫째, simple indirect call은 간접 호출 오버헤드가 크게 중요하지 않은 high-level functionality에 사용합니다. 호출 빈도가 낮거나 연산 자체의 비용이 더 크다면 단순한 간접 호출이 구현의 명료성과 교체 가능성을 유지하는 합리적인 선택입니다.
둘째, binary patch 최적화를 허용하는 indirect call은 자주 호출되는 low-level critical instructions에 사용합니다. 이 경로는 performance critical하므로 간접 호출의 작은 비용도 누적될 수 있으며, boot time binary patching으로 그 비용을 줄이는 것이 중요합니다.
셋째, hand written assembly code를 위한 macro 집합이 있습니다. `.S` 파일에도 sensitive instructions가 포함될 수 있고 일부 code path가 매우 성능에 민감하므로, C 코드의 function pointer만으로는 충분하지 않은 조립 코드 위치를 paravirtualization해야 합니다.
세 범주는 같은 목표를 서로 다른 수단으로 달성합니다. 높은 수준의 드문 연산은 simple indirect call, 빈번한 저수준 연산은 패치 가능한 indirect call, 직접 작성한 assembly는 전용 macro를 사용해 환경별 차이를 흡수합니다.
원문의 분류 기준과 선택 이유를 나란히 비교합니다.
연산의 위치와 비용 특성으로 구현 방식을 결정합니다.
pv_ops operations are classified into three categories:
- simple indirect call
These operations correspond to high-level functionality where it is
known that the overhead of indirect call isn't very important.
- indirect call which allows optimization with binary patch
Usually these operations correspond to low-level critical instructions. They
are called frequently and are performance critical. The overhead is
very important.
- a set of macros for hand written assembly code
Hand written assembly codes (.S files) also need paravirtualization
because they include sensitive instructions or some code paths in
them are very performance critical.
요약·해설
paravirt_ops.rst:1-35`pv_ops`는 hypervisor별로 바뀌어야 하는 critical operation을 교체 가능한 인터페이스로 묶어, 같은 kernel binary가 native machine과 가상화 환경에서 실행되게 합니다.
호출 비용이 덜 중요한 고수준 기능은 simple indirect call을 사용하고, 빈번한 저수준 명령은 boot time binary patching으로 최적화하며, `.S` assembly에는 전용 macro를 적용합니다.