HEADSUP: complete dev_t/cdevsw patches available
Poul-Henning Kamp
phk at phk.freebsd.dk
Sun Feb 15 12:07:20 PST 2004
OK,
I have uploaded what I think are the complete patches for the dev_t
reorganization.
This is a very intrusive patch set which tries to get the dev_t API
into final shape for RELENG_5, and puts versioning on it so that
we have a chance of backwards compatibility in the future.
The patch touches 166 files throughout the kernel tree, which
is hopefully pretty close to the number of device-drivers we
have in the tree.
If you have style-fixes for this, I would appreciate if we can
handle them afterwards, as this is an incredibly painful patch-set
to maintain the way it is split up right now.
Here is what I would like everybody with time and machines to do:
1. If you maintain a device driver, check it out in sysN.patch,
yell at me if you hate what I've done. If you protest I will
take your driver out of the patch, and leave it to you to fix
it after my commit. The changes are pretty trivial to all drivers
but the drivers in sys2.patch.
2. If you understand evil insides of the dev_t/vnode interaction,
please review sys6.patch in particular.
3. If you understand how cloning works, review sys2.patch in
particular.
4. Review anything else you may care for.
5. Install the sysN.patch and run with it. If it explodes, tell
me where, how etc. (usual debugging applies). For brownie
points, try to see if you can reproduce it with only a subset of
the patches. It helps me if you can tell me in which sys%d.patch
it breaks.
6. Have patience if/when things explode after next weekend when I
commit this.
Thanks in advance,
Poul-Henning
You will find the patches here: http://phk.freebsd.dk/patch
--- patch file size --- -- patch lines --
lines words char filename plus minus netto
1818 6552 55569 sys1.patch 3 265 -262
1254 4862 33711 sys2.patch 309 353 -44
617 2427 20027 sys3.patch 31 68 -37
2395 9446 78634 sys4.patch 321 65 256
191 819 6616 sys5.patch 25 25 0
623 1967 15623 sys6.patch 199 59 140
5813 20526 161298 sysN.patch 879 826 53
sys1.patch (previously major.patch)
patch relative to -current
Free up a heap of static major numbers and use dynamic
allocation for almost all our drivers. A few are left
behind some intentionally, some because my script didn't
find them.
sys2.patch (previously pseudo.patch)
patch relative to -current + sys1.patch
Implement nmdm, snp, if_tap and if_tun as new-style
cloning drivers.
sys3.patch (previous tty.patch)
patch relative to -current + sys2.patch
Clean up cdevsw with respect to TTY drivers.
sys4.patch
patch relative to -current + sys3.patch
Add version number to cdevsw so we can detect if a KLD
is compiled with the same API.
Flip the sense of the D_NOGIANT flag to be D_NEEDGIANT
instead. Hopefully someday all these will be gone.
sys5.patch
patch relative to -current + sys4.patch
Remove unused last arg from udev2dev(). Replace remaining
use of makedev() with udev2dev().
sys6.patch
patch relative to -current + sys5.patch
Implement reference counting on dev_t and cdevsw.
Check version number on cdevsw and refuse if incorrect.
Free dev_t's back to malloc(9) when no longer used.
Free major numbers when cdevsw no longer used.
sys6.patch is the risky bit, and if there is too much trouble
with it, I will either neuter it suitably (by not actually
freeing the dev_t anyway) or not commit it at all.
sysN.patch
patch relative to -current.
The kilopatch containing all of the above.
And what do we all get for all this pain ?
I hate to say that the visible impact is very limited right now.
About the only thing you can see is this:
syv# sysctl kern.malloc | grep dev_t
dev_t 26 7K 8K 30 256
syv# ls -l /dev/nmdm
crw-rw-rw- 1 root wheel 235, 0 Feb 15 19:34 /dev/nmdm
This creates two instances of the null-modem driver (I guess ls(1)
stats the name twice, or maybe the first is done by the shell ?)
syv# ls -l /dev/nmdm*
crw-rw-rw- 1 root wheel 235, 0 Feb 15 19:34 /dev/nmdm0A
crw-rw-rw- 1 root wheel 235, 0x00100000 Feb 15 19:34 /dev/nmdm0B
crw-rw-rw- 1 root wheel 235, 1 Feb 15 19:34 /dev/nmdm1A
crw-rw-rw- 1 root wheel 235, 0x00100001 Feb 15 19:34 /dev/nmdm1B
See ? Two instances.
syv# sysctl kern.malloc | grep dev_t
dev_t 30 8K 8K 34 256
More memory used.
syv# find / -ls > /dev/null
Now, stomp around until vnodes are reclaimed.
syv# sysctl kern.malloc | grep dev_t
dev_t 26 7K 8K 34 256
Less memory used again.
The next thing from here is that we can avoid unloading drivers which
the kernel still needs and we can recycle major numbers so we don't
run out before we have 254 in concurrent use.
And a whole lot of other things like a SMPng makeover of the "we don't
have SMPng yet and I need something" atomics in DEVFS.
Poul-Henning
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
More information about the freebsd-current
mailing list