LWN.net Logo

Re: [PATCH -v11][RFC] mutex: implement adaptive spinning

From:  Nick Piggin <npiggin-AT-suse.de>
To:  Peter Zijlstra <peterz-AT-infradead.org>
Subject:  Re: [PATCH -v11][RFC] mutex: implement adaptive spinning
Date:  Wed, 14 Jan 2009 18:18:00 +0100
Message-ID:  <20090114171800.GA18621@wotan.suse.de>
Cc:  Linus Torvalds <torvalds-AT-linux-foundation.org>, Ingo Molnar <mingo-AT-elte.hu>, "Paul E. McKenney" <paulmck-AT-linux.vnet.ibm.com>, Gregory Haskins <ghaskins-AT-novell.com>, Matthew Wilcox <matthew-AT-wil.cx>, Andi Kleen <andi-AT-firstfloor.org>, Chris Mason <chris.mason-AT-oracle.com>, Andrew Morton <akpm-AT-linux-foundation.org>, Linux Kernel Mailing List <linux-kernel-AT-vger.kernel.org>, linux-fsdevel <linux-fsdevel-AT-vger.kernel.org>, linux-btrfs <linux-btrfs-AT-vger.kernel.org>, Thomas Gleixner <tglx-AT-linutronix.de>, Peter Morreale <pmorreale-AT-novell.com>, Sven Dietrich <SDietrich-AT-novell.com>, Dmitry Adamushko <dmitry.adamushko-AT-gmail.com>, Johannes Weiner <hannes-AT-cmpxchg.org>
Archive-link:  Article, Thread

On Wed, Jan 14, 2009 at 06:00:36PM +0100, Peter Zijlstra wrote:
> Full series, including changelogs available at:
> 
>  http://programming.kicks-ass.net/kernel-patches/mutex-ada...
> 
> and should shortly appear in a git tree near Ingo :-)

Linus is going to take a wholesale conversion of mutexes to adaptive
mutexes? He's gone soft. I put on my asbestos underwear for no reason,
then.

 
> @@ -173,21 +237,21 @@ __mutex_lock_common(struct mutex *lock, 
>  			spin_unlock_mutex(&lock->wait_lock, flags);
>  
>  			debug_mutex_free_waiter(&waiter);
> +			preempt_enable();
>  			return -EINTR;
>  		}
>  		__set_task_state(task, state);
>  
>  		/* didnt get the lock, go to sleep: */
>  		spin_unlock_mutex(&lock->wait_lock, flags);
> -		schedule();
> +		__schedule();

Why does this need to do a preempt-disabled schedule? After we schedule
away, the next task can do arbitrary things or reschedule itself, so if
we have not anticipated such a condition here, then I can't see what
__schedule protects. At least a comment is in order?

Pity to add the call overhead to schedule just for this case. BTW.
__schedule shouldn't need to be asmlinkage?

>  		spin_lock_mutex(&lock->wait_lock, flags);
>  	}
>  
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



(Log in to post comments)

Copyright © 2009, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds