From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752830AbbGOSPV (ORCPT ); Wed, 15 Jul 2015 14:15:21 -0400 Received: from casper.infradead.org ([85.118.1.10]:38570 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752081AbbGOSPU (ORCPT ); Wed, 15 Jul 2015 14:15:20 -0400 Date: Wed, 15 Jul 2015 20:15:11 +0200 From: Peter Zijlstra To: "Paul E. McKenney" 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: <20150715181511.GT19282@twins.programming.kicks-ass.net> References: <20150711233535.GA829@redhat.com> <20150711233548.GA843@redhat.com> <20150715180546.GJ3717@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150715180546.GJ3717@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.