Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Shaohua Li and committed by
Linus Torvalds
c84598bb 3c8f370d

+5 -1
+5 -1
include/linux/percpu_counter.h
··· 75 75 barrier(); /* Prevent reloads of fbc->count */ 76 76 if (ret >= 0) 77 77 return ret; 78 - return 1; 78 + return 0; 79 79 } 80 80 81 81 static inline int percpu_counter_initialized(struct percpu_counter *fbc) ··· 133 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 + */ 136 140 static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc) 137 141 { 138 142 return fbc->count;