From: Takuya Yoshikawa Subject: Re: [PATCH being tested] KVM: Reduce mmu_lock contention during dirty logging by cond_resched() Date: Sat, 14 Apr 2012 09:35:20 +0900 Message-ID: <20120414093520.e69d6c6a03df04169c77b16a@gmail.com> References: <20120411202207.2c575e8eab2a6d279c1ec65a@gmail.com> <20120412225645.GA19030@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: avi@redhat.com, kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp To: Marcelo Tosatti Return-path: Received: from mail-pz0-f52.google.com ([209.85.210.52]:65326 "EHLO mail-pz0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757263Ab2DNAfZ (ORCPT ); Fri, 13 Apr 2012 20:35:25 -0400 Received: by dake40 with SMTP id e40so4500989dak.11 for ; Fri, 13 Apr 2012 17:35:24 -0700 (PDT) In-Reply-To: <20120412225645.GA19030@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, 12 Apr 2012 19:56:45 -0300 Marcelo Tosatti wrote: > Other than potential performance improvement, the worst case scenario > of holding mmu_lock for hundreds of milliseconds at the beginning > of migration of huge guests must be fixed. Write protection in kvm_arch_commit_memory_region() can be treated similarly. I am now checking that part together with my KVM: Avoid zapping unrelated shadows in __kvm_set_memory_region() because if we do rmap-based write protection when we enable dirty-logging, sp->slot_bitmap necessary for kvm_mmu_slot_remove_write_access() can be removed. People who want to support more devices/slots will be happy, no? But then, I need to find another way to eliminate shadow flushes. Maybe I should leave sp->slot_bitmap removal to those who really want to do that. > > @@ -3121,15 +3121,23 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log) > > if (!dirty_bitmap[i]) > > continue; > > > > - is_dirty = true; > > - > > mask = xchg(&dirty_bitmap[i], 0); > > dirty_bitmap_buffer[i] = mask; > > > > offset = i * BITS_PER_LONG; > > - kvm_mmu_write_protect_pt_masked(kvm, memslot, offset, mask); > > + nr_protected += kvm_mmu_write_protect_pt_masked(kvm, memslot, > > + offset, mask); > > + if (nr_protected > 2048) { > > Can you expand on the reasoning behind this? Sure. Thanks, Takuya