User: Password:
|
|
Subscribe / Log in / New account

Can we admit that sysfs was a really bad idea?

Can we admit that sysfs was a really bad idea?

Posted Mar 18, 2010 11:16 UTC (Thu) by michaeljt (subscriber, #39183)
In reply to: Can we admit that sysfs was a really bad idea? by glikely
Parent article: A critical look at sysfs attribute values

>Sysfs is not intended to be the primary interface to a device. Nor is it intended to be a kernel
>configuration mechanism.
[snip]
>If questions about access atomicity or formatting of large data arise then I strongly suspect
>that the sysfs interface is being abused and that a char device or debugfs file would be a
>more appropriate choice.
As someone who has had to fiddle with sysfs in userspace recently I can only second that.


(Log in to post comments)

Can we admit that sysfs was a really bad idea?

Posted Mar 22, 2010 22:08 UTC (Mon) by neilbrown (subscriber, #359) [Link]

I would genuinely like to hear more about the problems and issues you experienced. My own belief is that, independent of any intentions to the contrary, sysfs is the de-facto primary interface to devices for configuration (though not for data transfer), and we would be well served by making it fit that role well. To do that we need to understand the problems.

Can we admit that sysfs was a really bad idea?

Posted Mar 25, 2010 4:34 UTC (Thu) by glikely (subscriber, #39601) [Link]

Heh. I was writing a driver a few years back (not mainlined) and completely ignored all the good advice I got about using a normal char dev to control my simple device. Instead I implemented a novel set of sysfs files for obtaining the state of the device. One file was written to chose the channel to read, and another file to read the measurement back. Nice and simple to manipulate from the shell for debug, but a complete disaster in real-world use cases. (ie. two processes cannot read from the device at the same time).

I completely abused sysfs in my driver. It was the wrong interface for actually interacting with the device, and I ended up rewriting the interface in the end. In this case the problems and issues were very much of my own making. :-)

Anytime I hear complaints about sysfs atomicity it raises a red flag for me and I wonder if it is a similar situation of using sysfs for IO instead of mere configuration. Using sysfs for IO is in a lot of cases broken.

I spoke to quickly in my earlier comment. Yes, you're right. sysfs has become the natural configuration interface for a lot of devices, and it suits that job very well. However, I still say that it doesn't replace sysctl for the non-device-centric configuration knobs (ie. the ip stack).

Can we admit that sysfs was a really bad idea?

Posted Mar 25, 2010 10:03 UTC (Thu) by michaeljt (subscriber, #39183) [Link]

I suppose my usage case was a bit special - I had to write code that would
enumerate and get information on devices that would run on as wide a
range of Linux-based systems as possible. Getting information out of sysfs
in a way that is fully backwards-compatible while still being future-proof
proved to be rather hard. In the end, by minimising the use I made of sysfs
to just the most basic device enumeration - the original purpose of sysfs
after all - I was able to write code that worked from early single-digit 2.6
kernels up to current ones, and with some slightly hacky extensions even
worked on all 2.4 series kernels I tried.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds