From patchwork Tue Apr 5 00:03:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 89738 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 EE122B6F73 for ; Tue, 5 Apr 2011 10:09:57 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751141Ab1DEAJw (ORCPT ); Mon, 4 Apr 2011 20:09:52 -0400 Received: from suva.vyatta.com ([76.74.103.44]:42823 "EHLO suva.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750846Ab1DEAJu (ORCPT ); Mon, 4 Apr 2011 20:09:50 -0400 Received: from suva.vyatta.com (suva [127.0.0.1]) by suva.vyatta.com (8.13.7/8.13.7) with ESMTP id p3508m8m013222; Mon, 4 Apr 2011 17:08:48 -0700 Received: (from shemminger@localhost) by suva.vyatta.com (8.13.7/8.13.7/Submit) id p3508mHJ013221; Mon, 4 Apr 2011 17:08:48 -0700 Message-Id: <20110405000537.187138133@vyatta.com> User-Agent: quilt/0.48-1 Date: Mon, 04 Apr 2011 17:03:29 -0700 From: Stephen Hemminger To: "David S. Miller" Cc: netdev@vger.kernel.org Subject: [PATCH 3/7] bridge: split rcu and no-rcu cases of fdb lookup References: <20110405000326.714524584@vyatta.com> Content-Disposition: inline; filename=br-fdb-norcu.patch Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In some cases, look up of forward database entry is done with RCU; and for others no RCU is needed because of locking. Split the two cases into two differnt loops (and take off inline). 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/bridge/br_fdb.c 2011-03-21 10:36:51.109460181 -0700 +++ b/net/bridge/br_fdb.c 2011-03-21 10:37:11.872443564 -0700 @@ -305,8 +305,21 @@ int br_fdb_fillbuf(struct net_bridge *br return num; } -static inline struct net_bridge_fdb_entry *fdb_find(struct hlist_head *head, - const unsigned char *addr) +static struct net_bridge_fdb_entry *fdb_find(struct hlist_head *head, + const unsigned char *addr) +{ + struct hlist_node *h; + struct net_bridge_fdb_entry *fdb; + + hlist_for_each_entry(fdb, h, head, hlist) { + if (!compare_ether_addr(fdb->addr.addr, addr)) + return fdb; + } + return NULL; +} + +static struct net_bridge_fdb_entry *fdb_find_rcu(struct hlist_head *head, + const unsigned char *addr) { struct hlist_node *h; struct net_bridge_fdb_entry *fdb; @@ -393,7 +406,7 @@ void br_fdb_update(struct net_bridge *br source->state == BR_STATE_FORWARDING)) return; - fdb = fdb_find(head, addr); + fdb = fdb_find_rcu(head, addr); if (likely(fdb)) { /* attempt to update an entry for a local interface */ if (unlikely(fdb->is_local)) {