From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751519AbdFIKFX (ORCPT ); Fri, 9 Jun 2017 06:05:23 -0400 Received: from foss.arm.com ([217.140.101.70]:36024 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751540AbdFIKFV (ORCPT ); Fri, 9 Jun 2017 06:05:21 -0400 Date: Fri, 9 Jun 2017 11:05:29 +0100 From: Will Deacon To: Peter Zijlstra Cc: Vlastimil Babka , "Kirill A. Shutemov" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, mark.rutland@arm.com, akpm@linux-foundation.org, Punit.Agrawal@arm.com, mgorman@suse.de, steve.capper@arm.com Subject: Re: [PATCH 2/3] mm/page_ref: Ensure page_ref_unfreeze is ordered against prior accesses Message-ID: <20170609100529.GD13955@arm.com> References: <1496771916-28203-1-git-send-email-will.deacon@arm.com> <1496771916-28203-3-git-send-email-will.deacon@arm.com> <20170608104056.ujuytybmwumuty64@black.fi.intel.com> <20170608112433.GH6071@arm.com> <20170608125059.4iufydsp7dsopsbz@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170608125059.4iufydsp7dsopsbz@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 08, 2017 at 02:50:59PM +0200, Peter Zijlstra wrote: > On Thu, Jun 08, 2017 at 12:24:33PM +0100, Will Deacon wrote: > > [+ PeterZ] > > > > On Thu, Jun 08, 2017 at 01:07:02PM +0200, Vlastimil Babka wrote: > > > On 06/08/2017 12:40 PM, Kirill A. Shutemov wrote: > > > > On Thu, Jun 08, 2017 at 11:38:21AM +0200, Vlastimil Babka wrote: > > > >> On 06/06/2017 07:58 PM, Will Deacon wrote: > > > >>> include/linux/page_ref.h | 1 + > > > >>> 1 file changed, 1 insertion(+) > > > >>> > > > >>> diff --git a/include/linux/page_ref.h b/include/linux/page_ref.h > > > >>> index 610e13271918..74d32d7905cb 100644 > > > >>> --- a/include/linux/page_ref.h > > > >>> +++ b/include/linux/page_ref.h > > > >>> @@ -174,6 +174,7 @@ static inline void page_ref_unfreeze(struct page *page, int count) > > > >>> VM_BUG_ON_PAGE(page_count(page) != 0, page); > > > >>> VM_BUG_ON(count == 0); > > > >>> > > > >>> + smp_mb__before_atomic(); > > > >>> atomic_set(&page->_refcount, count); > > So depending on what it actually required, we do have > atomic_set_release() (atomic_t equivalent to smp_store_release()). Yeah, I was wondering about that this morning. I think it should do the trick here, but smp_mb() would be a better fit for the other parts of this API (page_ref_freeze uses atomic_cmpxchg and page_cache_get_speculative uses atomic_add_unless). I'll send a v2 with the full barrier. Will