Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969052AbdIZQmP (ORCPT ); Tue, 26 Sep 2017 12:42:15 -0400 Received: from resqmta-ch2-05v.sys.comcast.net ([69.252.207.37]:48164 "EHLO resqmta-ch2-05v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967767AbdIZQmL (ORCPT ); Tue, 26 Sep 2017 12:42:11 -0400 Date: Tue, 26 Sep 2017 11:42:09 -0500 (CDT) From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Thomas Gleixner 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-CMAE-Envelope: MS4wfC2QkSIOQgFSJpg4Bzc44A30n3A30foaLf95DzWfgJnfaR/BvFyQ4a97vW2zkT2AH+rukZrIaisEpHFFDZIcwHrOGk2Lav7PuvsZ9Mww13Agxk1xKEaz V9Cm7XJ7Ttas9n/HFJJgwFtPqHWpYOtbpbTPjtBBVe378tEzYUO6W0R4YlAm5WHj6W/9aNctZDU+7g0C/HPeR4ZKsuYx5TUVgJgM+U9qaGagtf2wgnKScBup VP03G4hKz9tle8nXmgilF3oui+SZxjDIhRO55u1yE4Ror6o++sC9pvAgm/E9GSVJdiT6oigRYABWfvfQxw6x+hAo7LlPJNc8H5k2ylXOhX0b+ui1jUbE2KVs 459EbnR62ydcdY9frrfADt6EhbaJ5S1qeKIRiIFpmuQukBv/+6W2Wk4jD+yFceGog1b1GsSV Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1389 Lines: 32 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.