From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fzON0-0000uX-Ul for qemu-devel@nongnu.org; Mon, 10 Sep 2018 11:44:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fzOMw-0007N4-Me for qemu-devel@nongnu.org; Mon, 10 Sep 2018 11:44:58 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:59523) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fzOMp-0007KB-V2 for qemu-devel@nongnu.org; Mon, 10 Sep 2018 11:44:50 -0400 Date: Mon, 10 Sep 2018 11:44:42 -0400 From: "Emilio G. Cota" Message-ID: <20180910154442.GD19941@flamenco> References: <20180903171831.15446-1-cota@braap.org> <20180903171831.15446-2-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH 1/6] qsp: drop atomics when using the seqlock List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, Peter Crosthwaite , Richard Henderson , Eduardo Habkost , Alex =?iso-8859-1?Q?Benn=E9e?= On Mon, Sep 10, 2018 at 01:32:15 +0200, Paolo Bonzini wrote: > On 03/09/2018 19:18, Emilio G. Cota wrote: > > Using atomics here is a mistake since they're not guaranteed > > to compile. > > But isn't it technically a C11 data race if you don't use atomics? Yes, it's undefined behaviour. > Could we make nocheck read/set degrade to just a volatile access when > used on a variable that is bigger than pointers, or perhaps always > except when using tsan? But volatile wouldn't save you from undefined behaviour, would it? A simpler and definitely correct alternative is to just use a spinlock instead of the seqlock also for reads when !CONFIG_ATOMIC64. We don't care about scalability on those rare hosts anyway, so I'd go with that. Thanks, Emilio