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