From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrea Arcangeli Subject: Re: [PATCH 3/3] add support for change_pte mmu notifiers Date: Thu, 24 Sep 2009 19:11:36 +0200 Message-ID: <20090924171136.GC6864@random.random> References: <1253731638-24575-1-git-send-email-ieidus@redhat.com> <1253731638-24575-2-git-send-email-ieidus@redhat.com> <1253731638-24575-3-git-send-email-ieidus@redhat.com> <1253731638-24575-4-git-send-email-ieidus@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: avi@redhat.com, kvm@vger.kernel.org, mtosatti@redhat.com To: Izik Eidus Return-path: Received: from mx1.redhat.com ([209.132.183.28]:59129 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751732AbZIXRLd (ORCPT ); Thu, 24 Sep 2009 13:11:33 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8OHBbL7029900 for ; Thu, 24 Sep 2009 13:11:38 -0400 Content-Disposition: inline In-Reply-To: <1253731638-24575-4-git-send-email-ieidus@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Sep 23, 2009 at 09:47:18PM +0300, Izik Eidus wrote: > + if (need_flush) > + kvm_flush_remote_tlbs(kvm); need_flush can be return to kvm_mmu_notifier_change_pte to defer the tlb flush after dropping the spin lock I think. We are forced to flush the tlb inside spin_lock in kvm normal context because that stops the VM from freeing the page (it hangs on the mmu_lock taken by kvm invalidate_page/change_pte) so we can unmap tons of sptes and do a single kvm tlb flush that covers them all (by keeping both actions under the mmu_lock), but in mmu notifier context the pages can't be freed from under the guest, so we can flush the tlb flushing the tlb before making the page freeable, because both old and new page in do_wp_page are still pinned and can't be freed and reused from under us even if we release mmu_lock before tlb flush.