* Passing references to kobjects between userland and kernel
@ 2006-06-14 14:26 Daniele orlandi
2006-06-16 23:58 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Daniele orlandi @ 2006-06-14 14:26 UTC (permalink / raw)
To: linux-kernel
Hello,
I'm trying to figure out what is the correct way to pass references to
kobjects between userland and kernel space.
I have my big object hierarchy of kobjects representing a TDM interconnect
graph with channels, crossconnectors, physical ports and so on.
The main objects are nodes and archs; archs connect two nodes together.
The hierarchy is exported to sysfs.
>From userland I want to tell the kernel "Connect node X to node Y".
The first problem is deciding what interface to use; currently I'm using an
ioctl() but I'm open to suggestions.
The other issue is how to identify objects X and Y in the ioctl() request,
here are the possible ways I've examined:
1- Path
-------
Every kobject registered in sysfs has its own path. I can use path_lookup()
and lookup the object by its kobj.dentry.
Pros: In userland it's easy to identify kobjects by their path in sysfs. The
path is unambiguous and already available.
Cons: Passing the pathname to the kernel requires a big ioctl() body
(theoretically at least 2*MAX_PATH using a fixed-length structure).
Doing the reverse mapping (from kernel to userspace) is not easy since you
need to know from which vfsmount to generate the path with d_path().
2- Relative path
----------------
Pros: No need to consider where sysfs is mounted and would also work if the
kobjects are not registeres in sysfs.
Cons: There should be specific functions to parse/generate a pathname that is
specific to kobject hierarchy.
3- Unique ID
------------
A unique ID, probably a integer value can be assigned to each object.
Pros: much more compact, do not need parsing
Cons: Needs an 'id' attribute in sysfs for every object and a reverse mapping
(done with symlinks?) to allow an userland application to map IDs to paths
and vice-versa. Unique ID allocation needs an allocator (list, bitmap, etc)
either global or for every namespace.
4- kobject's pointer
------------------
The kobject's pointer could opaquely be seen as a unique identifier.
Pros: Compact, no need for storage.
Cons: Probably insane, exposes kernel internals to the userland, a developer
may be tempted to deference the user-provided value directly :)
So, are there any other ways? If not, which one would be advisable among
these?
Bye,
--
Daniele "Vihai" Orlandi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Passing references to kobjects between userland and kernel
2006-06-14 14:26 Passing references to kobjects between userland and kernel Daniele orlandi
@ 2006-06-16 23:58 ` Greg KH
2006-06-19 23:48 ` Daniele Orlandi
0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2006-06-16 23:58 UTC (permalink / raw)
To: Daniele orlandi; +Cc: linux-kernel
On Wed, Jun 14, 2006 at 04:26:38PM +0200, Daniele orlandi wrote:
>
> Hello,
>
> I'm trying to figure out what is the correct way to pass references to
> kobjects between userland and kernel space.
Use the kobject_uevent() call from kernelspace to let userspace know
whatever you want it to. That is what it is there for :)
>
> I have my big object hierarchy of kobjects representing a TDM interconnect
> graph with channels, crossconnectors, physical ports and so on.
> The main objects are nodes and archs; archs connect two nodes together.
>
> The hierarchy is exported to sysfs.
>
> From userland I want to tell the kernel "Connect node X to node Y".
Then use the names of the kobjects within your subdirectory. They have
to be unique so you should be safe.
Or use configfs :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Passing references to kobjects between userland and kernel
2006-06-16 23:58 ` Greg KH
@ 2006-06-19 23:48 ` Daniele Orlandi
2006-06-19 23:53 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Daniele Orlandi @ 2006-06-19 23:48 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel
On Saturday 17 June 2006 01:58, Greg KH wrote:
>
> Use the kobject_uevent() call from kernelspace to let userspace know
> whatever you want it to. That is what it is there for :)
kobject_uevent() is fine if I want to asynchronously notify the user space of
an event.
What I need is a synchronous bidirectional interface, e.g. I tell the kernel
"connect node X with node Y" and I get back the resulting pipeline
identifier.
> Or use configfs :)
Configfs is very interesting, it's surely well suited for several tasks I'm
doing and I will add support for it into my subsystem.
What it's missing is the ability to create non-persistent configurations,
bound to a process and disappearing along with the process that created them.
For example, my process creates pipelines between nodes using a ioctl()
interface. If the process dies unexpectedly the file descriptor is
automatically closed and I can release all the pipelines. I don't see a way I
could accomplish the same with configfs or sysfs.
OTOH, for what concerns persistent pipelines, configfs is quite good. It would
be even better if I could create links from configfs objects to sysfs
objects.
Bye,
--
Daniele "Vihai" Orlandi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Passing references to kobjects between userland and kernel
2006-06-19 23:48 ` Daniele Orlandi
@ 2006-06-19 23:53 ` Greg KH
2006-06-20 7:17 ` Daniele Orlandi
0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2006-06-19 23:53 UTC (permalink / raw)
To: Daniele Orlandi; +Cc: linux-kernel
On Tue, Jun 20, 2006 at 01:48:54AM +0200, Daniele Orlandi wrote:
> On Saturday 17 June 2006 01:58, Greg KH wrote:
> >
> > Use the kobject_uevent() call from kernelspace to let userspace know
> > whatever you want it to. That is what it is there for :)
>
> kobject_uevent() is fine if I want to asynchronously notify the user space of
> an event.
>
> What I need is a synchronous bidirectional interface, e.g. I tell the kernel
> "connect node X with node Y" and I get back the resulting pipeline
> identifier.
Why do you feel that this is a requirement? What exactly are you trying
to do?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Passing references to kobjects between userland and kernel
2006-06-19 23:53 ` Greg KH
@ 2006-06-20 7:17 ` Daniele Orlandi
0 siblings, 0 replies; 5+ messages in thread
From: Daniele Orlandi @ 2006-06-20 7:17 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel
On Tuesday 20 June 2006 01:53, Greg KH wrote:
>
> Why do you feel that this is a requirement? What exactly are you trying
> to do?
I have my channels interconnect graph, nicely exported to sysfs, and I just
need an interface that an application could use to request connections
between two nodes of this graph.
The result of the connection is a pipeline object, also exported to sysfs,
that the application will use to do further work on the connection.
Currently I'm using an ioctl() but, given that ioctls seem to be a no-no for
future projects, given that there is great effort in having new and better
interfaces, I'm trying to figure out what is the best way to do what I need.
thanks,
Bye,
--
Daniele Orlandi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-06-20 7:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-14 14:26 Passing references to kobjects between userland and kernel Daniele orlandi
2006-06-16 23:58 ` Greg KH
2006-06-19 23:48 ` Daniele Orlandi
2006-06-19 23:53 ` Greg KH
2006-06-20 7:17 ` Daniele Orlandi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.