From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtaZc-0006ol-BI for qemu-devel@nongnu.org; Tue, 03 Nov 2015 07:20:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtaZZ-0000fz-89 for qemu-devel@nongnu.org; Tue, 03 Nov 2015 07:20:24 -0500 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:54072 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtaZY-0000fs-V0 for qemu-devel@nongnu.org; Tue, 03 Nov 2015 07:20:21 -0500 References: <1446541276-32467-1-git-send-email-pl@kamp.de> <1446541276-32467-3-git-send-email-pl@kamp.de> <1446547969.4693.12.camel@redhat.com> From: Peter Lieven Message-ID: <5638A680.9020008@kamp.de> Date: Tue, 3 Nov 2015 13:20:16 +0100 MIME-Version: 1.0 In-Reply-To: <1446547969.4693.12.camel@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] io/buffer: avoid memmove at each qio_buffer_advance List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org Am 03.11.2015 um 11:52 schrieb Gerd Hoffmann: >> diff --git a/include/io/buffer.h b/include/io/buffer.h >> index f63869e..43688cc 100644 >> --- a/include/io/buffer.h >> +++ b/include/io/buffer.h >> @@ -39,6 +39,8 @@ struct QIOBuffer { >> size_t offset; >> uint64_t avg_size; >> uint8_t *buffer; >> + size_t base_offs; >> + uint8_t *base_ptr; > Why a separate base_ptr? > > While being at it I'd much prefer to replace offset with start & end. > The buffer content is buffer[start] ... buffer[end-1] then. > > We can allow the buffer to wrap around, i.e. end < start. Buffer > content is buf[start] ... buffer[size-1] and buffer[0] .. buffer[end-1] > then. Makes the buffer management a bit more complicated, but we never > have to memmove then (except when changing buffer size) and the > WASTED_SIZE logic isn't needed too ... Then drop this patch and try to use your approach for 2.6+ Peter