From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx177.postini.com [74.125.245.177]) by kanga.kvack.org (Postfix) with SMTP id 9422B6B0032 for ; Wed, 26 Jun 2013 11:20:03 -0400 (EDT) Date: Wed, 26 Jun 2013 14:53:38 +0200 From: Peter Zijlstra Subject: Re: [PATCH v2 5/5] rwsem: do optimistic spinning for writer lock acquisition Message-ID: <20130626125338.GK28407@twins.programming.kicks-ass.net> References: <1372116051.22432.95.camel@schen9-DESK> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1372116051.22432.95.camel@schen9-DESK> Sender: owner-linux-mm@kvack.org List-ID: To: Tim Chen Cc: Ingo Molnar , Andrew Morton , Andrea Arcangeli , Alex Shi , Andi Kleen , Michel Lespinasse , Davidlohr Bueso , Matthew R Wilcox , Dave Hansen , Rik van Riel , Peter Hurley , linux-kernel@vger.kernel.org, linux-mm On Mon, Jun 24, 2013 at 04:20:51PM -0700, Tim Chen wrote: > +#ifdef CONFIG_RWSEM_SPIN_ON_WRITE_OWNER > +static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem) > +{ > + int retval; > + task_struct *owner; > + > + rcu_read_lock(); > + owner = sem->owner; That wants to be: owner = ACCESS_ONCE(sem->owner); > + > + /* Spin only if active writer running */ > + if (owner) > + retval = owner->on_cpu; > + else > + retval = false; > + > + rcu_read_unlock(); > + /* > + * if lock->owner is not set, the sem owner may have just acquired > + * it and not set the owner yet, or the sem has been released, or > + * reader active. > + */ > + return retval; > +} -- 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