netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
To: Stephen Hemminger <shemminger@osdl.org>
Cc: "David S. Miller" <davem@redhat.com>,
	Jay Schulist <jschlst@samba.org>,
	netdev@oss.sgi.com
Subject: Re: [PATCH] 2.5.68 - RCU for SNAP
Date: Wed, 30 Apr 2003 04:22:36 -0300	[thread overview]
Message-ID: <20030430072236.GE31429@conectiva.com.br> (raw)
In-Reply-To: <20030429154856.39c75139.shemminger@osdl.org>

Hi,

	Looks fine, applied, David, could you please pull from:

bk://kernel.bkbits.net/acme/net-2.5

	Thanks Stephen.

- Arnaldo


You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.

===================================================================


ChangeSet@1.1170, 2003-04-30 04:17:25-03:00, shemminger@osdl.org
  Replace br_lock() in snap with Read Copy Update.
  
  Straightforward since SNAP uses list macros already.
  
  Tested by bringing up/down Appletalk on SMP system and making sure packets
  get through.
  
  This is the last subsystem that depends on br_lock before IPV4,IPV6
  can be converted.


 psnap.c |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)


diff -Nru a/net/802/psnap.c b/net/802/psnap.c
--- a/net/802/psnap.c	Wed Apr 30 04:20:09 2003
+++ b/net/802/psnap.c	Wed Apr 30 04:20:09 2003
@@ -21,9 +21,9 @@
 #include <linux/mm.h>
 #include <linux/in.h>
 #include <linux/init.h>
-#include <linux/brlock.h>
 
-LIST_HEAD(snap_list);
+static LIST_HEAD(snap_list);
+static spinlock_t snap_lock = SPIN_LOCK_UNLOCKED;
 static struct llc_sap *snap_sap;
 
 /*
@@ -34,17 +34,13 @@
 	struct list_head *entry;
 	struct datalink_proto *proto = NULL, *p;
 
-	if (list_empty(&snap_list))
-		goto out;
-
-	list_for_each(entry, &snap_list) {
+	list_for_each_rcu(entry, &snap_list) {
 		p = list_entry(entry, struct datalink_proto, node);
 		if (!memcmp(p->type, desc, 5)) {
 			proto = p;
 			break;
 		}
 	}
-out:
 	return proto;
 }
 
@@ -55,11 +51,13 @@
 		    struct packet_type *pt)
 {
 	int rc = 1;
-	struct datalink_proto *proto = find_snap_client(skb->h.raw);
+	struct datalink_proto *proto;
 	static struct packet_type snap_packet_type = {
 		.type = __constant_htons(ETH_P_SNAP),
 	};
 
+	rcu_read_lock();
+	proto = find_snap_client(skb->h.raw);
 	if (proto) {
 		/* Pass the frame on. */
 		skb->h.raw  += 5;
@@ -71,6 +69,7 @@
 		rc = 1;
 	}
 
+	rcu_read_unlock();
 	return rc;
 }
 
@@ -124,7 +123,7 @@
 {
 	struct datalink_proto *proto = NULL;
 
-	br_write_lock_bh(BR_NETPROTO_LOCK);
+	spin_lock_bh(&snap_lock);
 
 	if (find_snap_client(desc))
 		goto out;
@@ -135,10 +134,12 @@
 		proto->rcvfunc		= rcvfunc;
 		proto->header_length	= 5 + 3; /* snap + 802.2 */
 		proto->request		= snap_request;
-		list_add(&proto->node, &snap_list);
+		list_add_rcu(&proto->node, &snap_list);
 	}
 out:
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	spin_unlock_bh(&snap_lock);
+
+	synchronize_net();
 	return proto;
 }
 
@@ -147,12 +148,13 @@
  */
 void unregister_snap_client(struct datalink_proto *proto)
 {
-	br_write_lock_bh(BR_NETPROTO_LOCK);
+	spin_lock_bh(&snap_lock);
+	list_del_rcu(&proto->node);
+	spin_unlock_bh(&snap_lock);
 
-	list_del(&proto->node);
-	kfree(proto);
+	synchronize_net();
 
-	br_write_unlock_bh(BR_NETPROTO_LOCK);
+	kfree(proto);
 }
 
 MODULE_LICENSE("GPL");

===================================================================


This BitKeeper patch contains the following changesets:
1.1170
## Wrapped with gzip_uu ##


M'XL( "EYKSX  ^U6;6_;-A#^+/Z* PH$[E;+I%XLVX&#I''0&LE2(V[V:8! 
M4W0D6*8$DH[AS3]^1\EQUS1+L6+ OBPF[HS<\7F>X]T!?@/W1NJ1Q\5:DC?P
ML3)VY(E*26&+1^Z+:NTO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UE)V& 8/''Q0BEV)E-NMQ+))@&,=+\B?0XUJMO0@     
 

  reply	other threads:[~2003-04-30  7:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-29 22:48 [PATCH] 2.5.68 - RCU for SNAP Stephen Hemminger
2003-04-30  7:22 ` Arnaldo Carvalho de Melo [this message]
2003-04-30  6:34   ` David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030430072236.GE31429@conectiva.com.br \
    --to=acme@conectiva.com.br \
    --cc=davem@redhat.com \
    --cc=jschlst@samba.org \
    --cc=netdev@oss.sgi.com \
    --cc=shemminger@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).