From: Nick Piggin <npiggin@suse.de>
To: Peter Chubb <peter.chubb@nicta.com.au>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] Improved network performance by balancing Rx against other work
Date: Tue, 23 Mar 2010 00:27:55 +1100 [thread overview]
Message-ID: <20100322132754.GO17637@laptop> (raw)
In-Reply-To: <87tysfu05d.wl%peterc@chubb.wattle.id.au>
On Wed, Mar 17, 2010 at 01:55:58PM +1100, Peter Chubb wrote:
> +static int e1000_intr_thread(void *data)
> +{
> + struct net_device *netdev = data;
> + struct e1000_adapter *adapter = netdev_priv(netdev);
> + const int budget = 32; // FIXME should be auto-tuneable
> + int tx_clean_complete = 0, work_done = 0;
> +
> + while(!e1000_wait_for_intr(adapter)) {
> + do {
> + work_done = 0;
> +
> + tx_clean_complete = e1000_clean_tx_irq(adapter, &adapter->tx_ring[0]);
> + adapter->clean_rx(adapter, &adapter->rx_ring[0], &work_done, budget);
> + if (!tx_clean_complete)
> + work_done = budget;
> +
> + if (work_done == budget) {
> + /*
> + * Give up the rest of the timeslice to allow
> + * userspace to make forward progress
> + */
> + sys_sched_yield();
sched_yield literally has undefined semantics if you are in SCHED_OTHER
priority (which your thread is). sched_yield use in userspace and even
kernel has caused headaches whenever the scheduler changes
significantly.
Please use anything but sched_yield. cond_resched() looks appropriate
here, it gives a simple resched point on !PREEMPT kernels. Then the
scheduler nice levels and newer resource controls should give sufficient
flexibility to fine tune CPU allocation after that.
> + }
> + } while (work_done == budget);
> +
> + /* If budget not fully consumed, wait for an interrupt */
> + adapter->last_icr = 0;
> + if (likely(adapter->itr_setting & 3))
> + e1000_set_itr(adapter);
> + if (!test_bit(__E1000_DOWN, &adapter->flags))
> + e1000_irq_enable(adapter);
> + }
> + return 0;
> +}
prev parent reply other threads:[~2010-03-22 13:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-17 2:55 [PATCH] Improved network performance by balancing Rx against other work Peter Chubb
2010-03-22 3:21 ` David Miller
2010-03-22 4:04 ` Peter Chubb
2010-03-22 4:11 ` David Miller
2010-03-22 4:19 ` Peter Chubb
2010-03-22 4:24 ` David Miller
2010-03-22 13:27 ` Nick Piggin [this message]
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=20100322132754.GO17637@laptop \
--to=npiggin@suse.de \
--cc=netdev@vger.kernel.org \
--cc=peter.chubb@nicta.com.au \
/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