Re: [PATCH] move xchg/cmpxchg to atomic.h
Daniel Phillips (phillips@innominate.de)
Tue, 02 Jan 2001 23:05:01 +0100
Roman Zippel wrote:
>
> On Tue, 2 Jan 2001, David S. Miller wrote:
>
> > We really can't. We _only_ have load-and-zero. And it has to be
> > 16-byte aligned. xchg() is just not something the CPU implements.
> >
> > Oh bugger... you do have real problems.
>
> For 2.5 we could move all the atomic functions from atomic.h, bitops.h,
> system.h and give them a common interface. We could also give them a new
> argument atomic_spinlock_t, which is a normal spinlock, but only used on
> architectures which need it, everyone else can "optimize" it away. I think
> one such lock per major subsystem should be enough, as the lock is only
> held for a very short time, so contentation should be no problem.
> Anyway, this had the huge advantage that we could use the complete 32/64
> bit of the atomic value, e.g. for pointer operations.
*Yes*, and I could write:
waiters = xchg(&bdflush_waiters.counter, 0);
instead of:
waiters = atomic_read(&bdflush_waiters);
atomic_sub(waiters, &bdflush_waiters);
in my daemon wakeup patch.
--
Daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/