From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752429AbbIOBGG (ORCPT ); Mon, 14 Sep 2015 21:06:06 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:36447 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751944AbbIOBFg (ORCPT ); Mon, 14 Sep 2015 21:05:36 -0400 From: John Stultz To: LKML Cc: John Stultz , Dave Chinner , Tejun Heo , Ingo Molnar Subject: [RFC][PATCH 4/5] percpu: Fix abs() usage in percpu_counter_compare() Date: Mon, 14 Sep 2015 18:05:23 -0700 Message-Id: <1442279124-7309-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442279124-7309-1-git-send-email-john.stultz@linaro.org> References: <1442279124-7309-1-git-send-email-john.stultz@linaro.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Tejun Heo Cc: Ingo Molnar Signed-off-by: John Stultz --- 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