Re: [PATCH 05/11] netpoll: dont need rx_flags

2007-11-19 Thread David Miller
From: Stephen Hemminger [EMAIL PROTECTED]
Date: Sat, 03 Nov 2007 11:43:19 -0700

 The rx_flags variable is redundant. Turning rx on/off is done
 via setting the rx_np pointer.
 
 Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]

Not all of these transformations are equivalent, and as a result
you're adding a bug.

 @@ -51,12 +50,11 @@ static inline int netpoll_rx(struct sk_b
   unsigned long flags;
   int ret = 0;
  
 - if (!npinfo || (!npinfo-rx_np  !npinfo-rx_flags))
 + if (!npinfo || !npinfo-rx_np)
   return 0;
  
   spin_lock_irqsave(npinfo-rx_lock, flags);
 - /* check rx_flags again with the lock held */
 - if (npinfo-rx_flags  __netpoll_rx(skb))
 + if (__netpoll_rx(skb))
   ret = 1;
   spin_unlock_irqrestore(npinfo-rx_lock, flags);

If you're using -rx_np == NULL as your new guard, you have
to duplicate that test inside of holding the lock.

-rx_np goes to NULL under the lock, but in the previous code if
the rx_flags is set we know that -rx_np is also NULL, that's
why it was OK to only recheck -rx_flags in the lock and not
-rx_np as well.

Therefore we have to replace the test on -rx_flags with -rx_np in
all spots to retain correct semantics.

I've made this correction to your patch and applied it to net-2.6.25

Thanks.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/11] netpoll: dont need rx_flags

2007-11-03 Thread Stephen Hemminger
The rx_flags variable is redundant. Turning rx on/off is done
via setting the rx_np pointer.

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]


--- a/include/linux/netpoll.h   2007-11-03 09:32:54.0 -0700
+++ b/include/linux/netpoll.h   2007-11-03 09:35:45.0 -0700
@@ -25,7 +25,6 @@ struct netpoll {
 
 struct netpoll_info {
atomic_t refcnt;
-   int rx_flags;
spinlock_t rx_lock;
struct netpoll *rx_np; /* netpoll that registered an rx_hook */
struct sk_buff_head arp_tx; /* list of arp requests to reply to */
@@ -51,12 +50,11 @@ static inline int netpoll_rx(struct sk_b
unsigned long flags;
int ret = 0;
 
-   if (!npinfo || (!npinfo-rx_np  !npinfo-rx_flags))
+   if (!npinfo || !npinfo-rx_np)
return 0;
 
spin_lock_irqsave(npinfo-rx_lock, flags);
-   /* check rx_flags again with the lock held */
-   if (npinfo-rx_flags  __netpoll_rx(skb))
+   if (__netpoll_rx(skb))
ret = 1;
spin_unlock_irqrestore(npinfo-rx_lock, flags);
 
--- a/net/core/netpoll.c2007-11-03 09:33:31.0 -0700
+++ b/net/core/netpoll.c2007-11-03 09:35:45.0 -0700
@@ -39,7 +39,6 @@ static struct sk_buff_head skb_pool;
 static atomic_t trapped;
 
 #define USEC_PER_POLL  50
-#define NETPOLL_RX_ENABLED  1
 
 #define MAX_SKB_SIZE \
(MAX_UDP_CHUNK + sizeof(struct udphdr) + \
@@ -675,7 +674,6 @@ int netpoll_setup(struct netpoll *np)
goto release;
}
 
-   npinfo-rx_flags = 0;
npinfo-rx_np = NULL;
 
spin_lock_init(npinfo-rx_lock);
@@ -757,7 +755,6 @@ int netpoll_setup(struct netpoll *np)
 
if (np-rx_hook) {
spin_lock_irqsave(npinfo-rx_lock, flags);
-   npinfo-rx_flags |= NETPOLL_RX_ENABLED;
npinfo-rx_np = np;
spin_unlock_irqrestore(npinfo-rx_lock, flags);
}
@@ -799,7 +796,6 @@ void netpoll_cleanup(struct netpoll *np)
if (npinfo-rx_np == np) {
spin_lock_irqsave(npinfo-rx_lock, flags);
npinfo-rx_np = NULL;
-   npinfo-rx_flags = ~NETPOLL_RX_ENABLED;
spin_unlock_irqrestore(npinfo-rx_lock, flags);
}
 

-- 
Stephen Hemminger [EMAIL PROTECTED]

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html