RE: [Patch] Token Ring Deadlock on SMP

From: Phillips, Mike (PHILLIM@amtrak.com)
Date: Wed Mar 22 2000 - 08:25:25 EST


Linus,

>Mike, this part looks pretty wrong:
> + if (!spin_is_locked(&rif_lock) ) {
> + spin_lock_irqsave(&rif_lock,flags);

Yep, I cringed when I first put this in and then had a major brain fart that
made me think it was still needed. I ran some tests and this never returned
is_locked which is what should be expected from the other locks in the code.
So I've taken the offending test out and the code is still working fine.
(Although I'm still half convinced that the Uncertainty Principal comes into
play when dealing with smp, when only one person it looking at the code all
outcomes are possible, it is only when you actually send the patch off for
inclusion that the wave function collapses and the code actually works
according to the ANSI/Newtonian definition of C).

Attached is the corrected version.

        Mike

--- linux-2.3.99pre3-6.orig/net/802/tr.c Fri Nov 19 14:33:29 1999
+++ linux/net/802/tr.c Wed Mar 22 08:10:12 2000
@@ -237,8 +237,9 @@
         rif_cache entry;
         unsigned char *olddata;
         unsigned char mcast_func_addr[] = {0xC0,0x00,0x00,0x04,0x00,0x00};
+ unsigned long flags ;
         
- spin_lock_bh(&rif_lock);
+ spin_lock_irqsave(&rif_lock,flags);
 
         /*
          * Broadcasts are single route as stated in RFC 1042
@@ -308,7 +309,7 @@
         else
                 slack = 18 - ((ntohs(trh->rcf) & TR_RCF_LEN_MASK)>>8);
         olddata = skb->data;
- spin_unlock_bh(&rif_lock);
+ spin_unlock_irqrestore(&rif_lock,flags);
 
         skb_pull(skb, slack);
         memmove(skb->data, olddata, sizeof(struct trh_hdr) - slack);
@@ -418,8 +419,9 @@
 {
         int i;
         unsigned long now=jiffies;
+ unsigned long flags ;
 
- spin_lock(&rif_lock);
+ spin_lock_irqsave(&rif_lock,flags);
         
         for(i=0; i < RIF_TABLE_SIZE;i++)
         {
@@ -439,7 +441,7 @@
                 }
         }
         
- spin_unlock(&rif_lock);
+ spin_unlock_irqrestore(&rif_lock,flags);
 
         /*
          * Reset the timer



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:36 EST