aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShaohua Li <shaohua.li@intel.com>2011-05-24 20:13:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-25 11:39:54 -0400
commitc84598bbfa756b7d042da31aa4e198ae866a6c7d (patch)
tree9287d1dcfd313193b944f3dc49a6519a40a7ee4f
parent3c8f370ded3483b27f1218ff0051fcf0c7a2facd (diff)
percpu_counter: change return value and add comments
The percpu_counter_*_positive() API in UP case doesn't check if return value is positive. Add comments to explain why we don't. Also if count < 0, returns 0 instead of 1 for *read_positive(). [akpm@linux-foundation.org: tweak comment] Signed-off-by: Shaohua Li <shaohua.li@intel.com> Acked-by: Eric Dumazet <eric.dumazet@gmail.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/percpu_counter.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h
index 46f6ba56fa91..5edc9014263a 100644
--- a/include/linux/percpu_counter.h
+++ b/include/linux/percpu_counter.h
@@ -75,7 +75,7 @@ static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
75 barrier(); /* Prevent reloads of fbc->count */ 75 barrier(); /* Prevent reloads of fbc->count */
76 if (ret >= 0) 76 if (ret >= 0)
77 return ret; 77 return ret;
78 return 1; 78 return 0;
79} 79}
80 80
81static inline int percpu_counter_initialized(struct percpu_counter *fbc) 81static inline int percpu_counter_initialized(struct percpu_counter *fbc)
@@ -133,6 +133,10 @@ static inline s64 percpu_counter_read(struct percpu_counter *fbc)
133 return fbc->count; 133 return fbc->count;
134} 134}
135 135
136/*
137 * percpu_counter is intended to track positive numbers. In the UP case the
138 * number should never be negative.
139 */
136static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc) 140static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
137{ 141{
138 return fbc->count; 142 return fbc->count;