lkml.org 
[lkml]   [2010]   [Jun]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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



\
 
 \ /
  Last update: 2010-06-15 15:09    [W:0.100 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site