From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAKWM-00082w-Gl for qemu-devel@nongnu.org; Wed, 01 Jul 2015 12:05:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAKWL-0002EM-9P for qemu-devel@nongnu.org; Wed, 01 Jul 2015 12:05:58 -0400 MIME-Version: 1.0 In-Reply-To: <5594015C.20104@redhat.com> References: <1435761950-26714-1-git-send-email-stefanha@redhat.com> <5593FD66.5020002@redhat.com> <5594015C.20104@redhat.com> Date: Wed, 1 Jul 2015 17:05:56 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] block/mirror: limit qiov to IOV_MAX elements List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu block , qemu-devel , Stefan Hajnoczi On Wed, Jul 1, 2015 at 4:03 PM, Paolo Bonzini wrote: > On 01/07/2015 16:59, Stefan Hajnoczi wrote: >> I found it annoying to write it backwards too, but it's for consistency: >> >> if (s->buf_free_count < nb_chunks + added_chunks) { >> trace_mirror_break_buf_busy(s, nb_chunks, s->in_flight); >> break; >> } >> if (IOV_MAX < nb_chunks + added_chunks) { >> trace_mirror_break_iov_max(s, nb_chunks, added_chunks); >> break; >> } >> >> It's the same type of check as s->buf_free_count (which isn't modified >> by this loop either so it's a yoda conditional). > > Hmm, right. The problem goes back to: > > while (nb_chunks == 0 && s->buf_free_count < added_chunks) { > trace_mirror_yield_buf_busy(s, nb_chunks, s->in_flight); > qemu_coroutine_yield(); > } > > where s->buf_free_count _is_ modified by the loop. The if below: > > if (s->buf_free_count < nb_chunks + added_chunks) { > trace_mirror_break_buf_busy(s, nb_chunks, s->in_flight); > break; > } > > is written as a < check for consistency, and the one you add exacerbates > the problem. If you want you can change the < to > in the "while" loop > as well; otherwise the patch is okay as is. Let's leave it.