← Documents Documentation/virt/paravirt_ops.rst GitHub 원문 ↗

Linux 6.18.37 · 가상화 / paravirt_ops

Paravirt_ops

pv_ops가 단일 커널 바이너리에서 native machine과 여러 hypervisor를 지원하고, function pointer와 부팅 시 binary patching으로 연산 비용을 조정하는 방식을 설명합니다.

Source pathDocumentation/virt/paravirt_ops.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

paravirt_ops.rst:1-35

`pv_ops`는 hypervisor별로 바뀌어야 하는 critical operation을 교체 가능한 인터페이스로 묶어, 같은 kernel binary가 native machine과 가상화 환경에서 실행되게 합니다.

호출 비용이 덜 중요한 고수준 기능은 simple indirect call을 사용하고, 빈번한 저수준 명령은 boot time binary patching으로 최적화하며, `.S` assembly에는 전용 macro를 적용합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ============
4 Paravirt_ops
5 ============
6
7 Linux provides support for different hypervisor virtualization technologies.
8 Historically, different binary kernels would be required in order to support
9 different hypervisors; this restriction was removed with pv_ops.
10 Linux pv_ops is a virtualization API which enables support for different
11 hypervisors. It allows each hypervisor to override critical operations and
12 allows a single kernel binary to run on all supported execution environments
13 including native machine -- without any hypervisors.
14
15 pv_ops provides a set of function pointers which represent operations
16 corresponding to low-level critical instructions and high-level
17 functionalities in various areas. pv_ops allows for optimizations at run
18 time by enabling binary patching of the low-level critical operations
19 at boot time.
20
21 pv_ops operations are classified into three categories:
22
23 - simple indirect call
24 These operations correspond to high-level functionality where it is
25 known that the overhead of indirect call isn't very important.
26
27 - indirect call which allows optimization with binary patch
28 Usually these operations correspond to low-level critical instructions. They
29 are called frequently and are performance critical. The overhead is
30 very important.
31
32 - a set of macros for hand written assembly code
33 Hand written assembly codes (.S files) also need paravirtualization
34 because they include sensitive instructions or some code paths in
35 them are very performance critical.
36

3. 한국어 전문 번역

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

하나의 커널 바이너리로 여러 실행 환경 지원

1-13

Linux는 서로 다른 hypervisor 가상화 기술을 지원합니다. 과거에는 hypervisor마다 별도의 binary kernel을 준비해야 했지만, `pv_ops`가 이 제약을 없애 여러 가상화 환경을 하나의 커널 구성으로 다룰 수 있게 했습니다.

`pv_ops`는 여러 hypervisor를 지원하기 위한 virtualization API입니다. 각 hypervisor는 자신에게 민감한 critical operation을 알맞은 구현으로 override할 수 있고, 나머지 공통 커널 코드는 같은 형태로 유지됩니다.

이 구조의 핵심은 단일 kernel binary가 지원되는 모든 실행 환경에서 동작한다는 점입니다. hypervisor가 없는 native machine도 같은 범위에 포함되므로, 배포 이미지를 실행 환경마다 따로 나눌 필요가 줄어듭니다.

따라서 `pv_ops`는 특정 hypervisor 전용 커널을 만드는 방식이 아니라, 바뀌어야 하는 핵심 연산만 교체 가능한 경계로 모으는 방식입니다. 공통 경로와 환경별 구현의 책임이 명확하게 분리됩니다.

pv_ops가 제거한 제약
항목과거 방식pv_ops 방식
커널 이미지hypervisor별 binary kernel단일 kernel binary
가상화 인터페이스환경별로 분리된 코드공통 virtualization API
핵심 연산커널에 고정hypervisor가 override
native machine별도 빌드가 필요할 수 있음같은 바이너리로 실행
배포 단위실행 환경 수만큼 증가지원 환경에서 공통화
환경 차이전체 이미지에 반영critical operation에 국한
유지보수구현별 분기 확산교체 지점에 구현 집중

hypervisor별 커널에서 공통 커널과 교체 가능한 연산으로 전환한 결과를 정리합니다.

단일 바이너리의 실행 환경 선택
하나의 Linux kernel binary를 빌드부팅 환경이 native machine인지 hypervisor인지 확인환경에 맞는 pv_ops 구현을 연결공통 커널 코드가 선택된 critical operation을 호출동일 바이너리로 지원 실행 환경에서 동작

같은 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 인터페이스 구성
구성 요소적용 대상역할
function pointer환경별 operation구현 교체 지점 제공
low-level operationcritical instructions가상화에 민감한 명령 대체
high-level functionality여러 커널 기능 영역간접 호출로 환경별 동작 연결
binary patching빈번한 저수준 호출호출 오버헤드 감소
boot time실행 환경이 정해지는 시점패치 대상 구현 확정
run time패치 이후 실행선택된 빠른 경로 사용
공통 커널 코드전체 지원 환경동일 호출 계약 유지

추상화 지점과 성능 최적화가 맡는 역할을 구분합니다.

부팅 시 저수준 연산 최적화
pv_ops가 operation별 function pointer 계약을 제공부팅 시 native 또는 hypervisor 실행 환경을 식별환경별 low-level critical operation 구현을 선택성능에 민감한 호출 지점을 binary patchingrun time에는 패치된 명령 경로를 직접 실행

선택 가능한 인터페이스가 실제 실행 경로로 고정되는 순서입니다.


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를 사용해 환경별 차이를 흡수합니다.

세 가지 operation 범주
범주주요 대상성능 판단적용 수단
simple indirect callhigh-level functionality호출 오버헤드가 덜 중요일반 function pointer 호출
패치 가능한 indirect calllow-level critical instructions빈번하고 performance criticalboot time binary patch
assembly macrohand written assembly code민감 명령 또는 핵심 경로`.S` 전용 macro
고수준 경로복합 기능연산 자체 비용이 큼단순 간접 호출 유지
저수준 경로짧은 critical operation호출 비용 비중이 큼직접 경로로 패치
조립 코드 경로컴파일러 밖의 명령열C 추상화 적용 불가macro로 명시적 치환
호출 빈도낮음 또는 보통최적화 우선순위 낮음simple indirect call
호출 빈도매우 높음작은 비용도 누적binary patching
가상화 민감도sensitive instructions직접 실행이 안전하지 않을 수 있음환경별 대체 구현
공통 목표지원 실행 환경 전체정확성과 성능의 균형pv_ops 계약 준수

원문의 분류 기준과 선택 이유를 나란히 비교합니다.

operation 분류 선택
대상 operation이 C 코드인지 `.S` assembly인지 확인assembly이며 sensitive instructions 또는 critical path라면 macro 사용C 경로라면 호출 빈도와 간접 호출 비용을 평가오버헤드가 중요하지 않으면 simple indirect call 사용빈번한 low-level operation이면 패치 가능한 indirect call 사용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.