Re: 2.6.9-rc1-mm4 sparc reiser4 build broken - undefined atomic_s ub_and_test

From: Hugh Dickins
Date: Mon Sep 13 2004 - 15:25:40 EST


On Mon, 13 Sep 2004, Tonnerre wrote:
> On Mon, Sep 13, 2004 at 06:03:28PM +0200, Roman Zippel wrote:
> > +#define atomic_add_and_test(i,v) (atomic_add_return((i), (v)) == 0)
> > +#define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0)
>
> This is no longer atomic, is it? I mean, there's no guarantee that the
> atomic_add_return and the comparison are executed without
> interruption, is there?

It's true that the atomic_add_return and the comparison are not executed
atomically, but they don't need to be: a value is equal to 0, or not,
however long ago that value was computed, no matter what happened since.

The important thing is that the value is the atomic result of the atomic
operation: which may not be the case when you use atomic_add followed by
atomic_read, but is what's guaranteed by atomic_add_return.

Hugh

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/