linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* adaptive mutexes, was Re: btrfs_tree_lock & trylock
       [not found]         ` <20080908080751.3d29fd61@extreme>
@ 2008-09-08 17:16           ` Christoph Hellwig
  0 siblings, 0 replies; only message in thread
From: Christoph Hellwig @ 2008-09-08 17:16 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Andi Kleen, Chris Mason, linux-btrfs, linux-kernel

On Mon, Sep 08, 2008 at 08:07:51AM -0700, Stephen Hemminger wrote:
> The problem is that they are a nuisance. It is impossible to choose
> the right trade off between spin an no-spin, also they optimize for
> a case that doesn't occur often enough to be justified.
> 
> People seem to repeatedly come up with adaptive mutex based on intuitive
> hunch, and never do much analysis before or afterwards.
> 
> You need some facts to come up with a useful model:
>   % of time lock is contended
>   average lock hold time
>   overhead of entry-exit for lock primitive (spin time)
>   overhead of the adaptive version either pure spin or pure mutex
> 
> Also, adaptive locks have even worse unfairness than spin locks under
> contention.

Well, the traditional wisdom in kernel land is that you want a spinlock
if the contention phases are short.  But we grow more an more places
where we might do sleep under the lock.  One optimization would be
to spin, but only if the mutex holder is not sleeping.  Or we make the
spinning a completely different API, mutex_lock_adaptive()


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-09-08 17:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20080908111059.GA8902@basil.nowhere.org>
     [not found] ` <1220881666.8537.3.camel@think.oraclecorp.com>
     [not found]   ` <20080908135414.GG26079@one.firstfloor.org>
     [not found]     ` <1220882551.8537.5.camel@think.oraclecorp.com>
     [not found]       ` <20080908142052.GK26079@one.firstfloor.org>
     [not found]         ` <20080908080751.3d29fd61@extreme>
2008-09-08 17:16           ` adaptive mutexes, was Re: btrfs_tree_lock & trylock Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).