Commit ab99a1cc authored by Christian Borntraeger's avatar Christian Borntraeger

KVM: s390: do not take mmap_sem on dirty log query

Dirty log query can take a long time for huge guests.
Holding the mmap_sem for very long times  can cause some unwanted
latencies.
Turns out that we do not need to hold the mmap semaphore.
We hold the slots_lock for gfn->hva translation and walk the page
tables with that address, so no need to look at the VMAs. KVM also
holds a reference to the mm, which should prevent other things
going away. During the walk we take the necessary ptl locks.
Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: default avatarDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
parent 8a08b9c7
...@@ -274,7 +274,6 @@ static void kvm_s390_sync_dirty_log(struct kvm *kvm, ...@@ -274,7 +274,6 @@ static void kvm_s390_sync_dirty_log(struct kvm *kvm,
unsigned long address; unsigned long address;
struct gmap *gmap = kvm->arch.gmap; struct gmap *gmap = kvm->arch.gmap;
down_read(&gmap->mm->mmap_sem);
/* Loop over all guest pages */ /* Loop over all guest pages */
last_gfn = memslot->base_gfn + memslot->npages; last_gfn = memslot->base_gfn + memslot->npages;
for (cur_gfn = memslot->base_gfn; cur_gfn <= last_gfn; cur_gfn++) { for (cur_gfn = memslot->base_gfn; cur_gfn <= last_gfn; cur_gfn++) {
...@@ -283,7 +282,6 @@ static void kvm_s390_sync_dirty_log(struct kvm *kvm, ...@@ -283,7 +282,6 @@ static void kvm_s390_sync_dirty_log(struct kvm *kvm,
if (gmap_test_and_clear_dirty(address, gmap)) if (gmap_test_and_clear_dirty(address, gmap))
mark_page_dirty(kvm, cur_gfn); mark_page_dirty(kvm, cur_gfn);
} }
up_read(&gmap->mm->mmap_sem);
} }
/* Section: vm related */ /* Section: vm related */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment