Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934928Ab3DPJKe (ORCPT ); Tue, 16 Apr 2013 05:10:34 -0400 Received: from mail-ee0-f50.google.com ([74.125.83.50]:48727 "EHLO mail-ee0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934807Ab3DPJKb (ORCPT ); Tue, 16 Apr 2013 05:10:31 -0400 Date: Tue, 16 Apr 2013 11:10:27 +0200 From: Ingo Molnar To: Waiman Long Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "Paul E. McKenney" , David Howells , Dave Jones , Clark Williams , Peter Zijlstra , linux-kernel@vger.kernel.org, x86@kernel.org, linux-arch@vger.kernel.org, "Chandramouleeswaran, Aswin" , Davidlohr Bueso , "Norton, Scott J" , Rik van Riel Subject: Re: [PATCH v2 2/3] mutex: Queue mutex spinners with MCS lock to reduce cacheline contention Message-ID: <20130416091026.GB9569@gmail.com> References: <1366036679-9702-1-git-send-email-Waiman.Long@hp.com> <1366036679-9702-3-git-send-email-Waiman.Long@hp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1366036679-9702-3-git-send-email-Waiman.Long@hp.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1639 Lines: 57 * Waiman Long wrote: > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -3021,9 +3021,6 @@ static inline bool owner_running(struct mutex *lock, struct task_struct *owner) > */ > int mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner) > { > - if (!sched_feat(OWNER_SPIN)) > - return 0; > - > rcu_read_lock(); > while (owner_running(lock, owner)) { > if (need_resched()) > @@ -3040,6 +3037,27 @@ int mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner) > */ > return lock->owner == NULL; > } > + > +/* > + * Initial check for entering the mutex spinning loop > + */ > +int mutex_can_spin_on_owner(struct mutex *lock) > +{ > + int retval = 1; > + > + if (!sched_feat(OWNER_SPIN)) > + return 0; > + > + rcu_read_lock(); > + if (lock->owner) > + retval = lock->owner->on_cpu; > + rcu_read_unlock(); > + /* > + * if lock->owner is not set, the mutex owner may have just acquired > + * it and not set the owner yet or the mutex has been released. > + */ > + return retval; > +} The SCHED_FEAT_OWNER_SPIN was really just an early hack we did to make with/without mutex-spinning testable. I'd suggest a preparatory patch that gets rid of that flag and moves these two functions from sched/core.c to mutex.c where they belong. This will also allow the removal of the mutex prototypes from sched.h. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/