From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: Checking guest memory pages changes from host userspace Date: Sun, 21 Jun 2009 23:01:10 +0300 Message-ID: <4A3E9186.8020303@redhat.com> References: <18C018878FB0244EB71B7FE328978A32679FD52B@rrsmsx503.amr.corp.intel.com> <4A3E5706.9070408@redhat.com> <3574F699-DC93-41EB-9ABC-F246CCE28203@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "Passera, Pablo R" , "kvm@vger.kernel.org" To: Alexander Graf Return-path: Received: from mx2.redhat.com ([66.187.237.31]:56198 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752073AbZFUUBU (ORCPT ); Sun, 21 Jun 2009 16:01:20 -0400 In-Reply-To: <3574F699-DC93-41EB-9ABC-F246CCE28203@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: On 06/21/2009 09:46 PM, Alexander Graf wrote: >> You can use the dirty memory logging API. vga uses this to track >> which regions of the screen have changed, and live migration uses it >> to allow the guest to proceed while copying its memory to the other >> node. It works exactly by write protecting guest memory and trapping >> the resultant fault. > > > I stumbled across this on my ppc implementation: Is there an obvious > reason we don't use the pte's dirty bit? Yes: > I don't know which operation is more frequent - writing into dirty > mapped memory or reading the dirty map. And I have no idea how long it > would take to find out dirty pages... The cost of write protection is one fault per dirtied spte. The cost of looking at the dirty bit is a cache miss per spte (could be reduced by scanning in spte order rather than gfn order). The problem is when you have a low percentage of memory dirtied. Then you're scanning a lot of sptes to find a few dirty ones - so the cost per dirty page goes up. We've talked about write-protecting the upper levels first, but given a random distribution of writes, that doesn't help much. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.