From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qnoyd-0001kI-Ep for qemu-devel@nongnu.org; Mon, 01 Aug 2011 05:40:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qnoyc-0002lg-Cv for qemu-devel@nongnu.org; Mon, 01 Aug 2011 05:39:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12470) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qnoyc-0002lK-63 for qemu-devel@nongnu.org; Mon, 01 Aug 2011 05:39:58 -0400 Message-ID: <4E36746A.6040901@redhat.com> Date: Mon, 01 Aug 2011 11:39:54 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH v2 2/3] fine grained qemu_mutex locking for migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Umesh Deshpande Cc: mtosatti@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org, Juan Quintela On 07/29/2011 10:57 PM, Umesh Deshpande wrote: > + qemu_mutex_unlock_iothread(); > > while (s->state == MIG_STATE_ACTIVE) { > if (migrate_fd_check_expire()) { > + qemu_mutex_lock_iothread(); > buffered_rate_tick(s->file); > + qemu_mutex_unlock_iothread(); > } > > if (s->state != MIG_STATE_ACTIVE) { > @@ -392,12 +396,11 @@ void migrate_fd_begin(void *arg) > > if (s->callback) { > migrate_fd_wait_for_unfreeze(s); > + qemu_mutex_lock_iothread(); > s->callback(s); > + qemu_mutex_unlock_iothread(); > } > } > - > -out: > - qemu_mutex_unlock_iothread(); I think it's clearer to unlock explicitly around the waiting points (see review of 1/3). In fact, I think you're working around the busy wait by accessing s->state outside the lock, right? I don't think this is provably safe; moving the knowledge of the thread entirely within buffered_file.c also fixes this, because then the lifetimes of the thread and the QEMUFile are much clearer. Thanks, Paolo