On Fri, 05 Oct 2007 17:00:48 +0900,
Tejun Heo <htejun@gmail.com> wrote:
I agree, so I'll give my 0.02 € here...
I think that's the heart of the question: We first need to agree what
use the different components should have.
(a) The driver model
The driver model serves as a unified layer for all devices managed by
the kernel, organized in trees, and the drivers handling them. This
includes busses, matching of devices and drivers, attributes and so on.
Userspace expects to see these devices, drivers, busses and attributes
by looking under /sys/devices/. /sys/class/ and /sys/bus/ provide
additional views on this data.
(b) kobjects, ktypes, ksets
kobjects provide a mechanism to arrange kernel objects into a tree-like
structure. ktypes and ksets are mechanisms to further order these
objects. Changes in the kobject hierarchy are communicated to userspace
via uevents.
The driver core is implemented using this infrastructure.
(c) krefs
krefs provide a generic reference counting mechanism.
The kobject infrastructure uses krefs for its reference counting needs.
(d) sysfs
sysfs is a virtual filesystem. It exports information on kernel objects
to user space. (IMO, that's the key: sysfs is userspace representation.)
That said, it is logical that kobjects are made visible to userspace
via sysfs. If someone is trying to make things show up in sysfs and has
to jump through hoops to cook up kobjects, they're probably using the
wrong infrastructure.
There are two big problems with the tight coupling of sysfs and kobjects:
- lifetime rules; but this fortunately hugely improved with the
previous patches :)
- relaying implementation details to userspace so that they cannot be
easily changed. We would need to allow kobjects not showing up in sysfs
and making symlinks a sysfs facility not relying on kobjects to help
there.
But krefs are used for kobject reference counting, or am I
misunderstanding here?
There are use cases outside of the driver model prober where you may
want to use kobject for hierarchy.
I see uevents as a notifier for changes in the kobject hierarchy, so
they belong to that layer. However, the layering between kobjects and
sysfs (path names etc.) could probably be made cleaner.
I agree, attributes should belong to the driver model.
Hm. Currently you have a file<->attribute correlation. This would
change if you allow non-attribute files.
And I still think that this is the purpose of krefs :)
I see the value for those code paths that want to provide a hierarchy
of kernel objects outside the driver model proper.
Yes, an easier-to-use interface to the kobject stuff would be helpful
for everyone :)
I disagree. A hierarchy of kernel objects has uses beyond the driver
model.
Yes, stuff visible to userspace is hard :(
I'm not familiar with the libata attributes, but shouldn't these
features really be part of the respective block devices or module
parameters?
s/outside of driver model/outside of kobjects/
And I don't think something that is not part of the kobject hierarchy
really wants to have a sysfs representation.
uevent suppression does not belong to devices, yes. Rather to
kobjects :) And I think uevents as a way to notify users of changes in
the kobject hierarchy is useful outside of sysfs.
*nod* Cleaning up the layering and the interfaces is a good thing in
itself.
I hope I have made my own view clear :) Thanks for reading through this
longish mail.
-