Subject: Re: [PATCH] net: more timeouts that reach -1

From: "Guo-Fu Tseng" <[email-masked]>
Date: Fri, 27 Feb 2009 23:51:05 +0800

On Fri, 27 Feb 2009 16:37:30 +0100, roel kluin wrote
> On Fri, Feb 27, 2009 at 12:43 PM, Guo-Fu Tseng <[email-masked]> wrote:
> > There should be no difference after this modification.
> > The return value of this function is: "limit > 0 ? limit : 0;"
> 
> There is:
> In the last iteration limit is 1 during the test before it is decremented to 0.
> 
> rxdesc = rxring->desc;
> rxdesc += i;
> 
> If then we break out of the loop by the 'goto out;', we continue with:
> 
> out:
>         atomic_set(&rxring->next_to_clean, i);
> 
> out_inc:
>         atomic_inc(&jme->rx_cleaning);
> 
> but since limit is already decremented, 0 is returned.
> 
> >
> > Guo-Fu Tseng
> >
> 
> Roel
I see.
But the correct patch should be following one, right?

===================================================================
--- jme.c	(revision 580)
+++ jme.c	(working copy)
@@ -958,13 +958,14 @@
 		goto out_inc;
 
 	i = atomic_read(&rxring->next_to_clean);
-	while (limit-- > 0) {
+	while (limit > 0) {
 		rxdesc = rxring->desc;
 		rxdesc += i;
 
 		if ((rxdesc->descwb.flags & RXWBFLAG_OWN) ||
 		!(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL))
 			goto out;
+		--limit;
 
 		desccnt = rxdesc->descwb.desccnt & RXWBDCNT_DCNT;

Guo-Fu Tseng