netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: rusty@rustcorp.com.au
Cc: netdev@vger.kernel.org, shemminger@linux-foundation.org,
	jgarzik@pobox.com, hadi@cyberus.ca
Subject: Re: [PATCH RFX]: napi_struct V3
Date: Mon, 23 Jul 2007 22:47:07 -0700 (PDT)	[thread overview]
Message-ID: <20070723.224707.30179585.davem@davemloft.net> (raw)
In-Reply-To: <1185252439.1803.174.camel@localhost.localdomain>

From: Rusty Russell <rusty@rustcorp.com.au>
Date: Tue, 24 Jul 2007 14:47:19 +1000

> On Mon, 2007-07-23 at 21:07 -0700, David Miller wrote:
> > Another area of consternation are drivers that were using
> > netif_rx_reschedule(), as that interface was removed because it
> > doesn't fit well with the caller managing the dev->quota et al.  I
> > left race conditions in the drivers that were using that interface,
> > but they should still basically work nonetheless.
> 
> Hmm, virtio does this, if the implementation returns false from
> ->restart.  But it's basically a bandaid for things like lguest which
> don't check irq status on irq enable, hence is subject to the race.
> 
> But AFAICT netif_rx_reschedule() is implementable in a driver anyway.
> What am I missing?

That looks like it would work, yes.

This is the least understood area, semantically, of NAPI.  It is
commonly believed that level-triggered interrupts obviate the need to
handle this race condition, and nothing could be further from the
truth.

I don't think it's wise to implement this over and over again in each
driver, since we already know at least a handfull of drivers will use
this.

A netdev_napi_init() suggests itself already.  We could put the work
struct into the napi_struct and make the init routine something like:

static inline void netif_napi_init(struct napi_struct *napi,
				   int (*poll)(struct napi_struct *, int),
				   void (*resched)(struct work *),
				   int weight)
{
	napi->poll = poll;
	napi->weight = weight;
	INIT_WORK(&napi->work, resched);
}

and then we have napi_resched():

static inline void napi_resched(struct napi_struct *napi)
{
	schedule_work(&napi->work);
}

If this can be handled in a better way inside the driver, as is the
case for tg3 et al., "resched" can be passed in as NULL.

Any objections?

  reply	other threads:[~2007-07-24  5:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-24  4:07 [PATCH RFX]: napi_struct V3 David Miller
2007-07-24  4:47 ` Rusty Russell
2007-07-24  5:47   ` David Miller [this message]
2007-07-24  6:21     ` Rusty Russell
2007-07-25  0:45       ` David Miller
2007-07-25  1:15         ` Rusty Russell
2007-07-25  1:47           ` David Miller
2007-07-25  2:33             ` Rusty Russell
2007-07-25  4:29               ` David Miller
2007-07-25  5:09                 ` Rusty Russell
2007-07-25  5:12                   ` David Miller
2007-07-25  5:10             ` David Miller
2007-07-24  7:12 ` Francois Romieu
2007-07-24  7:33   ` Jeff Garzik
2007-07-24  7:35   ` David Miller
2007-07-28 15:21 ` Roland Dreier
2007-07-29  5:30   ` 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=20070723.224707.30179585.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=hadi@cyberus.ca \
    --cc=jgarzik@pobox.com \
    --cc=netdev@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=shemminger@linux-foundation.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).