Re: [PATCH 1/4]percpu_counter: make API return consistent value

From: Tejun Heo
Date: Tue Apr 12 2011 - 23:08:52 EST


On Wed, Apr 13, 2011 at 09:24:15AM +0800, Shaohua Li wrote:
> > Ummm, on UP, the counters cannot be positive.
> s/positive/negative?


> > The _positive interface
> > is there to make it easier to cope with deviations introduced by
> > unsynchronized modifications by different CPUs. On UP, such
> > deviations don't happen at all so _positive interface is the same as
> > the counterpart without the postfix.
> I'm confused. the counter could be negative, we have *_dec, *_sub.

Yes it can technically but I was referring to the intent of the API.
The whole percpu counter is supposed to track a positive number. The
_positive interface is there just to cope with deviations caused by
distribution over multiple per-cpu counters, which can't happen on UP.
When the counter can actually be negative, the API doesn't make whole
lot of sense. I agree it's poorly documented.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at