From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akqXN-0002lA-3C for qemu-devel@nongnu.org; Tue, 29 Mar 2016 06:06:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1akqXJ-0001vI-Rs for qemu-devel@nongnu.org; Tue, 29 Mar 2016 06:06:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akqXJ-0001vE-Ee for qemu-devel@nongnu.org; Tue, 29 Mar 2016 06:06:09 -0400 References: <1459138565-6244-1-git-send-email-jitendra.kolhe@hpe.com> <20160328094945-mutt-send-email-mst@redhat.com> From: Paolo Bonzini Message-ID: <56FA5385.1030608@redhat.com> Date: Tue, 29 Mar 2016 12:05:57 +0200 MIME-Version: 1.0 In-Reply-To: <20160328094945-mutt-send-email-mst@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] migration: skip sending ram pages released by virtio-balloon driver. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" , Jitendra Kolhe Cc: JBottomley@Odin.com, ehabkost@redhat.com, crosthwaite.peter@gmail.com, simhan@hpe.com, armbru@redhat.com, quintela@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, borntraeger@de.ibm.com, mohan_parthasarathy@hpe.com, stefanha@redhat.com, amit.shah@redhat.com, den@openvz.org, dgilbert@redhat.com, rth@twiddle.net On 28/03/2016 08:59, Michael S. Tsirkin wrote: >> > + qemu_mutex_lock_balloon_bitmap(); >> > for (;;) { >> > size_t offset = 0; >> > uint32_t pfn; >> > elem = virtqueue_pop(vq, sizeof(VirtQueueElement)); >> > if (!elem) { >> > + qemu_mutex_unlock_balloon_bitmap(); >> > return; >> > } >> > >> > @@ -242,6 +245,7 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq) >> > addr = section.offset_within_region; >> > balloon_page(memory_region_get_ram_ptr(section.mr) + addr, >> > !!(vq == s->dvq)); >> > + qemu_balloon_bitmap_update(addr, !!(vq == s->dvq)); >> > memory_region_unref(section.mr); >> > } >> > > So the assumption here is that offset_within_region equals > ram ptr if region is get_system_memory. > > And I'm not sure that's always right. > > Paolo? Indeed. It is correct for the main system RAM, but hot-plugged RAM would also have a zero-based section.offset_within_region. You need to add memory_region_get_ram_addr(section.mr), just like the call to balloon_page adds memory_region_get_ram_ptr(section.mr). Paolo