From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fb3rf-0003V7-Ck for qemu-devel@nongnu.org; Thu, 05 Jul 2018 09:00:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fb3ra-0004y4-Fs for qemu-devel@nongnu.org; Thu, 05 Jul 2018 09:00:03 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:35780 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fb3ra-0004tc-AZ for qemu-devel@nongnu.org; Thu, 05 Jul 2018 08:59:58 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3550401EF04 for ; Thu, 5 Jul 2018 12:59:56 +0000 (UTC) From: Juan Quintela In-Reply-To: <20180705031755.3254-2-peterx@redhat.com> (Peter Xu's message of "Thu, 5 Jul 2018 11:17:47 +0800") References: <20180705031755.3254-1-peterx@redhat.com> <20180705031755.3254-2-peterx@redhat.com> Reply-To: quintela@redhat.com Date: Thu, 05 Jul 2018 14:59:46 +0200 Message-ID: <87601t3kjh.fsf@secure.mitica> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH for-3.0 1/9] migration: simplify check to use qemu file buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu Cc: qemu-devel@nongnu.org, "Dr . David Alan Gilbert" Peter Xu wrote: > Firstly, renaming the old matching_page_sizes variable to > matching_target_page_size, which suites more to what it did (it only > checks against target page size rather than multiple page sizes). > Meanwhile, simplify the check logic a bit, and enhance the comments. > Should have no functional change. > > Signed-off-by: Peter Xu Reviewed-by: Juan Quintela agree with dave suggestion, even: same_target_page_size O:-) > --- > migration/ram.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/migration/ram.c b/migration/ram.c > index 23cea47090..fbeb23f750 100644 > --- a/migration/ram.c > +++ b/migration/ram.c > @@ -3580,7 +3580,7 @@ static int ram_load_postcopy(QEMUFile *f) > { > int flags = 0, ret = 0; > bool place_needed = false; > - bool matching_page_sizes = false; > + bool matching_target_page_size = false; > MigrationIncomingState *mis = migration_incoming_get_current(); > /* Temporary page that is later 'placed' */ > void *postcopy_host_page = postcopy_get_tmp_page(mis); > @@ -3620,7 +3620,7 @@ static int ram_load_postcopy(QEMUFile *f) > ret = -EINVAL; > break; > } > - matching_page_sizes = block->page_size == TARGET_PAGE_SIZE; > + matching_target_page_size = block->page_size == TARGET_PAGE_SIZE; > /* > * Postcopy requires that we place whole host pages atomically; > * these may be huge pages for RAMBlocks that are backed by > @@ -3668,12 +3668,17 @@ static int ram_load_postcopy(QEMUFile *f) > > case RAM_SAVE_FLAG_PAGE: > all_zero = false; > - if (!place_needed || !matching_page_sizes) { > + if (!matching_target_page_size) { > + /* For huge pages, we always use temporary buffer */ > qemu_get_buffer(f, page_buffer, TARGET_PAGE_SIZE); > } else { > - /* Avoids the qemu_file copy during postcopy, which is > - * going to do a copy later; can only do it when we > - * do this read in one go (matching page sizes) > + /* > + * For small pages that matches target page size, we > + * avoid the qemu_file copy. Instead we directly use > + * the buffer of QEMUFile to place the page. Note: we > + * cannot do any QEMUFile operation before using that > + * buffer to make sure the buffer is valid when > + * placing the page. > */ > qemu_get_buffer_in_place(f, (uint8_t **)&place_source, > TARGET_PAGE_SIZE);