[PATCH] fix buffer starvation race in ibmveth

From: Santiago Leon
Date: Fri Dec 03 2004 - 17:04:53 EST


Andrew,

There's a chance that the receive buffers are being consumed at the same rate as they are being replenished in ibmveth_replenish_task()... Meanwhile, the calls to schedule_replenishing() from ibmveth_poll() won't schedule another replenishing cycle (because the not_replenishing flag is zero), starving the buffers and making the adapter unable to receive packets unless the module is reloaded... Here's a small patch that will fix it by scheduling another replenishing task after toggling the not_replenishing flag.

Please apply.

Signed-Off-By: Santiago Leon <santil@xxxxxxxxxx>
--
Santiago A. Leon
Power Linux Development
IBM Linux Technology Center
===== drivers/net/ibmveth.c 1.19 vs edited =====
--- 1.19/drivers/net/ibmveth.c 2004-11-22 00:42:54 -06:00
+++ edited/drivers/net/ibmveth.c 2004-12-03 15:27:40 -06:00
@@ -96,6 +96,7 @@
static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter);
static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter);
static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
+static inline void ibmveth_schedule_replenishing(struct ibmveth_adapter*);

#ifdef CONFIG_PROC_FS
#define IBMVETH_PROC_DIR "ibmveth"
@@ -104,7 +105,7 @@

static const char ibmveth_driver_name[] = "ibmveth";
static const char ibmveth_driver_string[] = "IBM i/pSeries Virtual Ethernet Driver";
-#define ibmveth_driver_version "1.02"
+#define ibmveth_driver_version "1.03"

MODULE_AUTHOR("Santiago Leon <santil@xxxxxxxxxx>");
MODULE_DESCRIPTION("IBM i/pSeries Virtual Ethernet Driver");
@@ -271,6 +272,8 @@
adapter->rx_no_buffer = *(u64*)(((char*)adapter->buffer_list_addr) + 4096 - 8);

atomic_inc(&adapter->not_replenishing);
+
+ ibmveth_schedule_replenishing(adapter);
}

/* kick the replenish tasklet if we need replenishing and it isn't already running */