Relayfs
[Posted October 8, 2003 by corbet]
Tom Zanussi has posted a new version of the "relayfs" filesystem code; the
full set of patches can be found in the "patches" section, below. Relayfs
is an attempt to provide a common framework for kernel code which must
exchange large amounts of data with user space. The initial application
would appear to be for kernel event tracing and profiling, but one can
certainly imagine other ways to use such a system as well.
Relayfs is, of course, yet another virtual filesystem implemented by the
kernel; it must be explicitly mounted by user space to be available.
Kernel code can then create a relay with relay_open(); it will
show up as a file under relayfs. User space can then open the relay and
employ all of the usual file operations - including mmap() and
poll() - to exchange data with the kernel. To an application, a
relayfs file descriptor looks much like a Unix-domain socket, except that
the other end is a piece of kernel code rather than another process.
The interface on the kernel side is a bit more complex. The expected
relay_read() and relay_write() functions exist and can be
used to move data to and from user space. But relayfs also exposes much of
the internal structure to kernel code that needs to know about it. So
special-purpose code can obtain a pointer into the relayfs buffer and copy
data there directly, for example. There is also a set of callbacks for
kernel code that wants to know about relayfs events, and a set of utilities
for manipulating the buffer size, optimizing the locking used, etc.
Relayfs is a non-intrusive patch - it does not affect parts of the kernel
that are not explicitly changed to make use of it. So it is conceivable
that this patch could yet make it into a 2.6 release. The reimplementation
of printk() which uses relayfs might have to wait a little longer,
however.
(
Log in to post comments)