From: Stephen Hemminger <shemminger@vyatta•com>
To: Stephen Hemminger <shemminger@vyatta•com>
Cc: Joe Perches <joe@perches•com>, Tom Herbert <therbert@google•com>,
netdev@vger•kernel.org, aabdulla@nvidia•com, davem@davemloft•net
Subject: Re: [PATCH] forcedeth: Stay in NAPI as long as there's work
Date: Wed, 28 Apr 2010 11:25:28 -0700 [thread overview]
Message-ID: <20100428112528.01277670@nehalam> (raw)
In-Reply-To: <20100428111354.49a6ec1a@nehalam>
The following does the same thing without the extra overhead
of testing all the registers. It also handles the out of memory
case.
Compile tested only...
Signed-off-by: Stephen Hemminger <shemminger@vyatta•com>
--- a/drivers/net/forcedeth.c 2010-04-28 11:14:29.784799317 -0700
+++ b/drivers/net/forcedeth.c 2010-04-28 11:23:53.254354744 -0700
@@ -3743,23 +3743,26 @@ static int nv_napi_poll(struct napi_stru
u8 __iomem *base = get_hwbase(dev);
unsigned long flags;
int retcode;
- int tx_work, rx_work;
+ int rx_count, tx_work=0, rx_work=0;
- if (!nv_optimized(np)) {
- spin_lock_irqsave(&np->lock, flags);
- tx_work = nv_tx_done(dev, np->tx_ring_size);
- spin_unlock_irqrestore(&np->lock, flags);
+ do {
+ if (!nv_optimized(np)) {
+ spin_lock_irqsave(&np->lock, flags);
+ tx_work += nv_tx_done(dev, np->tx_ring_size);
+ spin_unlock_irqrestore(&np->lock, flags);
- rx_work = nv_rx_process(dev, budget);
- retcode = nv_alloc_rx(dev);
- } else {
- spin_lock_irqsave(&np->lock, flags);
- tx_work = nv_tx_done_optimized(dev, np->tx_ring_size);
- spin_unlock_irqrestore(&np->lock, flags);
+ rx_count = nv_rx_process(dev, budget);
+ retcode = nv_alloc_rx(dev);
+ } else {
+ spin_lock_irqsave(&np->lock, flags);
+ tx_work += nv_tx_done_optimized(dev, np->tx_ring_size);
+ spin_unlock_irqrestore(&np->lock, flags);
- rx_work = nv_rx_process_optimized(dev, budget);
- retcode = nv_alloc_rx_optimized(dev);
- }
+ rx_count = nv_rx_process_optimized(dev, budget);
+ retcode = nv_alloc_rx_optimized(dev);
+ }
+ } while (retcode == 0 &&
+ rx_count > 0 && (rx_work += rx_count) < budget);
if (retcode) {
spin_lock_irqsave(&np->lock, flags);
next prev parent reply other threads:[~2010-04-28 18:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-28 6:36 [PATCH] forcedeth: Stay in NAPI as long as there's work Tom Herbert
2010-04-28 17:54 ` Joe Perches
2010-04-28 18:07 ` Tom Herbert
2010-04-28 18:18 ` Tom Herbert
2010-04-28 18:13 ` Stephen Hemminger
2010-04-28 18:25 ` Stephen Hemminger [this message]
2010-04-28 21:25 ` David Miller
2010-04-28 23:56 ` Tom Herbert
2010-04-30 23:17 ` David Miller
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=20100428112528.01277670@nehalam \
--to=shemminger@vyatta$(echo .)com \
--cc=aabdulla@nvidia$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=joe@perches$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=therbert@google$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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