From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx200.postini.com [74.125.245.200]) by kanga.kvack.org (Postfix) with SMTP id 6F7646B0005 for ; Thu, 4 Apr 2013 15:10:50 -0400 (EDT) Received: by mail-vc0-f175.google.com with SMTP id hf12so2604434vcb.20 for ; Thu, 04 Apr 2013 12:10:49 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: Date: Thu, 4 Apr 2013 12:10:49 -0700 Message-ID: Subject: Re: [PATCH] mm: prevent mmap_cache race in find_vma() From: Linus Torvalds Content-Type: text/plain; charset=UTF-8 Sender: owner-linux-mm@kvack.org List-ID: To: Hugh Dickins Cc: Andrew Morton , Jan Stancek , Jakub Jelinek , David Rientjes , Johannes Weiner , "Paul E. McKenney" , Ian Lance Taylor , linux-mm , Linux Kernel Mailing List On Thu, Apr 4, 2013 at 12:01 PM, Hugh Dickins wrote: > > When Paul reminded us of it yesterday, I came to wonder if actually > every use of ACCESS_ONCE in the read form should strictly be matched > by ACCESS_ONCE whenever modifying the location. > > My uneducated guess is that strictly it ought to, in the sense of > insurance policy; but that (apart from that strange split writing > issue which came up a couple of months ago) in practice our compilers > have not "advanced" to the point of making this an issue yet. I don't see how a compiler could reasonably really ever do anything different, but I do think the ACCESS_ONCE() modification version might be a good thing just as a "documentation". This is a good example of this issue, exactly because we have a mix of both speculative cases (the find_vma() lookup and modification) together with strictly exclusive locked accesses to the same field (the ones that invalidate the cache under the write lock). So documenting that the write in find_vma() is this kind of "optimistic unlocked access" is actually a potentially interesting piece of information for programmers, completely independently of whether the compiler will then treat it really differently or not. Of course, a plain comment would do the same, but would be less greppable. And despite the verbiage here, I don't really have a very strong opinion on this. I'm going to let it go, and if somebody sends me a patch with a good explanation in the next merge window, I'll probably apply it. Linus -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org