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