From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boQLp-0007V0-7m for qemu-devel@nongnu.org; Mon, 26 Sep 2016 03:29:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1boQLl-0007wf-PU for qemu-devel@nongnu.org; Mon, 26 Sep 2016 03:29:21 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:38885) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boQLk-0007va-Ei for qemu-devel@nongnu.org; Mon, 26 Sep 2016 03:29:17 -0400 Received: by mail-wm0-f54.google.com with SMTP id l132so133137854wmf.1 for ; Mon, 26 Sep 2016 00:29:14 -0700 (PDT) References: <1474615909-17069-1-git-send-email-pbonzini@redhat.com> <1474615909-17069-17-git-send-email-pbonzini@redhat.com> <20d59fed-4187-28d2-c179-5e66571d5e49@twiddle.net> <1267831407.2636295.1474717973602.JavaMail.zimbra@redhat.com> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: Date: Mon, 26 Sep 2016 08:28:12 +0100 Message-ID: <87a8evglwz.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 16/16] cpus-common: lock-free fast path for cpu_exec_start/end List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Richard Henderson , serge fdrv , cota@braap.org, qemu-devel@nongnu.org, sergey fedorov Paolo Bonzini writes: > On 24/09/2016 22:43, Richard Henderson wrote: >>>> I don't see that the cpu_list_lock protects the >>>> last two lines in any way. >>> >>> It does: >>> >>> qemu_mutex_lock(&qemu_cpu_list_lock); >> >> What I meant is that I don't see that the mutex avoids the need for >> atomic_set. > > Oh, I see. > > cpu->running is only read under the mutex, but can be written _by the > owner thread only_ outside the mutex. So writes outside the mutex must > be atomic, but writes under the mutex don't because: > > - no other thread ever writes to cpu->running > > - no other thread can be reading cpu->running Should we add some comments to cpu.h's definitions to make the rules clear? -- Alex Bennée