From patchwork Wed Mar 12 15:31:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Maloy X-Patchwork-Id: 329494 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id BC7812C00B5 for ; Thu, 13 Mar 2014 02:31:29 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752285AbaCLPbX (ORCPT ); Wed, 12 Mar 2014 11:31:23 -0400 Received: from smtp104.biz.mail.ne1.yahoo.com ([98.138.207.11]:33815 "HELO smtp104.biz.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754899AbaCLPbV (ORCPT ); Wed, 12 Mar 2014 11:31:21 -0400 Received: (qmail 75468 invoked from network); 12 Mar 2014 15:31:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1394638280; bh=crCMoBarkpILWra6miwqfbmvUeWstbKZg6ybZ1YAk/M=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:X-Rocket-Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=bXTz2mJPw/ybJFe8YP2bJT6hkKgJQAZzHwsqpk6thLxi03nMrF0zHMVhQyWVC1Z2V6veC+rkeyefwjYfYJQtkDaViDxFbtvhACqYWBute/cOrq82gvCZE5sBKDeNrD2xwwqk/yANzG521veE5OcM4emV+HsereByV84Y86otNdA= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: r_WAfxEVM1lbIfN631vCzhIIOXlP3u55omNilK1x9BnALmW AUCD7SYEP_QEE4aow4EslcTh_GgqThg8jylbycWIAvl04S0sulLHc_UEBuok PtXkNwrYBE5Toe6ZEzvbs053vATrsYK31IdxIufaBfPTpUxuBLT.kHxwFAVM KyHVM0DvqT29ncjEd7I2MBpSwSCKsw9Ty4IWYMS25C2cFz2Yo8v_z.i1T7hK EOzOocdFsjddyjtVmqLhXyyeqRqDQD5GK7N3Z2gRDDJ9byu4HY9PV9qFNkx8 df7dBFT8mzjNP0Bj4SOLL5gQOBQ8LAFjBjxW0VcC8w07c.3PfRP0Ld8qFkg2 qByjNP9IS0UTb0RW4YfpGAyhTumSeRQJP796k3oPpcqGlLAHmx_PItlidfK7 P8F1ggqvMbtvasnulxcrSaRsNKKBFSEX20G0pjk1EvaBBzRmsGMfF2edbVv9 RtJPMAhh3lV_smupcuNgnkWx5rKbVd3N89_nurtO9tk_JptUxrPhrRvpSOBj TXRwsQ5tkDfQlFpZxeIIHtAhLAf4dY3mRga9gGNPZT4Xq90i1wWpmU1AZfw- - X-Yahoo-SMTP: gPXIZm2swBAFQJ_Vx0CebjUfUdhJ X-Rocket-Received: from goethe.lan (jon.maloy@129.192.185.163 with plain [98.138.105.25]) by smtp104.biz.mail.ne1.yahoo.com with SMTP; 12 Mar 2014 08:31:20 -0700 PDT From: Jon Maloy To: davem@davemloft.net Cc: netdev@vger.kernel.org, Paul Gortmaker , erik.hugne@ericsson.com, ying.xue@windriver.com, maloy@donjonn.com, tipc-discussion@lists.sourceforge.net, Jon Maloy Subject: [PATCH net-next 1/7] tipc: replace reference table rwlock with spinlock Date: Wed, 12 Mar 2014 11:31:07 -0400 Message-Id: <1394638273-6127-2-git-send-email-jon.maloy@ericsson.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1394638273-6127-1-git-send-email-jon.maloy@ericsson.com> References: <1394638273-6127-1-git-send-email-jon.maloy@ericsson.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The lock for protecting the reference table is declared as an RWLOCK, although it is only used in write mode, never in read mode. We redefine it to become a spinlock. Signed-off-by: Jon Maloy Reviewed-by: Ying Xue Reviewed-by: Erik Hugne --- net/tipc/ref.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/tipc/ref.c b/net/tipc/ref.c index de3d593..67176b5 100644 --- a/net/tipc/ref.c +++ b/net/tipc/ref.c @@ -89,7 +89,7 @@ struct ref_table { static struct ref_table tipc_ref_table; -static DEFINE_RWLOCK(ref_table_lock); +static DEFINE_SPINLOCK(ref_table_lock); /** * tipc_ref_table_init - create reference table for objects @@ -159,7 +159,7 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock) } /* take a free entry, if available; otherwise initialize a new entry */ - write_lock_bh(&ref_table_lock); + spin_lock_bh(&ref_table_lock); if (tipc_ref_table.first_free) { index = tipc_ref_table.first_free; entry = &(tipc_ref_table.entries[index]); @@ -175,7 +175,7 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock) } else { ref = 0; } - write_unlock_bh(&ref_table_lock); + spin_unlock_bh(&ref_table_lock); /* * Grab the lock so no one else can modify this entry @@ -216,7 +216,7 @@ void tipc_ref_discard(u32 ref) index = ref & index_mask; entry = &(tipc_ref_table.entries[index]); - write_lock_bh(&ref_table_lock); + spin_lock_bh(&ref_table_lock); if (!entry->object) { pr_err("Attempt to discard ref. to non-existent obj\n"); @@ -242,7 +242,7 @@ void tipc_ref_discard(u32 ref) tipc_ref_table.last_free = index; exit: - write_unlock_bh(&ref_table_lock); + spin_unlock_bh(&ref_table_lock); } /**