On Mon, Apr 02, 2007 at 04:33:54PM +0200, Eric Dumazet wrote:
> On Mon, 2 Apr 2007 14:47:59 +0200
> Oliver Neukum <[email protected]> wrote:
>
> > Hi,
> >
> > some atomic operations are only atomic, not ordered. Thus a CPU is allowed
> > to reorder memory references to an object to before the reference is
> > obtained. This fixes it.
> >
> > Regards
> > Oliver
> > Signed-off-by: Oliver Neukum <[email protected]>
> > ------
> >
> > --- a/lib/kref.c 2007-04-02 14:40:40.000000000 +0200
> > +++ b/lib/kref.c 2007-04-02 14:40:50.000000000 +0200
> > @@ -21,6 +21,7 @@
> > void kref_init(struct kref *kref)
> > {
> > atomic_set(&kref->refcount,1);
> > + smp_mb();
> > }
>
> I dont understand why smp_mb() is needed here, and not in
> spinlock_init() for example.
I think, after reading the Documentation/memory-barriers.txt and
Documentation/atomic_ops.txt documentation, that spin_lock_init() also
needs this kind of memory barrier.
>From what I can tell (Oliver, please correct me if I'm wrong, you know
this much better than I do), the issue is that atomic init has no memory
barrier, and you need to handle that.
thanks,
greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]