From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjUdT-0001Cw-T5 for qemu-devel@nongnu.org; Fri, 14 Dec 2012 07:45:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjUdR-0000QO-J7 for qemu-devel@nongnu.org; Fri, 14 Dec 2012 07:45:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:29658) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjUdR-0000P8-Ac for qemu-devel@nongnu.org; Fri, 14 Dec 2012 07:45:01 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBECj0ei008629 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 14 Dec 2012 07:45:00 -0500 From: Juan Quintela In-Reply-To: <505C88AD.4030800@redhat.com> (Paolo Bonzini's message of "Fri, 21 Sep 2012 17:33:01 +0200") References: <1348236500-2565-1-git-send-email-quintela@redhat.com> <1348236500-2565-10-git-send-email-quintela@redhat.com> <505C88AD.4030800@redhat.com> Date: Fri, 14 Dec 2012 13:44:51 +0100 Message-ID: <874njog5vg.fsf@elfo.mitica> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 09/14] migration: take finer locking Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org Paolo Bonzini wrote: > Il 21/09/2012 16:08, Juan Quintela ha scritto: >> Instead of locking the whole migration_thread inside loop, just lock >> migration_fd_put_notify, that is what interacts with the rest of the >> world. > > Wrong commit message: just lock migrate_fd_put_ready. Fixed. >> @@ -305,8 +305,10 @@ void migrate_fd_put_ready(MigrationState *s) >> int ret; >> static bool first_time = true; >> >> + qemu_mutex_lock_iothread(); >> if (s->state != MIG_STATE_ACTIVE) { >> DPRINTF("put_ready returning because of non-active state\n"); >> + qemu_mutex_unlock_iothread(); > > Please use a goto instead. > >> return; >> } >> if (first_time) { >> @@ -316,6 +318,7 @@ void migrate_fd_put_ready(MigrationState *s) >> if (ret < 0) { >> DPRINTF("failed, %d\n", ret); >> migrate_fd_error(s); >> + qemu_mutex_unlock_iothread(); > > Same here. > Don't work. The last branch of the code drops the lock before the end. Code is: lock() while() { if (foo) { ... unlock() break; } if (bar) { ... unlock() break; } unlock() ... /* this is the interesting bit */ } .... /* more stuff needed both sides */ adding a goto would not help making things clearer. >> return; >> } >> } >> @@ -351,6 +354,8 @@ void migrate_fd_put_ready(MigrationState *s) >> } >> } >> } >> + qemu_mutex_unlock_iothread(); >> + >> } >> >> static void migrate_fd_cancel(MigrationState *s) >>