From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPXXZ-0000yB-Jw for qemu-devel@nongnu.org; Tue, 09 Apr 2013 08:20:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPXXY-0002G9-8e for qemu-devel@nongnu.org; Tue, 09 Apr 2013 08:20:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8894) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPXXX-0002Fy-VU for qemu-devel@nongnu.org; Tue, 09 Apr 2013 08:20:44 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r39CKh5x014458 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Apr 2013 08:20:43 -0400 Message-ID: <516407FF.2050904@redhat.com> Date: Tue, 09 Apr 2013 15:22:23 +0300 From: Orit Wasserman MIME-Version: 1.0 References: <1365420597-5506-1-git-send-email-pbonzini@redhat.com> <1365420597-5506-5-git-send-email-pbonzini@redhat.com> <874nfgdj51.fsf@elfo.elfo> <5164013A.6030407@redhat.com> In-Reply-To: <5164013A.6030407@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 4/4] migration: simplify writev vs. non-writev logic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, qemu-devel@nongnu.org, quintela@redhat.com On 04/09/2013 02:53 PM, Paolo Bonzini wrote: > Il 09/04/2013 13:43, Juan Quintela ha scritto: >>>> @@ -687,12 +685,10 @@ void qemu_put_byte(QEMUFile *f, int v) >>>> f->bytes_xfer++; >>>> if (f->ops->writev_buffer) { >>>> add_to_iovec(f, f->buf + f->buf_index, 1); >>>> - f->buf_index++; >>>> - } else { >>>> - f->buf_index++; >>>> - if (f->buf_index == IO_BUF_SIZE) { >>>> - qemu_fflush(f); >>>> - } >>>> + } >>>> + f->buf_index++; >>>> + if (f->buf_index == IO_BUF_SIZE) { >>>> + qemu_fflush(f); >>>> } >>>> } >> If you follow my advice of moving the call to add_to_iovec() you get >> this one simplified and only one place to do this. > > Moving what call? The apparent complication is because the old logic > was a bit more involute than necessary. If you look at the code after > the patches, not the patches themselves, you'll see for yourself. > > The logic now is: > > add byte > if using iovs > add byte to iov list > if buffer full > flush > > add_to_iovec has no business checking the buffer. Why should > qemu_put_buffer_async() check the buffer? > > The duplication between qemu_put_byte and qemu_put_buffer is a different > topic. I think it's acceptable in the name of performance, but perhaps > you can just call qemu_put_buffer(f, &c, 1). I thought about it too, we can keep the optimization by checking the size Orit > > Paolo >