From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 4 18:11:12 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4548492A for ; Thu, 4 Jun 2015 18:11:12 +0000 (UTC) (envelope-from joerg@britannica.bec.de) Received: from mo6-p00-ob.smtp.rzone.de (mo6-p00-ob.smtp.rzone.de [IPv6:2a01:238:20a:202:5300::6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.smtp.rzone.de", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D303E1A8A for ; Thu, 4 Jun 2015 18:11:11 +0000 (UTC) (envelope-from joerg@britannica.bec.de) X-RZG-AUTH: :JiIXek6mfvEEUpFQdo7Fj1/zg48CFjWjQv0cW+St/nW/afgnrylsiW+zbzV1rmQ= X-RZG-CLASS-ID: mo00 Received: from britannica.bec.de (ip-109-45-150-98.web.vodafone.de [109.45.150.98]) by smtp.strato.de (RZmta 37.6 DYNA|AUTH) with ESMTPSA id 20495fr54IApR2b (using TLSv1 with cipher AES256-SHA (256 bits)) (Client did not present a certificate) for ; Thu, 4 Jun 2015 20:10:51 +0200 (CEST) Received: by britannica.bec.de (sSMTP sendmail emulation); Thu, 04 Jun 2015 20:10:41 +0200 Date: Thu, 4 Jun 2015 20:10:41 +0200 From: Joerg Sonnenberger To: freebsd-hackers@freebsd.org Subject: Re: [PATCH] timecounters: Fix timehand generation read/write Message-ID: <20150604181041.GC11630@britannica.bec.de> Mail-Followup-To: freebsd-hackers@freebsd.org References: <1433331966-27548-1-git-send-email-sebastian.huber@embedded-brains.de> <20150603203228.GA9774@britannica.bec.de> <2023236942.13088.1433365253885.JavaMail.zimbra@embedded-brains.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2023236942.13088.1433365253885.JavaMail.zimbra@embedded-brains.de> User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jun 2015 18:11:12 -0000 On Wed, Jun 03, 2015 at 11:00:53PM +0200, Sebastian Huber wrote: > In my interpretation of the C standard this is implementation defined behaviour. See also: > > https://gcc.gnu.org/onlinedocs/gcc/Volatiles.html I don't think that is nearly correct as far as any data accessibly from global objects is concerned beside the volatile. C11 5.1.2.3 (2) and (3) are the relevant clauses. An assignment to a volatile object is a sequence point with side effects. All assignments before that sequence point must be visible to whatever possible side effect the volatile has. Similar, it can implicitly change all globals, so no read can be moved from after the sequence point to before. This is much stricter than the normal as-if rule, since a sequence of side-effect-free operations can be implemented anyway the compiler likes. A different interpretation would be quite questionable. Note that this is all just about the rules of the C abstract machine. It is not about the observable behavior of a multi-processor machine. Whether or not TSO is enough for this purpose is a completely different question. Joerg