From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bu7W7-0006YI-2B for qemu-devel@nongnu.org; Tue, 11 Oct 2016 20:35:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bu7W4-00086T-U1 for qemu-devel@nongnu.org; Tue, 11 Oct 2016 20:35:29 -0400 Message-ID: <57FD870A.5070902@cn.fujitsu.com> Date: Wed, 12 Oct 2016 08:42:50 +0800 From: Changlong Xie MIME-Version: 1.0 References: <57FCC06A.8060608@cn.fujitsu.com> <41ca850c-034f-156d-0551-2ecb649c1bb0@redhat.com> In-Reply-To: <41ca850c-034f-156d-0551-2ecb649c1bb0@redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Questions] NBD issue or CoMutex->holder issue? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu devel , qemu block , Kevin Wolf , Stefan Hajnoczi , Max Reitz , Fam Zheng , Eric Blake , Wen Congyang On 10/11/2016 06:47 PM, Paolo Bonzini wrote: >> the free_sema->queue head, so set free_sema->holder as >> >revelant coroutine. > NBD is using the CoMutex in a way that wasn't anticipated. The simplest > fix is to change it to CoQueue, which is like a condition variable. > Instead of locking if in_flight >= MAX_NBD_REQUESTS - 1, wait on the > queue while in_flight == MAX_NBD_REQUESTS. Instead of unlocking, use > qemu_co_queue_next to wake up one request. > Thanks for your explanation! will send out a patch later. Thanks -Xie > Thanks for the report! > > Paolo > >> >For example if there are N(N=26 and MAX_NBD_REQUESTS=16) nbd write >> >requests, so we'll invoke nbd_client_co_pwritev 26 times. >> >time request No Actions >> >1 1 in_flight=1, Coroutine=C1 >> >2 2 in_flight=2, Coroutine=C2