On Sun, 17 Aug 2008, Mathieu Desnoyers wrote:So first off, you should call this "trylock", since it doesn't necessarily get the lock at all. It has nothing to do with fast. Secondly: This is actually potentially very slow. Why? If the lock is uncontended, but is not in the current CPU's caches, the read -> rmw operation generates multiple cache coherency protocol events. First it gets the line in shared mode (for the read), and then later it turns it into exclusive mode. So if it's likely that the value is zero (or even if it's just the only case we really care about), then you really should do the atomic_long_cmpxchg(&rwlock->value, 0, newvalue); thing as the _first_ access to the lock. Yeah, yeah, that means that you need to do the local_bh_disable etc first too, and undo it if it fails, but the failure path should be the unusual one. Linus --
| Greg Kroah-Hartman | [PATCH 004/196] Chinese: add translation of SubmittingPatches |
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Willy Tarreau | Re: Linux 2.6.21 |
| Jan Kundrát | kswapd high CPU usage with no swap |
git: | |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| David Miller | [GIT]: Networking |
| David Miller | Re: [PATCH] tcp: splice as many packets as possible at once |
