From: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
To: Roland Dreier <rdreier@cisco.com>
Cc: netdev@vger.kernel.org
Subject: Re: NAPI: netif_rx_reschedule() ??
Date: Fri, 1 Sep 2006 03:54:54 +0400 [thread overview]
Message-ID: <20060831235454.GA13068@ms2.inr.ac.ru> (raw)
In-Reply-To: <adau03tlvx8.fsf@cisco.com>
Hello!
> However I'm confused about a couple of things, and there are only two
> uses of netif_rx_reschedule() in the kernel, so I'm a little stuck.
First, do not believe to even single bit of code or docs about
netif_rx_reschedule(). It was used once in the first version of NAPI
for 3com driver (which did not go to mainstream) and was left to rot. :-)
> 1. What is the intent of the second, 'undo' parameter? For example,
> ibmveth.c does
>
> if(ibmveth_rxq_pending_buffer(adapter) && netif_rx_reschedule(netdev, frames_processed))
> {
> lpar_rc = h_vio_signal(adapter->vdev->unit_address, VIO_IRQ_DISABLE);
> ibmveth_assert(lpar_rc == H_SUCCESS);
> more_work = 1;
> goto restart_poll;
> }
>
> but it only does
>
> netdev->quota -= frames_processed;
>
> _after_ that block (and the jump back to restart_poll). So the
> whole things seems fishy: netdev->quota goes up by the number of
> frames processed??
It is broken. netdev->quota MUST not be touched after netif_rx_complete().
Authors improved coding style, moving it closer to update of *budget
and it is wrong. First, because it is changed in an absolutely unserialized
context, second... you noticed.
> It's not clear to me why the driver would want to do something
> different depending on whether the NAPI poll was already scheduled
> or not.
netif_rx_complete() released control. ->poll can be reentered on another
CPU after this.
If netif_rx_reschedule() fails, it means that ->poll must exit, because
poll was already rescheduled.
If it succeds, it means current thread got control back. Changes made
before netif_rx_complete(), becuase we were going to exit, (netdev->quota etc)
are undone and loop can be restarted.
To be honest, I do not recollect everything. F.e. scheduling softirq
in netif_rx_reschedule() looks like a cut-n-paste bug.
Alexey
prev parent reply other threads:[~2006-08-31 23:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-30 22:07 NAPI: netif_rx_reschedule() ?? Roland Dreier
2006-08-30 23:12 ` Stephen Hemminger
2006-08-30 23:31 ` Roland Dreier
2006-08-30 23:38 ` Stephen Hemminger
2006-08-30 23:39 ` Roland Dreier
2006-08-31 21:29 ` Stephen Hemminger
2006-08-31 21:50 ` jamal
2006-08-31 23:54 ` Alexey Kuznetsov [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=20060831235454.GA13068@ms2.inr.ac.ru \
--to=kuznet@ms2.inr.ac.ru \
--cc=netdev@vger.kernel.org \
--cc=rdreier@cisco.com \
/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).