2007-11-21 19:45:28

by Ferenc Wagner

[permalink] [raw]
Subject: network driver usage count

Hi!

Under 2.6.23.1, my lsmod output shows this:

$ lsmod | grep tg3
tg3 100580 0

The usage count is zero, even though it drives my two physical
interfaces:

$ ls -l /sys/class/net/eth-gb?/device/driver
lrwxrwxrwx 1 root root 0 2007-11-21 19:58 /sys/class/net/eth-gb1/device/driver -> ../../../bus/pci/drivers/tg3
lrwxrwxrwx 1 root root 0 2007-11-21 19:58 /sys/class/net/eth-gb2/device/driver -> ../../../bus/pci/drivers/tg3

These interfaces are up and bonded together, but that doesn't seem to
matter at all. I also checked other machines, the network driver
(tg3, e1000) usage counts are always zero under various recent 2.6
kernels, but nonzero under 2.4.21 for example.

And really, the module could be removed, cutting my ssh session. :)

Was this made possible intentionally? If yes, why?
--
Thanks,
Feri.

PS. please Cc: me, I'm not on the list.

PPS. on loading tg3, I get messages like:
eth-gb1: device_rename: sysfs_create_symlink failed (-17)
I configured renaming by udev, did I make a mistake?


2007-11-21 21:05:59

by Stephen Hemminger

[permalink] [raw]
Subject: Re: network driver usage count

On Wed, 21 Nov 2007 20:45:11 +0100
Ferenc Wagner <[email protected]> wrote:

> Hi!
>
> Under 2.6.23.1, my lsmod output shows this:
>
> $ lsmod | grep tg3
> tg3 100580 0
>
> The usage count is zero, even though it drives my two physical
> interfaces:
>
> $ ls -l /sys/class/net/eth-gb?/device/driver
> lrwxrwxrwx 1 root root 0 2007-11-21 19:58 /sys/class/net/eth-gb1/device/driver -> ../../../bus/pci/drivers/tg3
> lrwxrwxrwx 1 root root 0 2007-11-21 19:58 /sys/class/net/eth-gb2/device/driver -> ../../../bus/pci/drivers/tg3
>
> These interfaces are up and bonded together, but that doesn't seem to
> matter at all. I also checked other machines, the network driver
> (tg3, e1000) usage counts are always zero under various recent 2.6
> kernels, but nonzero under 2.4.21 for example.
>
> And really, the module could be removed, cutting my ssh session. :)
>
> Was this made possible intentionally? If yes, why?

Yes, so devices can be removed at anytime.

--
Stephen Hemminger <[email protected]>

2007-11-21 22:17:17

by Ferenc Wagner

[permalink] [raw]
Subject: Re: network driver usage count

Stephen Hemminger <[email protected]> writes:

> On Wed, 21 Nov 2007 20:45:11 +0100
> Ferenc Wagner <[email protected]> wrote:
>
>> Under 2.6.23.1, my lsmod output shows this:
>>
>> $ lsmod | grep tg3
>> tg3 100580 0
>>
>> The usage count is zero, even though it drives my two physical
>> interfaces:
>>
>> $ ls -l /sys/class/net/eth-gb?/device/driver
>> lrwxrwxrwx 1 root root 0 2007-11-21 19:58 /sys/class/net/eth-gb1/device/driver -> ../../../bus/pci/drivers/tg3
>> lrwxrwxrwx 1 root root 0 2007-11-21 19:58 /sys/class/net/eth-gb2/device/driver -> ../../../bus/pci/drivers/tg3
>>
>> These interfaces are up and bonded together, but that doesn't seem to
>> matter at all. I also checked other machines, the network driver
>> (tg3, e1000) usage counts are always zero under various recent 2.6
>> kernels, but nonzero under 2.4.21 for example.
>>
>> And really, the module could be removed, cutting my ssh session. :)
>>
>> Was this made possible intentionally? If yes, why?
>
> Yes, so devices can be removed at anytime.

Hmm, that would warrant nuking all the reference counts on every
driver. I must be missing something, since I really feel it goes
against common sense. Can you point me to some discussion of this
change? I mean, I couldn't remove the driver of a mounted filesystem.
So why can I remove a driver serving live network traffic?
--
Thanks,
Feri.

2007-11-21 23:56:17

by Francois Romieu

[permalink] [raw]
Subject: Re: network driver usage count

Wagner Ferenc <[email protected]> :
[...]
> So why can I remove a driver serving live network traffic?

Why not ? It is quite common to remove physically a network/storage
device.

--
Ueimor

2007-11-23 01:05:10

by David Miller

[permalink] [raw]
Subject: Re: network driver usage count

From: Wagner Ferenc <[email protected]>
Date: Wed, 21 Nov 2007 23:16:59 +0100

> Hmm, that would warrant nuking all the reference counts on every
> driver.

That's not true. When packets are in flight, references go
to the device and the device cannot be unloaded until those
references get dropped.

This behavior makes sense because otherwise you have to figure
out the myriad of references (each ipv4 address, each ipv6
address, routes, ARP entries, etc.) just to perform such a
simple operation.

If you do not mean to unload the device, simply do not do it.

2007-11-23 10:11:39

by Ferenc Wagner

[permalink] [raw]
Subject: Re: network driver usage count

David Miller <[email protected]> writes:

> From: Wagner Ferenc <[email protected]>
> Date: Wed, 21 Nov 2007 23:16:59 +0100
>
>> Hmm, that would warrant nuking all the reference counts on every
>> driver.
>
> That's not true. When packets are in flight, references go
> to the device and the device cannot be unloaded until those
> references get dropped.

I'm trying to understand it. Do you mean that the "usage count" in
the lsmod output does not express the user's view of a piece of *ware
being in use, but rather the number of internal kernel references to
it, which would become invalid should that piece disappear? Where the
former "invalidily" means some undetectable and uncorrectable
inconsistency in the kernel data structures, which leads to a kernel
crash.

> This behavior makes sense because otherwise you have to figure
> out the myriad of references (each ipv4 address, each ipv6
> address, routes, ARP entries, etc.) just to perform such a
> simple operation.

Yes, that's the user's idea of a network device being in use. It can
get hairy indeed.

> If you do not mean to unload the device, simply do not do it.

Now I know...
--
Thanks for taking the time,
Feri.