Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751377AbbEARkT (ORCPT ); Fri, 1 May 2015 13:40:19 -0400 Received: from g9t5008.houston.hp.com ([15.240.92.66]:47233 "EHLO g9t5008.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750812AbbEARkR (ORCPT ); Fri, 1 May 2015 13:40:17 -0400 Message-ID: <1430502008.4566.4.camel@j-VirtualBox> Subject: Re: [PATCH v2 2/5] sched, numa: Document usages of mm->numa_scan_seq From: Jason Low To: paulmck@linux.vnet.ibm.com Cc: Waiman Long , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , linux-kernel@vger.kernel.org, Andrew Morton , Oleg Nesterov , Frederic Weisbecker , Mel Gorman , Rik van Riel , Steven Rostedt , Preeti U Murthy , Mike Galbraith , Davidlohr Bueso , Aswin Chandramouleeswaran , Scott J Norton , jason.low2@hp.com Date: Fri, 01 May 2015 10:40:08 -0700 In-Reply-To: <20150501152157.GF5381@linux.vnet.ibm.com> References: <1430251224-5764-1-git-send-email-jason.low2@hp.com> <1430251224-5764-3-git-send-email-jason.low2@hp.com> <55411F91.6050101@hp.com> <1430333101.8722.32.camel@j-VirtualBox> <55427794.30808@hp.com> <1430428387.2475.47.camel@j-VirtualBox> <20150501152157.GF5381@linux.vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2259 Lines: 41 On Fri, 2015-05-01 at 08:21 -0700, Paul E. McKenney wrote: > On Thu, Apr 30, 2015 at 02:13:07PM -0700, Jason Low wrote: > > On Thu, 2015-04-30 at 14:42 -0400, Waiman Long wrote: > > > > > I do have a question of what kind of tearing you are talking about. Do > > > you mean the tearing due to mm being changed in the middle of the > > > access? The reason why I don't like this kind of construct is that I am > > > not sure if > > > the address translation p->mm->numa_scan_seq is being done once or > > > twice. I looked at the compiled code and the translation is done only once. > > > > > > Anyway, the purpose of READ_ONCE and WRITE_ONCE is not for eliminating > > > data tearing. They are to make sure that the compiler won't compile away > > > data access and they are done in the order they appear in the program. I > > > don't think it is a good idea to associate tearing elimination with > > > those macros. So I would suggest removing the last sentence in your comment. > > > > Yes, I can remove the last sentence in the comment since the main goal > > was to document that we're access this field without exclusive access. > > > > In terms of data tearing, an example would be the write operation gets > > split into multiple stores (though this is architecture dependent). The > > idea was that since we're modifying a seq variable without the write > > lock, we want to remove any forms of optimizations as mentioned above or > > unpredictable behavior, since READ_ONCE/WRITE_ONCE adds no overhead. > > Just to be clear... READ_ONCE() and WRITE_ONCE() do not avoid data tearing > in cases where the thing read or written is too big for a machine word. Right, that makes sense. I've updated the comment to instead mention that it's used to avoid "compiler optimizations". > If the thing read/written does fit into a machine word and if the location > read/written is properly aligned, I would be quite surprised if either > READ_ONCE() or WRITE_ONCE() resulted in any sort of tearing. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/