netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: benh@kernel.crashing.org
Cc: netdev@vger.kernel.org
Subject: Re: The proper way of delaying tx in a driver
Date: Wed, 23 Jul 2008 01:11:34 -0700 (PDT)	[thread overview]
Message-ID: <20080723.011134.256015233.davem@davemloft.net> (raw)
In-Reply-To: <1216795043.11027.311.camel@pasglop>

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: Wed, 23 Jul 2008 16:37:23 +1000

> Drivers like tg3 seem to be at least -somewhat- careful, and only do
> those things when netif_running(). However, unless I missed something,
> this is true from just before the driver open() is called, that is, too
> early for closing the race.
> 
> So the question is, what is the proper approach ?
> 
> I'm happy to help fixing tg3, sungem and emac at least as I'm somewhat
> familiar with those 3 drivers once we decide what is the right sequence
> of operations here.

The other problematic case is netif_device_attach(), which many
drivers use for resume.  It triggers the same WARN_ON() case as
well.

I'm going to attack this as follows:

1) Make running netif_schedule() on the builtin' qdiscs such
   as noop_qdisc and noqueue_qdisc a NOP and not WARN any more.

2) Come up with a "netif_freeze_tx()" or similar to give these
   drivers what they want.

The truth is that neither netif_stop_queue() nor netif_carrier_off()
stop ->hard_start_xmit() execution immediately.

Taking the TX lock(s) and doing netif_stop_queue() comes close, but
it is also not a full solution.

netif_stop_queue() just sets a bit, but a cpu could already be in
the ->hard_start_xmit() handler.

netif_carrier_off() defers the qdisc reset it does into the link_watch
work queue, so it's effect is not immediate either.

To me the most effective queue stopper would be a sequence of three
operations:

1) Set netdev_queue->qdisc to &noop_qdisc

2) Lock the previous qdisc and call ->reset() on it

3) Grab and release TX lock

That guarentees nobody is inside of ->hard_start_xmit() and that
no future packets are pending for the device.

At least for non-LLTX driver.  For LLTX ones, oh well, too bad, they
have to find their own ways to ensure such things.  It's deprecated
for a reason :)


  reply	other threads:[~2008-07-23  8:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-23  6:37 The proper way of delaying tx in a driver Benjamin Herrenschmidt
2008-07-23  8:11 ` David Miller [this message]
2008-07-23  8:19   ` Benjamin Herrenschmidt

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=20080723.011134.256015233.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=benh@kernel.crashing.org \
    --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).