提交 c84598bb 编写于 作者: S Shaohua Li 提交者: Linus Torvalds

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: NShaohua Li <shaohua.li@intel.com>
Acked-by: NEric Dumazet <eric.dumazet@gmail.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 3c8f370d
......@@ -75,7 +75,7 @@ static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
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)
......@@ -133,6 +133,10 @@ static inline s64 percpu_counter_read(struct percpu_counter *fbc)
return fbc->count;
}
/*
* percpu_counter is intended to track positive numbers. In the UP case the
* number should never be negative.
*/
static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
{
return fbc->count;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册