From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2h14-0003sV-Hs for qemu-devel@nongnu.org; Tue, 17 May 2016 11:34:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2h0z-0003yc-DO for qemu-devel@nongnu.org; Tue, 17 May 2016 11:34:37 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:33296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2h0z-0003yS-6n for qemu-devel@nongnu.org; Tue, 17 May 2016 11:34:33 -0400 Received: by mail-wm0-x244.google.com with SMTP id r12so5685426wme.0 for ; Tue, 17 May 2016 08:34:33 -0700 (PDT) Sender: Paolo Bonzini References: <1460719926-12950-1-git-send-email-pbonzini@redhat.com> <1460719926-12950-7-git-send-email-pbonzini@redhat.com> <20160429062646.GJ1421@ad.usersys.redhat.com> From: Paolo Bonzini Message-ID: <1e563292-6623-2287-84f4-b39d08eb61fe@redhat.com> Date: Tue, 17 May 2016 17:34:30 +0200 MIME-Version: 1.0 In-Reply-To: <20160429062646.GJ1421@ad.usersys.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 06/11] coroutine-lock: make CoMutex thread-safe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: qemu-devel@nongnu.org, stefanha@redhat.com, kwolf@redhat.com, berto@igalia.com On 29/04/2016 08:26, Fam Zheng wrote: > > + if (to_wake) { > > + Coroutine *co = to_wake->co; > > + qemu_coroutine_wake(co->ctx, co); > > + goto out; > > + } > > + > > + /* Some concurrent lock() is in progress (we know this because of > > + * count) but it hasn't yet put itself on the wait queue. > > Unlike OSv's lfmutex.cc, we don't seem to have count. Should the comment say > "locked" instead? Yes; we know at least one lock() is in progress because we found mutex->locked > 1. locked cannot decrease until unlock() wakes up someone or until a concurrent lock() completes a handoff---which must be after unlock() writes a nonzero value tomutex->handoff Paolo