From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752827AbbCJMbG (ORCPT ); Tue, 10 Mar 2015 08:31:06 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:52395 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752300AbbCJMbC (ORCPT ); Tue, 10 Mar 2015 08:31:02 -0400 Date: Tue, 10 Mar 2015 13:30:57 +0100 From: Peter Zijlstra To: Sebastian Andrzej Siewior Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Maarten Lankhorst , Mike Galbraith Subject: Re: [PATCH 2/3] locking: ww_mutex: Allow to use rt_mutex instead of mutex for the baselock Message-ID: <20150310123057.GZ2896@worktop.programming.kicks-ass.net> References: <1425056229-22326-1-git-send-email-bigeasy@linutronix.de> <1425056229-22326-3-git-send-email-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1425056229-22326-3-git-send-email-bigeasy@linutronix.de> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 27, 2015 at 05:57:08PM +0100, Sebastian Andrzej Siewior wrote: > diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c > index 16b2d3cc88b0..0a652ba46081 100644 > --- a/kernel/locking/mutex.c > +++ b/kernel/locking/mutex.c > @@ -106,6 +106,7 @@ void __sched mutex_lock(struct mutex *lock) > EXPORT_SYMBOL(mutex_lock); > #endif > > +#ifndef CONFIG_WW_MUTEX_RTMUTEX > static __always_inline void ww_mutex_lock_acquired(struct ww_mutex *ww, > struct ww_acquire_ctx *ww_ctx) > { > @@ -215,6 +216,7 @@ ww_mutex_set_context_slowpath(struct ww_mutex *lock, > wake_up_process(cur->task); > } > } > +#endif Should we shuffle the code a bit to collect all the ww_mutex functions in one #ifdef block? > #ifdef CONFIG_MUTEX_SPIN_ON_OWNER > /* > @@ -328,6 +330,7 @@ static bool mutex_optimistic_spin(struct mutex *lock, > while (true) { > struct task_struct *owner; > > +#ifndef CONFIG_WW_MUTEX_RTMUTEX > if (use_ww_ctx && ww_ctx->acquired > 0) { > struct ww_mutex *ww; > > @@ -343,7 +346,7 @@ static bool mutex_optimistic_spin(struct mutex *lock, > if (READ_ONCE(ww->ctx)) > break; > } > - > +#endif > /* > * If there's an owner, wait for it to either > * release the lock or go to sleep. > @@ -356,12 +359,14 @@ static bool mutex_optimistic_spin(struct mutex *lock, > if (mutex_try_to_acquire(lock)) { > lock_acquired(&lock->dep_map, ip); > > +#ifndef CONFIG_WW_MUTEX_RTMUTEX > if (use_ww_ctx) { > struct ww_mutex *ww; > ww = container_of(lock, struct ww_mutex, base); > > ww_mutex_set_context_fastpath(ww, ww_ctx); > } > +#endif > > mutex_set_owner(lock); > osq_unlock(&lock->osq); > @@ -445,6 +450,7 @@ void __sched mutex_unlock(struct mutex *lock) > > EXPORT_SYMBOL(mutex_unlock); Are those ifdefs really needed, if we provide stubs and ensure to only call mutex_optimistic_spin/__mutex_lock_common with .ww_ctx=NULL, .use_ww_ctx = false, this should all just go away without #ifdefs, right?