Received: from [140.186.70.92] (port=45300 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PNozF-00085W-8D for qemu-devel@nongnu.org; Wed, 01 Dec 2010 10:53:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PNoyL-0005nq-Hn for qemu-devel@nongnu.org; Wed, 01 Dec 2010 10:52:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8577) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PNoyL-0005nU-9O for qemu-devel@nongnu.org; Wed, 01 Dec 2010 10:51:57 -0500 From: Juan Quintela In-Reply-To: <4CF65FBB.3020406@redhat.com> (Avi Kivity's message of "Wed, 01 Dec 2010 16:46:19 +0200") References: <411b3f89b6b79b429686bd1b1fa188ba55b6c6f7.1290552026.git.quintela@redhat.com> <4CF45DE0.8020701@codemonkey.ws> <4CF65FBB.3020406@redhat.com> Date: Wed, 01 Dec 2010 16:51:46 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH 10/10] Maintaing number of dirty pages List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: qemu-devel@nongnu.org Avi Kivity wrote: > On 11/30/2010 04:46 PM, Juan Quintela wrote: >> Anthony Liguori wrote: >> > On 11/23/2010 05:03 PM, Juan Quintela wrote: >> >> From: Juan Quintela >> >> >> >> Calculate the number of dirty pages takes a lot on hosts with lots >> >> of memory. Just maintain how many pages are dirty. Only sync bitmaps >> >> if number is small enough. >> >> >> > >> > There needs to be numbers that justify this as part of the commit message. >> >> They are on patch 0/6. >> >> Additionally, with 64GB of RAM, this bitmap is HUGE, having to walk over >> it in each ram_save_live() call is too onerous. > > It's not so huge. It's scaled down by a factor of 8 * 4096 = 32K. So > it's a 2MB bitmap. If kept as a bitmap and accessed in longs, it can > be read in less than a millisecond. Going to undertand why we need the other bitmaps for kvm. Basically we have: - CODE bit: kvm don't care - VGA bit: not really sure how much we care. My understanding is that the bitmap for the VGA don't need to be as big as all memory. - MIGRATION bit: we care O:-) Now, we are setting the MIGRATION in three ways: - kvm (we sync with that) - vhost net: it uses a different mechanism, not shared with kvm - *write[blw]. My understanding is that we care about this ones. Do we really care? We are also syncing too much bitmaps, we can do a bit less syncing. > An optimization can be to look at the previous ram_save_live (which > had to walk the bitmap). If old_nr_dirty > 4*target_nr_dirty, assume > we need one more pass and don't scan the bitmap. We had a similar optimization on rhel5. We only synched the bitmap each time that we passed over address 0. And each time that we called ram_save_remaining(). Trivial optimization for ram_save_reamaining is to: - maintain the number of pages that are dirty (we only modify the bitmap in two places, trivial to inc/dec the total number of dirty pages). - on ram_save_live only sync bitmap if we are about to exit from the loop. If pages dirty are still bigger that the one we need to go to non-save life, it makes no sense to sync. > Another optimization is to stop the count when we reach the target; > instead of ram_save_remaining() have a ram_save_may_stop() which > counts the number of dirty bits until it reaches target_nr_dirty or > exhausts the bitmap. The problem here is that guest want to continue running, and continues dirtying pages. So, no obvious place where to stop counting. Or I am losing something? Later, Juan.