From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Czj-0002nw-1m for qemu-devel@nongnu.org; Tue, 24 May 2016 10:07:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5CzZ-0001UW-Tc for qemu-devel@nongnu.org; Tue, 24 May 2016 10:07:38 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:35721 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5CzZ-0001TW-Ko for qemu-devel@nongnu.org; Tue, 24 May 2016 10:07:29 -0400 References: <1464097151-19479-1-git-send-email-pl@kamp.de> From: Peter Lieven Message-ID: <5744601B.9040905@kamp.de> Date: Tue, 24 May 2016 16:07:23 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] block/io: optimize bdrv_co_pwritev for small requests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-block@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com Am 24.05.2016 um 15:59 schrieb Paolo Bonzini: > > On 24/05/2016 15:39, Peter Lieven wrote: >> bytes += offset & (align - 1); >> offset = offset & ~(align - 1); > Because the low bits have been masked away from offset and added to bytes, > >> + >> + /* if head and tail fall into the same alignment >> + * we can omit the second read as it would read >> + * the same block again */ >> + if ((offset + bytes) & (align - 1) && > ... the first part is just "bytes & (align - 1)"... > >> + offset / align == (offset + bytes) / align) { > ... and the second part is just "bytes < align" (you can distribute > division over addition because offset / align has no reminder, and > simplify to "0 == bytes / align"). > > Putting it together, it becomes "bytes > 0 && bytes < align", or even > "bytes < align". Oh, thanks, and the if block also too complicated. If I am right it should collapse to: if (bytes < align) { qemu_iovec_add(&local_qiov, head_buf + bytes, align - bytes); bytes = align; } Right? Thanks, Peter