lkml.org 
[lkml]   [2015]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC][PATCH 4/5] percpu: Fix abs() usage in percpu_counter_compare()
Date
s64 values should not be used with abs(), as is one
in __percpu_counter_compare(), since it may cap the
result to 32-bits.

This patch modifies __percpu_counter_compare() to
use abs64() instead.

Cc: Dave Chinner <dchinner@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
lib/percpu_counter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c
index f051d69..3d1aba9 100644
--- a/lib/percpu_counter.c
+++ b/lib/percpu_counter.c
@@ -203,7 +203,7 @@ int __percpu_counter_compare(struct percpu_counter *fbc, s64 rhs, s32 batch)

count = percpu_counter_read(fbc);
/* Check to see if rough count will be sufficient for comparison */
- if (abs(count - rhs) > (batch * num_online_cpus())) {
+ if (abs64(count - rhs) > (batch * num_online_cpus())) {
if (count > rhs)
return 1;
else
--
1.9.1


\
 
 \ /
  Last update: 2015-09-15 03:21    [W:0.158 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site