From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df71G-0001CZ-2X for qemu-devel@nongnu.org; Tue, 08 Aug 2017 12:06:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df71E-0003vJ-TE for qemu-devel@nongnu.org; Tue, 08 Aug 2017 12:06:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46806) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df71E-0003uk-Mb for qemu-devel@nongnu.org; Tue, 08 Aug 2017 12:06:08 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 929D261493 for ; Tue, 8 Aug 2017 16:06:07 +0000 (UTC) From: Juan Quintela In-Reply-To: <20170720094947.GD23385@pxdev.xzpeter.org> (Peter Xu's message of "Thu, 20 Jul 2017 17:49:47 +0800") References: <20170717134238.1966-1-quintela@redhat.com> <20170717134238.1966-12-quintela@redhat.com> <20170720094947.GD23385@pxdev.xzpeter.org> Reply-To: quintela@redhat.com Date: Tue, 08 Aug 2017 18:06:04 +0200 Message-ID: <878tiu82oj.fsf@secure.mitica> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v5 11/17] migration: Really use multiple pages at a time List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu Cc: qemu-devel@nongnu.org, dgilbert@redhat.com, lvivier@redhat.com, berrange@redhat.com Peter Xu wrote: > On Mon, Jul 17, 2017 at 03:42:32PM +0200, Juan Quintela wrote: > > [...] > >> static int multifd_send_page(uint8_t *address) >> { >> - int i; >> + int i, j; >> MultiFDSendParams *p = NULL; /* make happy gcc */ >> + static multifd_pages_t pages; >> + static bool once; >> + >> + if (!once) { >> + multifd_init_group(&pages); >> + once = true; > > Would it be good to put the "pages" into multifd_send_state? One is to > stick globals together; another benefit is that we can remove the > "once" here: we can then init the "pages" when init multifd_send_state > struct (but maybe with a better name?...). I did to be able to free it. > (there are similar static variables in multifd_recv_page() as well, if > this one applies, then we can possibly use multifd_recv_state for > that one) Also there. >> + } >> + >> + pages.iov[pages.num].iov_base = address; >> + pages.iov[pages.num].iov_len = TARGET_PAGE_SIZE; >> + pages.num++; >> + >> + if (pages.num < (pages.size - 1)) { >> + return UINT16_MAX; > > Nit: shall we define something for readability? Like: > > #define MULTIFD_FD_INVALID UINT16_MAX Also done. MULTIFD_CONTINUE But I am open to changes. >> + } >> >> qemu_sem_wait(&multifd_send_state->sem); >> qemu_mutex_lock(&multifd_send_state->mutex); >> @@ -530,7 +559,12 @@ static int multifd_send_page(uint8_t *address) >> } >> qemu_mutex_unlock(&multifd_send_state->mutex); >> qemu_mutex_lock(&p->mutex); >> - p->address = address; >> + p->pages.num = pages.num; >> + for (j = 0; j < pages.size; j++) { >> + p->pages.iov[j].iov_base = pages.iov[j].iov_base; >> + p->pages.iov[j].iov_len = pages.iov[j].iov_len; >> + } >> + pages.num = 0; >> qemu_mutex_unlock(&p->mutex); >> qemu_sem_post(&p->sem); >> >> -- >> 2.9.4 >>