From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752303AbbFKHbt (ORCPT ); Thu, 11 Jun 2015 03:31:49 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:46900 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751245AbbFKHbm (ORCPT ); Thu, 11 Jun 2015 03:31:42 -0400 Date: Thu, 11 Jun 2015 09:31:28 +0200 From: Peter Zijlstra To: Oleg Nesterov Cc: Kirill Tkhai , umgwanakikbuti@gmail.com, mingo@elte.hu, ktkhai@parallels.com, rostedt@goodmis.org, tglx@linutronix.de, juri.lelli@gmail.com, pang.xunlei@linaro.org, wanpeng.li@linux.intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 08/14] hrtimer: Allow hrtimer::function() to free the timer Message-ID: <20150611073128.GQ19282@twins.programming.kicks-ass.net> References: <20150605084836.364306429@infradead.org> <20150605085205.723058588@infradead.org> <20150607223317.GA5193@redhat.com> <20150608091417.GM19282@twins.programming.kicks-ass.net> <20150608124234.GW18673@twins.programming.kicks-ass.net> <20150609213318.GA12436@redhat.com> <1433922411.23588.132.camel@odin.com> <20150610160444.GB3341@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150610160444.GB3341@redhat.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 10, 2015 at 06:04:44PM +0200, Oleg Nesterov wrote: > If we rely on the "locking" semantics of seqcount_t, this doesn't really > differ from > > spinlock_t LOCK; > bool X = true, Y = false; > > void read(void) > { > bool x, y; > > spin_lock(LOCK); > x = X; y = Y; > spin_unlock(LOCK); > > BUG_ON(!x && !y); > } > > void write(void) > { > Y = true; > > spin_lock(LOCK); > spin_unlock(LOCK); > > X = false; > } So when I first saw that I went, wait what? Because I looked at it like: Y = true; ACQUIRE RELEASE X = false; And we both know that is not ordered at all. But its the actual lock semantics that make it work, we cannot acquire until the other completes, at which time the acquire matches its release and things end up ordered again. And its exactly that part we lost in our transformation C yesterday. In any case, breakfast time, will go do the patches shortly.