LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* share buffer between user and kernel?
@ 2001-10-09  7:03 Peter T. Breuer
  2001-10-15 16:12 ` Tommy Reynolds
  0 siblings, 1 reply; 2+ messages in thread
From: Peter T. Breuer @ 2001-10-09  7:03 UTC (permalink / raw)
  To: linux kernel

What is the currently approved method of sharing a buffer between
userspace and kernelspace, so that I can avoid one or two
copy_to/from_user?

It used to be that one reimplemented mmap to provide the kernel
with some vmalloced memory which one went through reserving, then
the mmap interface automagically provided the right address to
userspace. I get the impression that there are nowadays much
slicker and cleaner ways to do this ... but searching the code
for examples of the absence of copy_to_user is, errm, difficult.

The sound drivers seem to play around in this area, but they
are mapping real physical memory, which I don't want. Is there
an example which uses vmalloced memory?

Or should I just be making a buffer in userspace, then passing
the address to the kernel, then locking it somehow, then collapsing
it to a kernel address? It's going to be about 256K at most.

Suggestions very gratefully received!

Peter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: share buffer between user and kernel?
  2001-10-09  7:03 share buffer between user and kernel? Peter T. Breuer
@ 2001-10-15 16:12 ` Tommy Reynolds
  0 siblings, 0 replies; 2+ messages in thread
From: Tommy Reynolds @ 2001-10-15 16:12 UTC (permalink / raw)
  To: ptb; +Cc: linux-kernel

It was a dark and stormy night.  Suddenly "Peter T. Breuer" <ptb@it.uc3m.es> spoke:

> What is the currently approved method of sharing a buffer between
> user space and kernel space, so that I can avoid one or two
> copy_to/from_user?

Two basic choices here:

1) Allocate the buffer in kernel space and use the mmap() method to give the
user-space program access to it; and

2) Allocate the buffer in you user application program and use the KIOBUF method
to give the kernel and/or hardware access to your buffer.  Look in
<linux/iobuf.h> for kernel-level inspiration.

---------------------------------------------+-----------------------------
Tommy Reynolds                               | mailto:	<reynolds@redhat.com>
Red Hat, Inc., Embedded Development Services | Phone:  +1.256.704.9286
307 Wynn Drive NW, Huntsville, AL 35805 USA  | FAX:    +1.236.837.3839
Senior Software Developer                    | Mobile: +1.919.641.2923

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-10-15 16:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-09  7:03 share buffer between user and kernel? Peter T. Breuer
2001-10-15 16:12 ` Tommy Reynolds

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).