← Documents Documentation/virt/guest-halt-polling.rst GitHub 원문 ↗

Linux 6.18.37 · 가상화

게스트 halt polling

Guest vCPU가 halt 전에 polling하는 적응 알고리즘과 다섯 module parameter를 설명합니다.

Source pathDocumentation/virt/guest-halt-polling.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

guest-halt-polling.rst:1-84

Halt polling은 짧은 idle 구간의 IPI와 VM-exit 지연을 줄이는 대신 host CPU 시간을 소비합니다. Per-CPU window를 event 시점에 맞춰 조절하되 global limit과 shrink 허용 정책을 함께 설정해야 latency와 전력·스케줄링 비용의 균형을 잡을 수 있습니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 ==================
2 Guest halt polling
3 ==================
4
5 The cpuidle_haltpoll driver, with the haltpoll governor, allows
6 the guest vcpus to poll for a specified amount of time before
7 halting.
8
9 This provides the following benefits to host side polling:
10
11 1) The POLL flag is set while polling is performed, which allows
12 a remote vCPU to avoid sending an IPI (and the associated
13 cost of handling the IPI) when performing a wakeup.
14
15 2) The VM-exit cost can be avoided.
16
17 The downside of guest side polling is that polling is performed
18 even with other runnable tasks in the host.
19
20 The basic logic as follows: A global value, guest_halt_poll_ns,
21 is configured by the user, indicating the maximum amount of
22 time polling is allowed. This value is fixed.
23
24 Each vcpu has an adjustable guest_halt_poll_ns
25 ("per-cpu guest_halt_poll_ns"), which is adjusted by the algorithm
26 in response to events (explained below).
27
28 Module Parameters
29 =================
30
31 The haltpoll governor has 5 tunable module parameters:
32
33 1) guest_halt_poll_ns:
34
35 Maximum amount of time, in nanoseconds, that polling is
36 performed before halting.
37
38 Default: 200000
39
40 2) guest_halt_poll_shrink:
41
42 Division factor used to shrink per-cpu guest_halt_poll_ns when
43 wakeup event occurs after the global guest_halt_poll_ns.
44
45 Default: 2
46
47 3) guest_halt_poll_grow:
48
49 Multiplication factor used to grow per-cpu guest_halt_poll_ns
50 when event occurs after per-cpu guest_halt_poll_ns
51 but before global guest_halt_poll_ns.
52
53 Default: 2
54
55 4) guest_halt_poll_grow_start:
56
57 The per-cpu guest_halt_poll_ns eventually reaches zero
58 in case of an idle system. This value sets the initial
59 per-cpu guest_halt_poll_ns when growing. This can
60 be increased from 10000, to avoid misses during the initial
61 growth stage:
62
63 10k, 20k, 40k, ... (example assumes guest_halt_poll_grow=2).
64
65 Default: 50000
66
67 5) guest_halt_poll_allow_shrink:
68
69 Bool parameter which allows shrinking. Set to N
70 to avoid it (per-cpu guest_halt_poll_ns will remain
71 high once achieves global guest_halt_poll_ns value).
72
73 Default: Y
74
75 The module parameters can be set from the sysfs files in::
76
77 /sys/module/haltpoll/parameters/
78
79 Further Notes
80 =============
81
82 - Care should be taken when setting the guest_halt_poll_ns parameter as a
83 large value has the potential to drive the cpu usage to 100% on a machine
84 which would be almost entirely idle otherwise.
85

3. 한국어 전문 번역

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

게스트 halt polling의 목적과 절충

1-18

`cpuidle_haltpoll` driver와 `haltpoll` governor를 함께 사용하면 guest vCPU가 halt하기 전에 지정된 시간 동안 event를 polling할 수 있습니다.

Host-side polling과 비교하면 두 가지 이점이 있습니다. Polling 중 `POLL` flag가 설정되므로 remote vCPU가 wakeup할 때 IPI를 보내는 비용과 IPI 처리 비용을 피할 수 있고, halt에 따른 VM-exit 비용도 피할 수 있습니다.

반면 guest-side polling은 host에 실행 가능한 다른 task가 있어도 polling을 수행하므로 CPU 시간을 불필요하게 소비할 수 있습니다.

Guest-side halt polling의 절충
측면효과
POLL flagRemote vCPU wakeup의 IPI 송신·처리 비용 회피
VM-exitPolling 중 event가 오면 halt VM-exit 회피
Host scheduling다른 runnable task가 있어도 guest가 polling할 수 있음

지연 감소와 host CPU 소비를 함께 고려해야 합니다.

==================
Guest halt polling
==================

The cpuidle_haltpoll driver, with the haltpoll governor, allows
the guest vcpus to poll for a specified amount of time before
halting.

This provides the following benefits to host side polling:

	1) The POLL flag is set while polling is performed, which allows
	   a remote vCPU to avoid sending an IPI (and the associated
	   cost of handling the IPI) when performing a wakeup.

	2) The VM-exit cost can be avoided.

The downside of guest side polling is that polling is performed
even with other runnable tasks in the host.

전역 상한과 vCPU별 적응값

19-27

사용자가 고정 전역값 `guest_halt_poll_ns`를 설정하며, 이 값은 polling을 허용하는 최대 시간입니다.

각 vCPU에는 별도로 조절되는 per-CPU `guest_halt_poll_ns`가 있습니다. 알고리즘은 wakeup event가 발생한 시점에 따라 이 값을 증가시키거나 감소시키되 전역 상한을 넘지 않습니다.

Per-CPU polling window 적응
vCPU가 현재 per-CPU guest_halt_poll_ns 동안 pollingEvent가 per-CPU window 안에 오면 현재 window 유지Event가 per-CPU window 뒤이지만 global limit 전이면 grow factor 적용Event가 global guest_halt_poll_ns 뒤에 오면 shrink factor 적용Per-CPU 값은 0과 global limit 사이에서 조절

