On Thu, Sep 21, 2000 at 02:35:53PM +0200, David S. Miller wrote:
> Date: Thu, 21 Sep 2000 14:30:42 +0200
> From: Andi Kleen <ak@xxxxxx>
>
> Also I would propose to run dev->do_ioctl and probably other device
> methods inside the BKL, they are not performance critical anyways
> and it is much safer.
>
> Why, that's really dumb.
>
> All of net/* and drivers/net/* runs %100 asynchronous and threaded on
> SMP systems. Your suggested change would create a new exception :-)
The difference is that hard_start_xmit et.al. are guaranteed to not reenter
on the same CPU. No such guarantee for the ioctl. I would not be surprised
if lots of them are not reentrant. Of course it could be fixed by adding
a reentrancy lock, but that would be overkill because the BKL does fine
for such things. They usually do also not synchronize against the RX/TX
threads properly (e.g. no hw register lock), that needs to be fixed in the
drivers, but I think it would be useless to add no-reeentrancy-against-itself
locks in all low level driver ioctls, that is better in higher levels.
Quick grep in drivers/net/* shows several drivers which are unsafe, mostly
by not protecting their data structures or hardware state:
depca ( while(lp->tx_old != lp->tx_new); /* Wait for the ring to empty */
looks pretty scary in a ioctl BTW ),
dgrs
ppp_synctty: calls n_tty_ioctl, which is surely not non BLK safe
even the happy meal ioctls look quite unsafe.
...
-Andi
|