diff options
author | Miaohe Lin <linmiaohe@huawei.com> | 2020-10-16 05:11:28 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-10-16 20:11:20 +0200 |
commit | 1d339638a954edce06ffcaa15d883d322e9e8291 (patch) | |
tree | f97127ed5e09d696a15951631f8752eaabee7cf2 | |
parent | lib/scatterlist.c: avoid a double memset (diff) | |
download | linux-1d339638a954edce06ffcaa15d883d322e9e8291.tar.xz linux-1d339638a954edce06ffcaa15d883d322e9e8291.zip |
lib/percpu_counter.c: use helper macro abs()
Use helper macro abs() to simplify the "x >= t || x <= -t" cmp.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Link: https://lkml.kernel.org/r/20200927122746.5964-1-linmiaohe@huawei.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | lib/percpu_counter.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c index f61689a96e85..00f666d94486 100644 --- a/lib/percpu_counter.c +++ b/lib/percpu_counter.c @@ -85,7 +85,7 @@ void percpu_counter_add_batch(struct percpu_counter *fbc, s64 amount, s32 batch) preempt_disable(); count = __this_cpu_read(*fbc->counters) + amount; - if (count >= batch || count <= -batch) { + if (abs(count) >= batch) { unsigned long flags; raw_spin_lock_irqsave(&fbc->lock, flags); fbc->count += count; |