From patchwork Mon Sep 28 18:38:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 34386 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.176.167]) by ozlabs.org (Postfix) with ESMTP id 422A5B7BFF for ; Tue, 29 Sep 2009 04:39:15 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752720AbZI1Si6 (ORCPT ); Mon, 28 Sep 2009 14:38:58 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752194AbZI1Si5 (ORCPT ); Mon, 28 Sep 2009 14:38:57 -0400 Received: from mail.vyatta.com ([76.74.103.46]:35928 "EHLO mail.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751837AbZI1Si5 (ORCPT ); Mon, 28 Sep 2009 14:38:57 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.vyatta.com (Postfix) with ESMTP id 36F5A4F416B; Mon, 28 Sep 2009 11:39:01 -0700 (PDT) X-Virus-Scanned: amavisd-new at tahiti.vyatta.com Received: from mail.vyatta.com ([127.0.0.1]) by localhost (mail.vyatta.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pODu3QpVSgIO; Mon, 28 Sep 2009 11:38:56 -0700 (PDT) Received: from nehalam (pool-71-117-243-208.ptldor.fios.verizon.net [71.117.243.208]) by mail.vyatta.com (Postfix) with ESMTP id 68DBD4F403C; Mon, 28 Sep 2009 11:38:56 -0700 (PDT) Date: Mon, 28 Sep 2009 11:38:55 -0700 From: Stephen Hemminger To: David Miller , netdev@vger.kernel.org Subject: [PATCH] get rid of read/write lock in gen_estimator Message-ID: <20090928113855.52eab44b@nehalam> Organization: Vyatta X-Mailer: Claws Mail 3.6.1 (GTK+ 2.16.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Don't need a read/write lock here sinc there already is a spin lock that is being acquired. Signed-off-by: Stephen Hemminger --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/net/core/gen_estimator.c 2009-09-24 16:27:01.239755070 -0700 +++ b/net/core/gen_estimator.c 2009-09-24 16:41:09.290751273 -0700 @@ -101,9 +101,6 @@ struct gen_estimator_head static struct gen_estimator_head elist[EST_MAX_INTERVAL+1]; -/* Protects against NULL dereference */ -static DEFINE_RWLOCK(est_lock); - /* Protects against soft lockup during large deletion */ static struct rb_root est_root = RB_ROOT; @@ -118,9 +115,8 @@ static void est_timer(unsigned long arg) u64 brate; u32 npackets; u32 rate; - + spin_lock(e->stats_lock); - read_lock(&est_lock); if (e->bstats == NULL) goto skip; @@ -136,7 +132,6 @@ static void est_timer(unsigned long arg) e->avpps += (rate >> e->ewma_log) - (e->avpps >> e->ewma_log); e->rate_est->pps = (e->avpps+0x1FF)>>10; skip: - read_unlock(&est_lock); spin_unlock(e->stats_lock); } @@ -270,9 +265,9 @@ void gen_kill_estimator(struct gnet_stat while ((e = gen_find_node(bstats, rate_est))) { rb_erase(&e->node, &est_root); - write_lock_bh(&est_lock); + spin_lock(e->stats_lock); e->bstats = NULL; - write_unlock_bh(&est_lock); + spin_unlock(e->stats_lock); list_del_rcu(&e->list); call_rcu(&e->e_rcu, __gen_kill_estimator);