path: root/include/linux
diff options
authorWanpeng Li <>2021-05-18 05:00:31 -0700
committerPaolo Bonzini <>2021-05-27 07:45:50 -0400
commit6bd5b743686243dae7351d5dcceeb7f171201bb4 (patch)
treec760534f54aca88f683598abe4a28bdde9bb1e19 /include/linux
parent28a4aa1160d71187a44414dac40b57d1fd9fcd77 (diff)
KVM: PPC: exit halt polling on need_resched()
This is inspired by commit 262de4102c7bb8 (kvm: exit halt polling on need_resched() as well). Due to PPC implements an arch specific halt polling logic, we have to the need_resched() check there as well. This patch adds a helper function that can be shared between book3s and generic halt-polling loops. Reviewed-by: David Matlack <> Reviewed-by: Venkatesh Srinivas <> Cc: Ben Segall <> Cc: Venkatesh Srinivas <> Cc: Jim Mattson <> Cc: David Matlack <> Cc: Paul Mackerras <> Cc: Suraj Jitindar Singh <> Signed-off-by: Wanpeng Li <> Message-Id: <> [Make the function inline. - Paolo] Signed-off-by: Paolo Bonzini <>
Diffstat (limited to 'include/linux')
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 2f34487e21f2..5d4b96b36ec0 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -10,6 +10,7 @@
#include <linux/spinlock.h>
#include <linux/signal.h>
#include <linux/sched.h>
+#include <linux/sched/stat.h>
#include <linux/bug.h>
#include <linux/minmax.h>
#include <linux/mm.h>
@@ -265,6 +266,11 @@ static inline bool kvm_vcpu_mapped(struct kvm_host_map *map)
return !!map->hva;
+static inline bool kvm_vcpu_can_poll(ktime_t cur, ktime_t stop)
+ return single_task_running() && !need_resched() && ktime_before(cur, stop);
* Sometimes a large or cross-page mmio needs to be broken up into separate
* exits for userspace servicing.