public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <andrewm@uow.edu.au>
To: kuznet@ms2.inr.ac.ru
Cc: Jeff Garzik <jgarzik@mandrakesoft.com>,
	davem@redhat.COM, linux-kernel@vger.kernel.org
Subject: Re: NETDEV_CHANGE events when __LINK_STATE_NOCARRIER is modified
Date: Tue, 15 May 2001 09:51:32 +1000	[thread overview]
Message-ID: <3B006F84.C1427EB3@uow.edu.au> (raw)
In-Reply-To: <3B002001.AEEEE415@mandrakesoft.com> from "Jeff Garzik" at May 14, 1 02:12:17 pm <200105141840.WAA16086@ms2.inr.ac.ru>

kuznet@ms2.inr.ac.ru wrote:
> 
> Hello!
> 
> > Note that using dev->name during probe was always incorrect.  Think
> > about the error case:
> ...
> > So, using interface name in this manner was always buggy because it
> > conveys no useful information to the user.
> 
> I used to think about cases of success. 8)
> In any case the question follows: do we have some another generic
> unique human-readable identifier? Only if device is PCI?
> 
> Actually, I am puzzled mostly with Andrew's note about "simplicity".
> Andrew's patch was evidently much __simpler__ than yours, at least,
> it required one liner for each device and surely was not a "2.5 material".

mmm...  I had to do a bit of mangling in the net core to be able
to "reserve" the netdevice name at init_etherdev() time, but make
it unavailable in namespace lookups.

As Jeff points out, it was an unusual interface - a two-phase
registration where we first reserve the name and then later
either commit it or withdraw it.  That's not the way kernel
normally does things, and it was done that way for back-compatibility,
and to make the device naming prettier.

And yes, it was a 140k patch because it modified about eighty drivers,
pulled out the old interfaces and pulled out dev_probe_lock().

> > I'm all for removing it...  I do not like removing it in a so-called
> > "stable" series, though.  alloc_etherdev() was enough to solve the race
> > and flush out buggy drivers using dev->name during probe.  Notice I did
> > not remove init_etherdev and fix it properly -- IMHO that is 2.5
> > material.
> 
> Nope, guy. Fixing fatal bug is always material of released kernel.
> 
> In any case the question remains: what is the sense of dev_probe_lock now?

It protects the as-yet-unchanged PCI and Cardbus drivers from a
fatal race.

This is not some theoretical race, BTW: as an experiment I put
a simple "schedule()" into vortex_probe1() and it killed the
driver.  Because:

      sys_init_module()
      ->vortex_probe1()
        ->init_etherdev()
	  ->register_netdev()
	    ->/sbin/hotplug  (an asynchronous execve)
	      -> ifconfig eth0 up

ifconfig is executed before vortex_probe1() had fully initialised the
device and the data structures.  The probe takes tens of milliseconds.

The only thing which prevents this race is the fact that sys_init_module()
and sys_ioctl() both do lock_kernel().  If xxx_probe() drops the BKL,
ifconfig gets in there and fails.  Usually, ifconfig finds the driver
has a null ->open() method, so the interface open "succeeds" but the
hardware wasn't opened.  A subsequent ->close() will probably crash
the machine.

That is what dev_probe_lock() is doing today.  It blocks
ifconfig while ->probe() is in progress.  Drivers which
do not use alloc_etherdev() and which can drop the BKL
in probe may fail to work with /sbin/hotplug initialisation
if dev_probe_lock() is removed.  At present that seems to
include acenic, eepro100, pcnet32 and everyone's 3c59x
except mine :)

-

  parent reply	other threads:[~2001-05-14 23:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <15091.23655.488243.650394@pizda.ninka.net>
2001-05-13 18:19 ` NETDEV_CHANGE events when __LINK_STATE_NOCARRIER is modified kuznet
2001-05-14  1:43   ` Andrew Morton
2001-05-14 17:47     ` kuznet
2001-05-14 18:12       ` Jeff Garzik
2001-05-14 18:40         ` kuznet
2001-05-14 19:27           ` Jeff Garzik
2001-05-14 19:42             ` kuznet
2001-05-14 20:34               ` Jeff Garzik
2001-05-14 23:51           ` Andrew Morton [this message]
2001-05-15  9:02             ` kuznet
2001-05-15 11:00               ` Andrew Morton
2001-05-15 11:15                 ` David S. 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=3B006F84.C1427EB3@uow.edu.au \
    --to=andrewm@uow.edu.au \
    --cc=davem@redhat.COM \
    --cc=jgarzik@mandrakesoft.com \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@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