Re: [PATCH, RFC] percpu_counters: make fbc->count read atomic on32 bit architecture

From: Peter Zijlstra
Date: Tue Oct 07 2008 - 13:22:57 EST


On Tue, 2008-10-07 at 18:09 +0100, richard kennedy wrote:
> Peter Zijlstra wrote:
> .....
> > +static inline int atomic64_dec_and_test(atomic64_t *v)
> > +{
> > + int ret;
> > +
> > + write_seqlock(&v->slock);
> > + v->counter--;
> > + ret = !v->counter;
> > + write_sequnlock(&v->slock);
> > +
> > + return ret;
> > +}
> > +
> > +static inline int atomic64_add_and_test(atomic64_t *v)
> > +{
> > + int ret;
> > +
> > + write_seqlock(&v->slock);
> > + v->counter++;
> > + ret = !v->counter;
> > + write_sequnlock(&v->slock);
> > +
> > + return ret;
> > +}
> would it be more logical to call this atomic64_inc_and_test to match the
> above dec_and_test ?

Yeah, I know of at least 2 other bugs in here, but I wanted some real
early feedback :-)

--
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/