summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--virt/kvm/dirty_ring.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/virt/kvm/dirty_ring.c b/virt/kvm/dirty_ring.c
index e844e869e8c7..97cca0c02fd1 100644
--- a/virt/kvm/dirty_ring.c
+++ b/virt/kvm/dirty_ring.c
@@ -134,6 +134,16 @@ int kvm_dirty_ring_reset(struct kvm *kvm, struct kvm_dirty_ring *ring,
ring->reset_index++;
(*nr_entries_reset)++;
+
+ /*
+ * While the size of each ring is fixed, it's possible for the
+ * ring to be constantly re-dirtied/harvested while the reset
+ * is in-progress (the hard limit exists only to guard against
+ * wrapping the count into negative space).
+ */
+ if (!first_round)
+ cond_resched();
+
/*
* Try to coalesce the reset operations when the guest is
* scanning pages in the same slot.