xref: /linux/Documentation/virt/guest-halt-polling.rst (revision daa2be74b1b2302004945b2a5e32424e177cc7da)
1==================
2Guest halt polling
3==================
4
5The cpuidle_haltpoll driver, with the haltpoll governor, allows
6the guest vcpus to poll for a specified amount of time before
7halting.
8
9This 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
17The downside of guest side polling is that polling is performed
18even with other runnable tasks in the host.
19
20The basic logic as follows: A global value, guest_halt_poll_ns,
21is configured by the user, indicating the maximum amount of
22time polling is allowed. This value is fixed.
23
24Each vcpu has an adjustable guest_halt_poll_ns
25("per-cpu guest_halt_poll_ns"), which is adjusted by the algorithm
26in response to events (explained below).
27
28Module Parameters
29=================
30
31The haltpoll governor has 5 tunable module parameters:
32
331) guest_halt_poll_ns:
34
35Maximum amount of time, in nanoseconds, that polling is
36performed before halting.
37
38Default: 200000
39
402) guest_halt_poll_shrink:
41
42Division factor used to shrink per-cpu guest_halt_poll_ns when
43wakeup event occurs after the global guest_halt_poll_ns.
44
45Default: 2
46
473) guest_halt_poll_grow:
48
49Multiplication factor used to grow per-cpu guest_halt_poll_ns
50when event occurs after per-cpu guest_halt_poll_ns
51but before global guest_halt_poll_ns.
52
53Default: 2
54
554) guest_halt_poll_grow_start:
56
57The per-cpu guest_halt_poll_ns eventually reaches zero
58in case of an idle system. This value sets the initial
59per-cpu guest_halt_poll_ns when growing. This can
60be increased from 10000, to avoid misses during the initial
61growth stage:
62
6310k, 20k, 40k, ... (example assumes guest_halt_poll_grow=2).
64
65Default: 50000
66
675) guest_halt_poll_allow_shrink:
68
69Bool parameter which allows shrinking. Set to N
70to avoid it (per-cpu guest_halt_poll_ns will remain
71high once achieves global guest_halt_poll_ns value).
72
73Default: Y
74
75The module parameters can be set from the sysfs files in::
76
77	/sys/module/haltpoll/parameters/
78
79Further 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