Messages in this thread Patch in this message | | | Date | Wed, 13 Apr 2011 15:57:16 +0800 | From | shaohua.li@intel ... | Subject | [patch v2 1/4] percpu_counter: change return value and add comments |
| |
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 <shaohua.li@intel.com>
--- 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; }
| |