ZEROCOPY between kernel and userland

Brooks Davis brooks at
Tue Jul 6 14:23:10 PDT 2004

[Please don't top-post, it tends to lose context.]

On Tue, Jul 06, 2004 at 03:36:40PM +0200, thefly wrote:
> could you point me pls to some code of that? To me read-only access is
> ok, userspace doesn't need to write anything on it, kernelspace does.
> But what about locking issues between userspace read access and
> kernelspace write access?

First, be aware that mmap is not necessicairly faster then copyout on
modern CPUs.  The cycles required to copy a few K of bytes aren't worth
much of anything on a modern CPU compared to a page-fault.  Second, if
you still want to do things this way, take a look at the geom statistics
mechanism.  IIRC, it works by using a generation number at the top and
bottom of the stats structure.  The user copies the entire struct and
then verified that the copies of the generation number at the top and
bottom of the struct are the same.  If so, it uses the copy it got.  If
not, it tries again.

-- Brooks

Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url :

More information about the freebsd-hackers mailing list