From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754507AbbERR4n (ORCPT ); Mon, 18 May 2015 13:56:43 -0400 Received: from www.osadl.org ([62.245.132.105]:35715 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753427AbbERR4k (ORCPT ); Mon, 18 May 2015 13:56:40 -0400 From: Nicholas Mc Guire To: Peter Zijlstra Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] locking: type cleanup when accessing fast_read_ctr Date: Mon, 18 May 2015 19:48:02 +0200 Message-Id: <1431971282-21412-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 1.7.10.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org static code checking with coccinelle was unhappy with: ./kernel/locking/percpu-rwsem.c:113 WARNING: return of wrong type int != unsigned int current state: include/linux/percpu-rwsem.h: struct percpu_rw_semaphore { unsigned int __percpu *fast_read_ctr; ... atomic_t slow_read_ctr; allocated as int: int __percpu_init_rwsem(struct percpu_rw_semaphore *brw, const char *name, struct lock_class_key *rwsem_key) { brw->fast_read_ctr = alloc_percpu(int); used compliant with type int in: static bool update_fast_ctr(struct percpu_rw_semaphore *brw, unsigned int val) usage (2): update_fast_ctr(brw, +1) update_fast_ctr(brw, -1) so val should be int here not unsigned int static int clear_fast_ctr(struct percpu_rw_semaphore *brw) usage (1): atomic_add(clear_fast_ctr(brw), &brw->slow_read_ctr); slow_read_ctr is atomic_t which is int so it would be consistent here to have fast_read_ctr being changed to int as well. This patch changes: fast_read_ctr to int clear_fast_ctr():sum to int update_fast_ctr():val to int to make usage of fast_read_ctr consistent with respect to type. ( Patch was build tested with x86_64_defconfig + CONFIG_UPROBE_EVENT (implies CONFIG_PERCPU_RWSEM=y)) Signed-off-by: Nicholas Mc Guire --- include/linux/percpu-rwsem.h | 2 +- kernel/locking/percpu-rwsem.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h index 3e88c9a..ba37dbe 100644 --- a/include/linux/percpu-rwsem.h +++ b/include/linux/percpu-rwsem.h @@ -8,7 +8,7 @@ #include struct percpu_rw_semaphore { - unsigned int __percpu *fast_read_ctr; + int __percpu *fast_read_ctr; atomic_t write_ctr; struct rw_semaphore rw_sem; atomic_t slow_read_ctr; diff --git a/kernel/locking/percpu-rwsem.c b/kernel/locking/percpu-rwsem.c index 652a8ee..002837d 100644 --- a/kernel/locking/percpu-rwsem.c +++ b/kernel/locking/percpu-rwsem.c @@ -52,7 +52,7 @@ void percpu_free_rwsem(struct percpu_rw_semaphore *brw) * reader inside the critical section. See the comments in down_write and * up_write below. */ -static bool update_fast_ctr(struct percpu_rw_semaphore *brw, unsigned int val) +static bool update_fast_ctr(struct percpu_rw_semaphore *brw, int val) { bool success = false; @@ -102,7 +102,7 @@ void percpu_up_read(struct percpu_rw_semaphore *brw) static int clear_fast_ctr(struct percpu_rw_semaphore *brw) { - unsigned int sum = 0; + int sum = 0; int cpu; for_each_possible_cpu(cpu) { -- 1.7.10.4