From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753420AbbGOS2O (ORCPT ); Wed, 15 Jul 2015 14:28:14 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:49208 "EHLO e39.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752560AbbGOS2N (ORCPT ); Wed, 15 Jul 2015 14:28:13 -0400 X-Helo: d03dlp02.boulder.ibm.com X-MailFrom: paulmck@linux.vnet.ibm.com X-RcptTo: linux-kernel@vger.kernel.org Date: Wed, 15 Jul 2015 11:28:01 -0700 From: "Paul E. McKenney" To: Peter Zijlstra Cc: Oleg Nesterov , Linus Torvalds , Daniel Wagner , Davidlohr Bueso , Ingo Molnar , Tejun Heo , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/7] rcu: Create rcu_sync infrastructure Message-ID: <20150715182801.GM3717@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <20150711233535.GA829@redhat.com> <20150711233548.GA843@redhat.com> <20150715180546.GJ3717@linux.vnet.ibm.com> <20150715181511.GT19282@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150715181511.GT19282@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15071518-0033-0000-0000-0000052A723A Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 15, 2015 at 08:15:11PM +0200, Peter Zijlstra wrote: > On Wed, Jul 15, 2015 at 11:05:46AM -0700, Paul E. McKenney wrote: > > On Sun, Jul 12, 2015 at 01:35:48AM +0200, Oleg Nesterov wrote: > > > It is functionally equivalent to > > > > > > struct rcu_sync_struct { > > > atomic_t counter; > > > }; > > > > > > static inline bool rcu_sync_is_idle(struct rcu_sync_struct *rss) > > > { > > > > If you add an smp_mb() here... > > > > > return atomic_read(&rss->counter) == 0; > > > } > > > > > > static inline void rcu_sync_enter(struct rcu_sync_struct *rss) > > > { > > > atomic_inc(&rss->counter); > > > synchronize_sched(); > > > } > > > > > > static inline void rcu_sync_exit(struct rcu_sync_struct *rss) > > > { > > > synchronize_sched(); > > > > You should be able to demote the above synchronize_sched() to an > > smp_mb__before_atomic(). Even rare writes should make this tradeoff > > worthwhile. > > No, it makes the read-side primitive contain an unconditional memory > barrier, that forgoes the entire point. > > The writers are stupidly expensive already for they need global > serialization, optimizing them in any way doesn't make sense. That could well be the case, but it would be good to see the numbers. Thanx, Paul