From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boQDv-0002hG-S2 for qemu-devel@nongnu.org; Mon, 26 Sep 2016 03:21:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1boQDr-0005g8-LW for qemu-devel@nongnu.org; Mon, 26 Sep 2016 03:21:10 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:37946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boQDr-0005fw-FS for qemu-devel@nongnu.org; Mon, 26 Sep 2016 03:21:07 -0400 Received: by mail-wm0-f47.google.com with SMTP id l132so132770344wmf.1 for ; Mon, 26 Sep 2016 00:21:07 -0700 (PDT) Sender: Paolo Bonzini 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: Paolo Bonzini Message-ID: Date: Mon, 26 Sep 2016 09:20:05 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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: Richard Henderson Cc: serge fdrv , cota@braap.org, alex bennee , qemu-devel@nongnu.org, sergey fedorov 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 Paolo