From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: FW: wrapper device driver
Date: Mon, 2 Feb 2015 19:15:13 -0800 [thread overview]
Message-ID: <20150203031513.GA23194@kroah.com> (raw)
In-Reply-To: <CALRD3qKZJpF=Tjw0nhqte3fXOcNqucTVPJpvfdZO584UNNKQnA@mail.gmail.com>
On Mon, Feb 02, 2015 at 05:50:43PM -0600, riya khanna wrote:
> On Mon, Feb 2, 2015 at 5:00 PM, Greg KH <greg@kroah.com> wrote:
> >
> > On Mon, Feb 02, 2015 at 04:46:24PM -0600, riya khanna wrote:
> >> The goal is to provide multiple instances of a real device, where each
> >> instance could be assigned to a container. This is to enable support
> >> for device multiplexing in user space.
> >
> > Heh, no, don't do it.
> >
> > Seriously, don't, it's been shot down time and time again in person and
> > in emails. The 2013 Plumbers conference had a whole session on this in
> > which people yelled at me for 45+ minutes, it was fun, I still said no.
> >
>
> Yes, I'm apprised of the LPC '13 and email discussion on device
> namespaces. In fact the reason I started down this path is because,
> like you said, the discussion outcome ruled out kernel changes.
The discussion also stated that this was impossible without kernel
changes, you need to do this in the kernel on a subsystem-by-subsystem
basis, there is no "magic fix" to make all devices work at once. That
was my main point of that discussion, people seem to be thinking that
they don't want to do the hard work for some reason :(
> >> I did look at CUSE. However, I realized that not all the device
> >> driver's all all operations to be forwarded to CUSE proxy daemon -
> >> some device drivers do bookkeeping based on process PID, so CUSE proxy
> >> daemon cannot operate on behalf of processes. Performance is another
> >> reason.
> >
> > Have you benchmarked CUSE? It's fast, but the real question is what
> > types of devices are you trying to use this for?
> >
> > If a device is to be multiplexed, it needs to be done so in the driver
> > for the device, or the subsystem, you can't do it in a "wrapper" driver,
> > or even in userspace, as state will get confused and messed up and it
> > will not work properly in the end, sorry.
> >
>
> The purpose of multiplexing is to either block undesired
> events/operations on devices (e.g. input, graphics) or respond to the
> applications based on the in-memory state of device instances.
You didn't answer my question of "which specific devices do you care
about" :(
You can't "filter" device commands (see the before-mentioned cdrom mess,
you have learned from history, right?) And you can't assume you know
what the in-kernel state of devices really are, as they are getting
commands from the hardware itself that changes this state, not all
changes come from userspace.
> With CUSE, in-memory states can be maintained and mediated in user
> space. AFAIU, doing device multiplexing in the kernel would also
> entail the same - maintain in-memory state (replicating data structs)
> for each virtual device instance, but that also means changing the
> drivers/subsystem to incorporate this functionality. I may be missing
> something here, but I'm not sure why maintaining the state in
> userspace (as a CUSE device) would be messy and not work. I would
> appreciate more explanation. thanks.
It's impossible to maintain the state in userspace properly. If you
could do it, then you would just have a userspace device driver, and why
need the kernel at all for it? :)
Think through the specifics of a specific device you wish to try to
mitigate access to, and walk through the complexity and marvel at how
much more work you are now doing than the original kernel driver did.
Again, this has to be done on a subsystem-basis, in the kernel, for it
to work properly. And when you try to do that you will get a lot of
pushback, which is correct, as you will be adding complexity for almost
no gain in the end.
Just properly assign different devices to different containers, if you
want to do more than that, then think about using a "real" virtual
machine, which does properly abstract the hardware away like this (or
really, it just does hardware pass-through and again, does not share the
hardware fully, look at how USB works in virtual machines for examples.)
good luck,
greg k-h
next prev parent reply other threads:[~2015-02-03 3:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-02 21:24 wrapper device driver riya khanna
[not found] ` <4796D93DD200E1498C487662EAD9C0DD11A5969F@MBXP14.ds.man.ac.uk>
2015-02-02 21:44 ` FW: " Malte Vesper
2015-02-02 22:05 ` riya khanna
2015-02-02 22:17 ` Greg KH
2015-02-02 22:46 ` riya khanna
2015-02-02 23:00 ` Greg KH
2015-02-02 23:50 ` riya khanna
2015-02-03 2:49 ` Valdis.Kletnieks at vt.edu
2015-02-03 3:09 ` riya khanna
2015-02-03 3:15 ` Greg KH [this message]
2015-02-03 15:34 ` riya khanna
2015-02-03 17:50 ` Valdis.Kletnieks at vt.edu
2015-02-03 20:18 ` Greg KH
2015-02-02 22:02 ` Valdis.Kletnieks at vt.edu
2015-02-02 22:04 ` riya khanna
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=20150203031513.GA23194@kroah.com \
--to=greg@kroah.com \
--cc=kernelnewbies@lists.kernelnewbies.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;
as well as URLs for NNTP newsgroup(s).