Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753109AbdI0JEC (ORCPT ); Wed, 27 Sep 2017 05:04:02 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:51472 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752281AbdI0JBY (ORCPT ); Wed, 27 Sep 2017 05:01:24 -0400 Date: Wed, 27 Sep 2017 11:01:13 +0200 (CEST) From: Thomas Gleixner To: Christopher Lameter cc: Tejun Heo , Mark Rutland , linux-kernel@vger.kernel.org, Arnd Bergmann , Peter Zijlstra , Pranith Kumar , linux-arch@vger.kernel.org, "Paul E. McKenney" Subject: Re: [PATCH] percpu: make this_cpu_generic_read() atomic w.r.t. interrupts In-Reply-To: Message-ID: References: <1506345872-30559-1-git-send-email-mark.rutland@arm.com> <20170925151826.GK828415@devbig577.frc2.facebook.com> <20170925153301.GA29775@leverpostej> <20170925154404.GA560070@devbig577.frc2.facebook.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1853 Lines: 44 On Tue, 26 Sep 2017, Christopher Lameter wrote: > On Tue, 26 Sep 2017, Thomas Gleixner wrote: > > > > because it could also occur before or after the preempt_enable/disable > > > without the code being able to distinguish that case. > > > > > > The fetch of a scalar value from memory is an atomic operation and that is > > > required from all arches. There is an exception for double word fetches. > > > > this_cpu_read_8() is a double word fetch on many 32bit architectures. > > Ok then this_cpu_read_8 for those platforms need to disable interrupts. > But that is not true for all arches. > > > > Maybe we would need to special code that case but so far this does not > > > seem to have been an issue. > > > > Just because nobody ran into problem with that it is a non issue? That's > > just hillarious. > > Its is even more (see your above statement) stupid to figure out that this > is actually unnecessary in the generic case and then continue the > argument. > > > It's obviously not correct and needs to be fixed _before_ someone has to go > > through the pain of debugging such a problem. > > As you pointed out the current approach *is* correct. Fetching a scalar > word is an atomic operation and must be one. If an arch cannot guarantee > that then arch specific measures need to be implemented to ensure that > this guarantee is kept. Could be done with interrupts disables, cmpxchg or > the reservation scheme on RISC processors. It definitely does not > belong into generic code. Wrong. The default for 32bit architectures is that they CANNOT do atomic fetch/write of 8 bytes. So instead of forcing that to be implemented in every affected architecture this wants to be addressed in generic code and those few 32bit architectures which can do atomic double word fetch/write implement the magic functions to do so. Thanks, tglx