netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: Jesper Krogh <jesper@krogh.cc>, netdev@vger.kernel.org
Subject: [RFC] niu: RX queues should rotate if budget exhausted
Date: Thu, 26 Mar 2009 19:26:20 +0100	[thread overview]
Message-ID: <49CBC8CC.1090807@cosmosbay.com> (raw)
In-Reply-To: <49CB8DFD.2050504@cosmosbay.com>

I dont have NIU hardware but it seems this driver could suffer from 
starvation of high numbered RX queues under flood. I suspect other
multiqueue drivers might have same problem.

With a standard budget of 64, we can consume all credit when handling
first queue(s), and last queues might discard packets.

Solve this by rotating the starting point, so that we garantee to scan at
least one new queue at each niu_poll_core() invocation, even under stress.

Also, change logic calling niu_sync_rx_discard_stats() to take
into account the device qlen, not bounded by budget (which could be 0)

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>


diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 50c1112..d62d186 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -3726,8 +3726,8 @@ static int niu_rx_work(struct niu *np, struct rx_ring_info *rp, int budget)
 	       np->dev->name, rp->rx_channel, (unsigned long long) stat, qlen);
 
 	rcr_done = work_done = 0;
-	qlen = min(qlen, budget);
-	while (work_done < qlen) {
+	budget = min(qlen, budget);
+	while (work_done < budget) {
 		rcr_done += niu_process_rx_pkt(np, rp);
 		work_done++;
 	}
@@ -3759,6 +3759,7 @@ static int niu_poll_core(struct niu *np, struct niu_ldg *lp, int budget)
 	u32 tx_vec = (v0 >> 32);
 	u32 rx_vec = (v0 & 0xffffffff);
 	int i, work_done = 0;
+	unsigned int cur_rx_ring;
 
 	niudbg(INTR, "%s: niu_poll_core() v0[%016llx]\n",
 	       np->dev->name, (unsigned long long) v0);
@@ -3770,17 +3771,24 @@ static int niu_poll_core(struct niu *np, struct niu_ldg *lp, int budget)
 		nw64(LD_IM0(LDN_TXDMA(rp->tx_channel)), 0);
 	}
 
+	cur_rx_ring = np->last_rx_ring;
 	for (i = 0; i < np->num_rx_rings; i++) {
-		struct rx_ring_info *rp = &np->rx_rings[i];
+		struct rx_ring_info *rp;
 
+		if (++cur_rx_ring >= np->num_rx_rings)
+			cur_rx_ring = 0;
+		rp = &np->rx_rings[cur_rx_ring];
 		if (rx_vec & (1 << rp->rx_channel)) {
 			int this_work_done;
 
 			this_work_done = niu_rx_work(np, rp,
 						     budget);
-
-			budget -= this_work_done;
-			work_done += this_work_done;
+			if (this_work_done) {
+				budget -= this_work_done;
+				work_done += this_work_done;
+				if (budget <= 0)
+					np->last_rx_ring = cur_rx_ring;
+			}
 		}
 		nw64(LD_IM0(LDN_RXDMA(rp->rx_channel)), 0);
 	}
@@ -4497,6 +4505,7 @@ static int niu_alloc_channels(struct niu *np)
 	}
 
 	np->num_rx_rings = parent->rxchan_per_port[port];
+	np->last_rx_ring = 0;
 	np->num_tx_rings = parent->txchan_per_port[port];
 
 	np->dev->real_num_tx_queues = np->num_tx_rings;
diff --git a/drivers/net/niu.h b/drivers/net/niu.h
index 8754e44..113fe1d 100644
--- a/drivers/net/niu.h
+++ b/drivers/net/niu.h
@@ -3266,6 +3266,7 @@ struct niu {
 	struct tx_ring_info		*tx_rings;
 	int				num_rx_rings;
 	int				num_tx_rings;
+	int				last_rx_ring;
 
 	struct niu_ldg			ldg[NIU_NUM_LDG];
 	int				num_ldg;

  parent reply	other threads:[~2009-03-26 18:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-26 12:54 [PATCH 1/2] ucc_geth: Move freeing of TX packets to NAPI context Joakim Tjernlund
2009-03-26 12:54 ` [PATCH 2/2] ucc_geth: Rework the TX logic Joakim Tjernlund
2009-03-26 13:39   ` Anton Vorontsov
2009-03-26 16:43     ` Joakim Tjernlund
2009-03-26 18:05       ` Anton Vorontsov
2009-03-26 18:20         ` Joakim Tjernlund
2009-03-27  7:42           ` David Miller
2009-03-27  9:37             ` Joakim Tjernlund
2009-03-26 14:15 ` [PATCH 1/2] ucc_geth: Move freeing of TX packets to NAPI context Eric Dumazet
2009-03-26 16:55   ` Joakim Tjernlund
2009-03-26 18:26   ` Eric Dumazet [this message]
2009-03-27  7:55     ` [RFC] niu: RX queues should rotate if budget exhausted David Miller
2009-03-27  7:58       ` David Miller
2009-03-27  8:05         ` Eric Dumazet
2009-03-27 10:50 ` [PATCH 1/2] ucc_geth: Move freeing of TX packets to NAPI context Li Yang
2009-03-27 11:52   ` Joakim Tjernlund
2009-03-27 21:55     ` David Miller
2009-03-30  7:36     ` Li Yang
2009-03-30  7:48       ` Joakim Tjernlund
2009-03-30  7:57         ` Li Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49CBC8CC.1090807@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=davem@davemloft.net \
    --cc=jesper@krogh.cc \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).