]> git.baikalelectronics.ru Git - kernel.git/commit
tmpfs: add accurate compare function to percpu_counter library
authorTim Chen <tim.c.chen@linux.intel.com>
Tue, 10 Aug 2010 00:19:04 +0000 (17:19 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 10 Aug 2010 03:44:58 +0000 (20:44 -0700)
commite7d942b629f6c41bf535e7c5cdff787807a9edac
tree0d3a0387b42eb0a830fa5ba896a205b2a3807b8b
parent3a0eb2da6ea487b39f99ac22b333a49dd6933ede
tmpfs: add accurate compare function to percpu_counter library

Add percpu_counter_compare that allows for a quick but accurate comparison
of percpu_counter with a given value.

A rough count is provided by the count field in percpu_counter structure,
without accounting for the other values stored in individual cpu counters.

The actual count is a sum of count and the cpu counters.  However, count
field is never different from the actual value by a factor of
batch*num_online_cpu.  We do not need to get actual count for comparison
if count is different from the given value by this factor and allows for
quick comparison without summing up all the per cpu counters.

Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/percpu_counter.h
lib/percpu_counter.c