Skip to contentSkip to conversation

spin_trylock_bh

RFC PATCH In review Arnaldo Carvalho de Melo 2 participants 3 messages Sep 15, 2001 – Sep 21, 2001 Networking

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 spin_trylock_bh

Hi,

Please see if this is acceptable, I noticed this while working on
the locks for NetBEUI 8) Patch is against 2.4.9, but it should apply to latest prepatch. It was being used in the ppp code for quite some time.

- Arnaldo

Index: include/linux/spinlock.h
===================================================================
RCS file: /home/cvs/kernel-acme/include/linux/spinlock.h,v retrieving revision 1.1.1.2

linux/spinlock.h +4 -0
diff -u -r1.1.1.2 spinlock.h
@@ -30,6 +30,10 @@
 #define write_unlock_irqrestore(lock, flags)	do { write_unlock(lock); local_irq_restore(flags); } while (0)
 #define write_unlock_irq(lock)			do { write_unlock(lock); local_irq_enable();       } while (0)
 #define write_unlock_bh(lock)			do { write_unlock(lock); local_bh_enable();        } while (0)
+#define spin_trylock_bh(lock)			({ int __r; local_bh_disable();\
+						__r = spin_trylock(lock);      \
+						if (!__r) local_bh_enable();   \
+						__r; })
 
 #ifdef CONFIG_SMP
 #include <asm/spinlock.h>

Index: drivers/net/ppp_synctty.c
===================================================================
RCS file: /home/cvs/kernel-acme/drivers/net/ppp_synctty.c,v retrieving revision 1.1.1.2

net/ppp_synctty.c +0 -7
diff -u -r1.1.1.2 ppp_synctty.c
@@ -44,13 +44,6 @@
 #include <linux/init.h>
 #include <asm/uaccess.h>
 
-#ifndef spin_trylock_bh
-#define spin_trylock_bh(lock)	({ int __r; local_bh_disable();	\
-				   __r = spin_trylock(lock);	\
-				   if (!__r) local_bh_enable();	\
-				   __r; })
-#endif
-
 #define PPP_VERSION	"2.4.1"
 
 /* Structure for storing local state. */

Index: net/ipv6/ip6_fib.c
===================================================================
RCS file: /home/cvs/kernel-acme/net/ipv6/ip6_fib.c,v retrieving revision 1.1.1.2

ipv6/ip6_fib.c +1 -3
diff -u -r1.1.1.2 ip6_fib.c
@@ -1192,10 +1192,8 @@
 		spin_lock_bh(&fib6_gc_lock);
 		gc_args.timeout = (int)dummy;
 	} else {
-		local_bh_disable();
-		if (!spin_trylock(&fib6_gc_lock)) {
+		if (!spin_trylock_bh(&fib6_gc_lock)) {
 			mod_timer(&ip6_fib_timer, jiffies + HZ);
-			local_bh_enable();
 			return;
 		}
 		gc_args.timeout = ip6_rt_gc_interval;
#1 lore raw

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Sat, 15 Sep 2001 17:26:59 -0300

Please see if this is acceptable, I noticed this while working on
the locks for NetBEUI 8) Patch is against 2.4.9, but it should apply to latest prepatch. It was being used in the ppp code for quite some time.

This patch looks fine to me...

Later,
David S. Miller
[email protected]

#2 lore raw
In reply to Arnaldo Carvalho de Melo

Em Thu, Sep 20, 2001 at 04:59:53PM -0700, David S. Miller escreveu:

Quoted 8 lines

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Sat, 15 Sep 2001 17:26:59 -0300

Please see if this is acceptable, I noticed this while working on
the locks for NetBEUI 8) Patch is against 2.4.9, but it should apply to latest prepatch. It was being used in the ppp code for quite some time.

This patch looks fine to me...

It is already in 2.4.9-ac12, hope it'll be merged with Linus soon.

- Arnaldo