mv643xx_eth: fix double add_timer() on the receive oom timer

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Thursday, August 28, 2008 - 12:59 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=92c70f...
Commit:     92c70f27d2a78873c940e77c7f075cd8e2e60a2d
Parent:     819ddcafb33136f2ba18018a22edcf857f640528
Author:     Lennert Buytenhek <buytenh@wantstofly.org>
AuthorDate: Sun Aug 24 01:59:05 2008 +0200
Committer:  Lennert Buytenhek <buytenh@marvell.com>
CommitDate: Sun Aug 24 03:33:02 2008 +0200

    mv643xx_eth: fix double add_timer() on the receive oom timer
    
    Commit 12e4ab79cd828563dc090d2117dc8626b344bc8f ("mv643xx_eth: be
    more agressive about RX refill") changed the condition for the receive
    out-of-memory timer to be scheduled from "the receive ring is empty"
    to "the receive ring is not full".
    
    This can lead to a situation where the receive out-of-memory timer is
    pending because a previous rxq_refill() didn't manage to refill the
    receive ring entirely as a result of being out of memory, and
    rxq_refill() is then called again as a side effect of a packet receive
    interrupt, and that rxq_refill() call then again does not succeed to
    refill the entire receive ring with fresh empty skbuffs because we are
    still out of memory, and then tries to call add_timer() on the already
    scheduled out-of-memory timer.
    
    This patch fixes this issue by changing the add_timer() call in
    rxq_refill() to a mod_timer() call.  If the OOM timer was not already
    scheduled, this will behave as before, whereas if it was already
    scheduled, this patch will push back its firing time a bit, which is
    safe because we've (unsuccessfully) attempted to refill the receive
    ring just before we do this.
    
    Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
 drivers/net/mv643xx_eth.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index af279f2..8a91d79 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -509,10 +509,8 @@ static void rxq_refill(struct rx_queue *rxq)
 		skb_reserve(skb, 2);
 	}
 
-	if (rxq->rx_desc_count != rxq->rx_ring_size) {
-		rxq->rx_oom.expires = jiffies + (HZ / 10);
-		add_timer(&rxq->rx_oom);
-	}
+	if (rxq->rx_desc_count != rxq->rx_ring_size)
+		mod_timer(&rxq->rx_oom, jiffies + (HZ / 10));
 
 	spin_unlock_irqrestore(&mp->lock, flags);
 }
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
mv643xx_eth: fix double add_timer() on the receive oom timer, Linux Kernel Mailing ..., (Thu Aug 28, 12:59 pm)