Event 시점을 per-CPU window와 global limit에 비교합니다.


The basic logic as follows: A global value, guest_halt_poll_ns,
is configured by the user, indicating the maximum amount of
time polling is allowed. This value is fixed.

Each vcpu has an adjustable guest_halt_poll_ns
("per-cpu guest_halt_poll_ns"), which is adjusted by the algorithm
in response to events (explained below).

1. guest_halt_poll_ns

28-39

`haltpoll` governor에는 다섯 개의 조정 가능한 module parameter가 있습니다. 첫 번째 `guest_halt_poll_ns`는 halt하기 전에 polling할 최대 시간을 nanosecond 단위로 지정합니다.

기본값은 `200000`ns입니다. 이 전역값은 모든 per-CPU 적응값의 상한으로 사용됩니다.

Module Parameters
=================

The haltpoll governor has 5 tunable module parameters:

1) guest_halt_poll_ns:

Maximum amount of time, in nanoseconds, that polling is
performed before halting.

Default: 200000

2. guest_halt_poll_shrink

40-46

`guest_halt_poll_shrink`는 wakeup event가 전역 `guest_halt_poll_ns` 이후에 발생했을 때 per-CPU `guest_halt_poll_ns`를 줄이는 나눗셈 계수입니다.

기본값은 `2`이므로 shrink가 허용된 상태에서는 늦은 wakeup이 관찰될 때 per-CPU polling window가 절반으로 줄어듭니다.

2) guest_halt_poll_shrink:

Division factor used to shrink per-cpu guest_halt_poll_ns when
wakeup event occurs after the global guest_halt_poll_ns.

Default: 2

3. guest_halt_poll_grow

47-54

`guest_halt_poll_grow`는 event가 per-CPU `guest_halt_poll_ns`보다 늦지만 전역 `guest_halt_poll_ns`보다 이르게 발생할 때 per-CPU 값을 키우는 곱셈 계수입니다.

기본값은 `2`이므로 이 구간의 wakeup을 관찰할 때 polling window가 두 배씩 증가합니다.

3) guest_halt_poll_grow:

Multiplication factor used to grow per-cpu guest_halt_poll_ns
when event occurs after per-cpu guest_halt_poll_ns
but before global guest_halt_poll_ns.

Default: 2

4. guest_halt_poll_grow_start

55-66

Idle system에서는 per-CPU `guest_halt_poll_ns`가 결국 0에 도달할 수 있습니다. `guest_halt_poll_grow_start`는 0에서 다시 성장할 때 사용할 초기 per-CPU 값을 지정합니다.

초기 성장 단계의 event miss를 줄이기 위해 이 값을 10000보다 크게 설정할 수 있습니다. `guest_halt_poll_grow=2`라면 예시 성장 수열은 `10k, 20k, 40k, ...`입니다. 문서의 기본값은 `50000`입니다.

0에서 polling window 재성장
Idle 관찰로 per-CPU window가 0까지 축소성장 조건을 다시 관찰guest_halt_poll_grow_start를 초기 window로 설정이후 guest_halt_poll_grow 배율로 증가Global guest_halt_poll_ns에서 상한 적용

grow_start가 첫 단계의 크기를 결정합니다.

4) guest_halt_poll_grow_start:

The per-cpu guest_halt_poll_ns eventually reaches zero
in case of an idle system. This value sets the initial
per-cpu guest_halt_poll_ns when growing. This can
be increased from 10000, to avoid misses during the initial
growth stage:

10k, 20k, 40k, ... (example assumes guest_halt_poll_grow=2).

Default: 50000

5. guest_halt_poll_allow_shrink와 sysfs

67-78

Boolean parameter `guest_halt_poll_allow_shrink`는 per-CPU window 축소 허용 여부를 제어합니다. 기본값은 `Y`이며 `N`으로 설정하면 shrink를 막습니다.

Shrink를 막은 경우 per-CPU `guest_halt_poll_ns`가 전역 상한에 도달한 뒤 높은 값으로 유지됩니다. 모든 module parameter는 `/sys/module/haltpoll/parameters/` 아래의 sysfs 파일에서 설정할 수 있습니다.

haltpoll module parameter
Parameter역할기본값
`guest_halt_poll_ns`전역 최대 polling 시간(ns)200000
`guest_halt_poll_shrink`Per-CPU 값을 줄이는 나눗셈 계수2
`guest_halt_poll_grow`Per-CPU 값을 키우는 곱셈 계수2
`guest_halt_poll_grow_start`0에서 성장할 초기값50000
`guest_halt_poll_allow_shrink`축소 허용 여부Y

다섯 parameter의 역할과 기본값입니다.

5) guest_halt_poll_allow_shrink:

Bool parameter which allows shrinking. Set to N
to avoid it (per-cpu guest_halt_poll_ns will remain
high once achieves global guest_halt_poll_ns value).

Default: Y

The module parameters can be set from the sysfs files in::

	/sys/module/haltpoll/parameters/

추가 주의 사항

79-84

`guest_halt_poll_ns`를 설정할 때는 주의해야 합니다. 큰 값을 사용하면 원래는 거의 완전히 idle했을 시스템에서 polling이 CPU 사용률을 100%까지 끌어올릴 수 있습니다.

따라서 latency 이득만 보지 말고 host의 runnable task, 전력 소비와 idle 비율을 함께 측정해 상한을 정해야 합니다.

Further Notes
=============

- Care should be taken when setting the guest_halt_poll_ns parameter as a
  large value has the potential to drive the cpu usage to 100% on a machine
  which would be almost entirely idle otherwise.