Messages in this thread | | | Date | Tue, 15 Jun 2010 09:06:22 -0400 | From | Kyle McMartin <> | Subject | Re: [PATCH] Fix a race in pid generation that causes pids to be reused immediately. |
| |
On Tue, Jun 15, 2010 at 08:56:50AM -0400, tytso@mit.edu wrote: > > I think you're probably right, as long as one sticks with 4-byte > > scalars. The cmpxchg-is-now-generic change snuck in under the radar > > (mine, at least). > > Hmmm, what about unsigned longs? (Which might be 8 bytes on some > architectures....) >
Longs are fine, since Linux only supports LP64 (and would need major work to support anything else.)
The problem documented above is that on 32-bit, a 64-bit read is non-atomic, so even if you use a hashed spinlock to protect a u64 variable on 32-bit, reads will be non-atomic, and so must take the same lock in order to be safe. Hence, you need accessor functions.
This is what the generic atomic code does, perhaps we could add a new API that gives us hooks to do proper hashed spinlocks on crap architectures but falls back to simple assignment and real cmpxchg on real platforms.
--Kyle
| |