This patchset tries to fix below issues: 1. Admin could set halt_poll_ns to 0 at runtime to disable poll and kernel behave just like the generic halt driver. Then If guest_halt_poll_grow_start is set to 0 and guest_halt_poll_ns set to nonzero later, cpu_halt_poll_us will never grow beyond 0. The first two patches fix this issue from both kvm and guest side. 2. guest_halt_poll_grow_start and guest_halt_poll_ns could be adjusted at runtime by admin, this could make a window where cpu_halt_poll_us jump out of the boundary. the window could be long in some cases(e.g. guest_halt_poll_grow_start is bumped and cpu_halt_poll_us is shrinking) The last two patches fix this issue from both kvm and guest side. 3. The 4th patch also simplifies branch check code. v2: Rewrite the patches and drop unnecessory changes Zhenzhong Duan (4): cpuidle-haltpoll: ensure grow start value is nonzero KVM: ensure grow start value is nonzero cpuidle-haltpoll: ensure cpu_halt_poll_us in right scope KVM: ensure vCPU halt_poll_us in right scope drivers/cpuidle/governors/haltpoll.c | 50 ++++++++++++++++++++++++----------- virt/kvm/kvm_main.c | 51 ++++++++++++++++++++++++------------ 2 files changed, 68 insertions(+), 33 deletions(-) -- 1.8.3.1