the percpu_counter_*_positive() API SMP and UP aren't consistent. Add comments
to explain it.
Also if count < 0, returns 0 instead of 1 for *read_positive().
Signed-off-by: Shaohua Li <[email protected]>
---
include/linux/percpu_counter.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Index: linux/include/linux/percpu_counter.h
===================================================================
--- linux.orig/include/linux/percpu_counter.h 2011-04-13 13:10:13.000000000 +0800
+++ linux/include/linux/percpu_counter.h 2011-04-13 13:21:21.000000000 +0800
@@ -75,7 +75,7 @@ static inline s64 percpu_counter_read_po
barrier(); /* Prevent reloads of fbc->count */
if (ret >= 0)
return ret;
- return 1;
+ return 0;
}
static inline int percpu_counter_initialized(struct percpu_counter *fbc)
@@ -135,6 +135,10 @@ static inline s64 percpu_counter_read(st
static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
{
+ /*
+ * percpu_counter is intended to track positive number. In UP case, the
+ * number should never be negative.
+ */
return fbc->count;
}
On Wed, Apr 13, 2011 at 03:57:16PM +0800, [email protected] wrote:
> the percpu_counter_*_positive() API SMP and UP aren't consistent. Add comments
> to explain it.
> Also if count < 0, returns 0 instead of 1 for *read_positive().
>
> Signed-off-by: Shaohua Li <[email protected]>
Patch looks technically okay to me but may I suggest...
* Revise patch description. It doesn't really match the patch
content.
* I would much prefer having docbook comments on top of
*read_positive() functions.
Thanks.
--
tejun