From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Bob Smith <bsmith@linuxtoys.org>
Cc: Arnd Bergmann <arnd@arndb.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 001/001] CHAR DRIVERS: a simple device to give daemons a /sys-like interface
Date: Mon, 5 Aug 2013 07:19:58 +0800 [thread overview]
Message-ID: <20130804231958.GA25418@kroah.com> (raw)
In-Reply-To: <51FECDA6.5070001@linuxtoys.org>
On Sun, Aug 04, 2013 at 02:54:46PM -0700, Bob Smith wrote:
> >>+Proxy has some unique features that make ideal for providing a
> >>+/sys like interface. It has no internal buffering. The means
> >>+the daemon can not write until a client program is listening.
> >>+Both named pipes and pseudo-ttys have internal buffers.
> >
> >So what is wrong with internal buffers? Named pipes have been around
> >for a long time, they should be able to be used much like this, right?
> Buffers are great for streaming data but are unneeded for
> configuration and status information. Neither sysfs or procfs
> have internal buffers because they are not needed.
That's because they have a "consumer" at all times already, the kernel
itself. And there is a buffer used, but it's quickly cleaned up.
> In a way the problem is not the buffer itself but that a write
> into a named pipe, for example, will succeed even if there is no
> one at the other end to receive the data. I think you'd want an
> open and write on a device driver to fail if the driver is not
> there and ready for the request.
Yes, but you aren't a device driver, you are a IPC between userspace
processes.
> >Adding a new IPC function to the kernel should not be burried down in
> >drivers/char/. We have 10+ different IPC mechanisms already, some
> >simple, some more complex. Are you _sure_ none of the existing ones
> >will not work for you?
> I'm convinced this has the fewest lines of new code and the
> smallest impact on the rest of the system, but I could be wrong.
> The minimum feature set I want is to emulate for my user-space
> device driver what the kernel has for procfs and sysfs, That is,
> echo 1 > /proc/sys/net/ipv4/ip_forward # procfs
> echo 75 > /dev/motors/left/speed # proxy dev
As I mentioned above, the kernel does have buffers, and you are using
them to talk to the device / driver / hardware / kernel when accessing
proc and sysfs files.
> > Maybe a simple userspace library that wraps the
> >existing mechanisms would be better (no kernel changes needed, portable
> >to any kernel release, etc.)?
> Yes, this is the traditional model for approaching problems like
> the one I have. It would involve opening a unix socket, defining
> a protocol for that socket, and then writing several bindings for
> that protocol for different languages. Wow, that is a LOT of work.
Use protobufs, all of the bindings and protocol is already handled for
you.
> Luckily for us the procfs and sysfs authors have given us a much
> better model to use: ASCII characters terminated by a newline. My
> Raspberry Pi customers expect to control an LED with a command like
> this: echo 1 > /sys/class/gpio/gpio25
That is because you are talking to a hardware device, so that makes
sense.
> So it is entirely reasonable on their part to want to control a
> stepper motor with a command like this:
> echo 300 > /dev/robot/stepper0/count
That would be good, if you were talking to hardware. But you aren't,
you are talking to another userspace process "somewhere else".
thanks,
greg k-h
next prev parent reply other threads:[~2013-08-04 23:18 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <51FC5478.40500@linuxtoys.org>
2013-08-03 1:19 ` [PATCH 001/001] CHAR DRIVERS: a simple device to give daemons a /sys-like interface Bob Smith
2013-08-03 1:56 ` Joe Perches
2013-08-03 2:35 ` Greg Kroah-Hartman
2013-08-03 18:12 ` Bob Smith
2013-08-03 22:38 ` Greg Kroah-Hartman
2013-08-04 21:54 ` Bob Smith
2013-08-04 23:19 ` Greg Kroah-Hartman [this message]
2013-08-05 23:46 ` Bob Smith
2013-08-06 9:46 ` Greg Kroah-Hartman
2013-08-07 19:02 ` Bob Smith
2013-08-07 19:27 ` Greg Kroah-Hartman
2013-08-07 19:39 ` Bob Smith
2013-08-07 19:51 ` Greg Kroah-Hartman
2013-08-07 19:54 ` Greg Kroah-Hartman
2013-08-07 21:04 ` Bob Smith
2013-08-07 21:33 ` Greg Kroah-Hartman
2013-08-08 21:23 ` Bob Smith
2013-08-09 21:52 ` Greg Kroah-Hartman
2013-08-09 22:20 ` Bob Smith
2013-08-09 22:14 ` Bob Smith
2013-08-09 23:01 ` Greg Kroah-Hartman
2013-08-09 23:35 ` Bob Smith
2013-08-09 23:46 ` Greg Kroah-Hartman
2013-08-10 20:08 ` Bob Smith
2013-08-10 20:29 ` richard -rw- weinberger
2013-08-10 20:49 ` Bob Smith
2013-08-10 21:43 ` Arnd Bergmann
2013-08-10 22:07 ` Bob Smith
2013-08-13 20:15 ` Arnd Bergmann
2013-08-07 21:28 ` Bob Smith
2013-08-07 21:40 ` Greg Kroah-Hartman
2013-08-07 21:53 ` Bob Smith
2013-08-09 21:54 ` Greg Kroah-Hartman
2013-08-09 22:51 ` Bob Smith
2013-08-09 23:04 ` Greg Kroah-Hartman
2013-08-07 21:38 ` Bob Smith
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130804231958.GA25418@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=bsmith@linuxtoys.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox