Re: rw_lock vs mutex

2012-02-02 Thread Matt Thomas

On Feb 2, 2012, at 5:38 PM, Paul Goyette wrote:

 While digging around looking into another problem, I noticed that the 
 piixpm(4) driver uses an rw_lock for its ic_acquire_bus/ic_release_bus 
 routines.  ic_acquire_bus() uses rw_enter(..., RW_WRITER) and there doesn't 
 appear to be any use anywhere of RW_READER for that lock.
 
 The man page for rw_lock implies that it is a superset of a mutex.  So I'm 
 wondering if it makes any sense to use the simpler mutex instead?

Switch to a mutex, it's much less overhead that a r/w lock

RE: rw_lock vs mutex

2012-02-02 Thread Paul_Koning
A rw_lock allows multiple readers, correct?  If there's a non-trivial 
probability of concurrent reads that would make a difference.  If not, then a 
mutex would be just as good especially if that is lower overhead.

paul

-Original Message-
From: tech-kern-ow...@netbsd.org [mailto:tech-kern-ow...@netbsd.org] On Behalf 
Of Matt Thomas
Sent: Thursday, February 02, 2012 8:53 PM
To: p...@whooppee.com
Cc: tech-kern@netbsd.org
Subject: Re: rw_lock vs mutex


On Feb 2, 2012, at 5:38 PM, Paul Goyette wrote:

 While digging around looking into another problem, I noticed that the 
 piixpm(4) driver uses an rw_lock for its ic_acquire_bus/ic_release_bus 
 routines.  ic_acquire_bus() uses rw_enter(..., RW_WRITER) and there doesn't 
 appear to be any use anywhere of RW_READER for that lock.
 
 The man page for rw_lock implies that it is a superset of a mutex.  So I'm 
 wondering if it makes any sense to use the simpler mutex instead?

Switch to a mutex, it's much less overhead that a r/w lock


RE: rw_lock vs mutex

2012-02-02 Thread Paul Goyette

On Thu, 2 Feb 2012, paul_kon...@dell.com wrote:

A rw_lock allows multiple readers, correct?  If there's a non-trivial 
probability of concurrent reads that would make a difference.  If not, 
then a mutex would be just as good especially if that is lower 
overhead.


The rwlock in question is contained with the driver's softc.  The only 
exported accessors are i2c_bus_acquire() (which grabs a RW_WRITER lock) 
and i2c_bus_release().


A mutex makes much more sense.


-
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:   |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com|
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |  | pgoyette at netbsd.org  |
-