Donald Becker wrote:
> On Mon, 19 Jun 2000, Andrew Morton wrote:
> > As you may have noticed, Al Viro is running around the kernel getting
> > rid of MOD_INC_USE_COUNT and MOD_DEC_USE_COUNT. His long-term plan
> > is to remove MOD_INC_USE_COUNT and MOD_DEC_USE_COUNT completely.
> > I'm looking into the changes required for the net drivers.
> Hmmm, this is curious.
> Should not the "feature freeze" phase come well after the "interface freeze"?
> This is pretty obviously an interface change.
Yes, I find it amusing that when something stable is imminent, people
start madly running around cleaning up stuff that should have been done
months/years ago. Oh well. Better than not doing it.
Linus' attitude is that interface changes should go into 2.4 even if
they're large/risky, because he seeks to minimise the differences
between 2.4 and 2.5, so problem fixes can be fed between the two. This
is unconventional and useful.
> > - All 2.4-only netdrivers can have all their MOD_DEC and MOD_INC calls
> > removed. All that twisty logic to keep track of the counts can be
> > tossed. A single
> > SET_NETDEVICE_OWNER(dev);
> "Twisty logic"? Most of the drivers have straight-forward use counts.
They used to, but it was risky.
The problem with a simple MOD_INC_USE_COUNT at the end of open() is that
the preceding kmalloc()'s can sleep while the module refcount is zero,
exposing an opportunity for the module to be unloaded while running.
So the "fix" was to move the MOD_INC_USE_COUNT to the top of open() and
to do complementary MOD_DEC calls wherever the open() method takes an
error path. It's pretty stinky and still doesn't stop the races.
> How is this new method any simpler? If anything, it seems to be more
> complex without any obvious benefit.
Well, even if it wasn't for the race-avoidance issue, it's always nice
to suck out duplicated code and put it in one place.