Weekly Edition Return to the Kernel page |
Future Driver core changes
Now that the 2.6.15 kernel is starting to stabilize, and the
class device nesting code
is looking pretty stable, it is time to start working on the future of
the Linux driver core, with regards to the class and device structures.
A month ago, I wrote
a short summary of what I thought the future was going to look like
.
In this short article, I'm going to try to explain more about exactly
what each of the steps that I described is going to entail.
The future of struct class_deviceEventually, the structure class_device is going to be merged into the device structure, and go away. But as this can not happen all at once, here are the different steps that I see happening to achieve this goal:
After all of these steps are complete, the last few holdouts of the class_device structure can be removed, and replaced with struct device, and then the class device structures and functions can finally be deleted. The main point of this process is that it is going to happen one subsystem at a time, hopefully in such a manner that no users ever notice the difference.
Trees of symlinksAfter the previously mentioned steps have been complete, the /sys/class/ directories will only contain subdirectories of symlinks back to the /sys/device tree. For example, for the 2.6.15 kernel release, the /sys/class/usb_host tree looks like:
/sys/class/usb_host/
|-- usb_host1
| |-- device -> ../../../devices/pci0000:00/0000:00:1d.0
| `-- uevent
|-- usb_host2
| |-- device -> ../../../devices/pci0000:00/0000:00:1d.1
| `-- uevent
|-- usb_host3
| |-- device -> ../../../devices/pci0000:00/0000:00:1d.2
| `-- uevent
`-- usb_host4
|-- device -> ../../../devices/pci0000:00/0000:00:1d.3
`-- uevent
Once the conversion process is done, it will look like this:
/sys/class/usb_host/ |-- usb_host1 -> ../../devices/pci0000:00/0000:00:1d.0/usb_host:usb_host1 |-- usb_host2 -> ../../devices/pci0000:00/0000:00:1d.1/usb_host:usb_host2 |-- usb_host3 -> ../../devices/pci0000:00/0000:00:1d.2/usb_host:usb_host3 `-- usb_host4 -> ../../devices/pci0000:00/0000:00:1d.3/usb_host:usb_host4With the usb_host1 class device moving to: /sys/devices/pci0000:00/0000:00:1d.0/usb_host:usb_host1 |-- device -> ../../0000:00:1d.0 `-- ueventNote how the existing symlink in the device directory that points back to the class device (usb_host:usbhost1 is for the first usb host class device) is now a subdirectory in the device tree. Hopefully this will prevent any userspace program that is relying on the current structure of sysfs from breaking.
kobject/kset/subsystem/attribute dietAs anyone who has tried to understand the tangled web of interlocking pointers and dependencies between the kobject, kset, and subsystem structures and helper functions knows, a lot of work could be done here to make it simpler and easier to use and understand. Along with this, the attribute system of how to create files for kobjects in sysfs is quite complex. Any rework that can be done in this area, while ensuring that all of the current users of these core structures still work properly, will be done. As of this writing, no concrete plans for exactly what needs to be done here have been finalized.
Easier and more APIsThe current driver model is very flexible and powerful. Unfortunately along with this power and flexibility comes the ability to use it in incorrect ways very easily. The driver core does try to warn if somethings are not set up properly (like the lack of a release function), but it is still quite easy to get around these limited checks. So, on the Rusty scale of good kernel api levels, the driver core is very low on the list. Again, like the kset maze, no concrete plans for exactly what will be done in this area have been finalized, but an example of what things might look like would be the current class_device_create() and class_device_destroy() functions. These functions push all of the nasty reference counting logic and class handling code into the driver core, and let the driver author worry about getting their driver specific logic correct. The driver author is no longer forced to become intimate with the driver core inner workings.
Better documentationDue to the complexity of the current driver model code, much better documentation is needed to help developers who do want to use the core functions figure out how things should be done. The documentation that is in the current kernel tree (in Documentation/driver-model/) is woefully out of date. Hopefully the majority of this documentation can be moved to sit next to the driver core code itself, in kerneldoc format, which will help prevent any future changes from going undocumented. Other subsystems have converted over to this format, with very great success, USB being one good example of this.
Out of tree subsystemsAll of these changes will hopefully be done without breaking any userspace utilities (although, there will probably be a few udev updates needed along the way.) Any in-kernel code will be fixed up along the way, preventing any build or usage breakage, and then the unused structures and functions will be removed from the kernel tree. For driver subsystems that live outside of the main kernel tree, this means that their individual authors will have to update them to handle the new changes that are happening, or they can just submit them for inclusion in the main kernel tree, so that their code will be converted for them. (Log in to post comments)
Please don't not break Posted Dec 1, 2005 11:11 UTC (Thu) by smurf (subscriber, #17840) [Link] >> Hopefully this will prevent any userspace program that is relying on the current structure of sysfs to not break.
Ummm... yeah. ;-)
Please don't not break Posted Dec 1, 2005 16:57 UTC (Thu) by gregkh (subscriber, #8) [Link] Well, that's the goal. Do you know of programs relying on the current sysfs class structure that would break with these proposed changes?
Please don't not break Posted Dec 1, 2005 17:31 UTC (Thu) by smurf (subscriber, #17840) [Link] You are missing the keyword "double negation". ;-)
Read literally, your intention seems to be to have *everything* break.
Please don't not break Posted Dec 1, 2005 17:38 UTC (Thu) by gregkh (subscriber, #8) [Link] Doh!Ok, sorry, I didn't mean that, thanks for pointing it out to me.
Please don't not break Posted Jan 12, 2006 20:10 UTC (Thu) by k8to (subscriber, #15413) [Link] Just to be a nudge: double negation in english is ambiguous. It is commonly used in a manner interpreted to be nonconflicting, and this nonconflicting behavior is considered proper in most languages.
All I'm saying here is humans are not CPUs, and can handle these issues fine, but it doesn't hurt to tighten up your language.
Please don't not break Posted Dec 1, 2005 21:46 UTC (Thu) by cook (editor, #4) [Link] Sorry, that slipped by me in the editing pass, the text has been fixed.
Please don't not break Posted Jan 29, 2006 9:12 UTC (Sun) by landley (subscriber, #6789) [Link] Actually, it'll break mdev in busybox. We were traversing the block andclass directory hierarchies to find dev nodes, but were avoiding traversing symlinks because following device and bridge can lead to endless loops. Now we apparently have to know _which_ symlinks to follow, which sucks deeply.
Rusty scale? Posted Dec 2, 2005 20:21 UTC (Fri) by skybrian (subscriber, #365) [Link] What is the "Rusty scale of good kernel api levels"?
Rusty scale? Posted Dec 4, 2005 0:18 UTC (Sun) by ddaa (subscriber, #5338) [Link] It's a part of a classic presentation by Rusty Russell.
The whole presentation can be found there:
It's definitely worth reading entirely, very funny and insightful.
In particular, this anecdote says much about communication issue in community projects (this slide and the few following):
The scale in a nutshell is found on those two slides:
But you should probably start reading it from this page:
Future Driver core changes Posted Dec 8, 2005 8:52 UTC (Thu) by akukula (guest, #3862) [Link] "struct class" is one of the worst names I can imagine. Not only it is too general and more precise name would be better -- e.g. "struct devclass". It also confuses a typical C++ programmer. There's only one which is more stupid: "struct struct".
$.02
Future Driver core changes Posted Jan 12, 2006 19:28 UTC (Thu) by gregkh (subscriber, #8) [Link] And what would you suggest using instead?
|
Copyright © 2005, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.