shared memory between user space and kernel space

Submitted by Anonymous
on September 11, 2007 - 4:13am

hi there

is it possible to have a memory area which i can access from both userspace and kernelspace?
so i can exchange data between these _without_ copying

can you please give me a hint how to do that in general (idea) or where i can read something about this
thx
mb

Look at the packet capturing

Anonymous (not verified)
on
September 11, 2007 - 6:27am

Look at the packet capturing code (net/packet/af_packet.c), it has support for a circular mmap-buffer that is shared between kernel and user space.

There's some documentation in Documentation/networking/packet_mmap.txt too..

thanks, i will check this

Anonymous (not verified)
on
September 12, 2007 - 4:42am

thanks, i will check this out ;)

All user space memory is

Anonymous (not verified)
on
September 12, 2007 - 3:40am

All user space memory is accessible from kernel space; any ioctl or syscall with a pointer argument will be reading user space memory. :)

But be careful, don't make any assumptions that two subsequent reads will return the same result -- read individual values only once, and keep them around as local variables while you need them.

yes but then i would be able

Anonymous (not verified)
on
September 12, 2007 - 4:41am

yes but then i would be able to access the right memory only if the user process is actual running.
but i need to write data in the memory from the kernel while the userprocess is sleeping.

Huh? The calling thread is

Anonymous (not verified)
on
September 13, 2007 - 4:52am

Huh? The calling thread is always suspended when a syscall is invoked (or an ioctl which is just another syscall). Other user threads from the same process might still be running, but it's the userspace programmer's problem to guarantee proper locking of their resources.

system calls

Shekhar Chinta (not verified)
on
October 2, 2007 - 4:28am

Hi,

Please help me in finding the system calls which can be use to share all kind of data between user space and kernel space, for example in accessing memory parameters.

RDMA does the same thing

on
September 13, 2007 - 8:23pm

You might also check out the current support for RDMA, as it also locks user buffers in physical memory for a considerable period of time. Here is an article about it from lwn.net:

http://lwn.net/Articles/133649/

We can write a character

Anonymous (not verified)
on
September 14, 2007 - 9:53am

We can write a character device driver as an interface between kernel space & user space...! using the ioctl functionalities.....!

also by using the copy_from_user() & copy_to_user() functions we can copy just the pointer of the data & we can send it directly to kernel level & back to userlevel...!

we can reserve some buffer/page cache(doesnt make difference in linux 2.6)which wil actually contain the pointer information for the data accross the domain....!

we can write our own write "read" & "write" "lseek" system calls...
One copy in the kernel zone exchange cant b avoided...!

We can use the circular linked list buffer for reusability by overwriting the oldest one...!

!......BRAVO......!

We can write a character

Anonymous (not verified)
on
September 14, 2007 - 9:59am

We can write a character device driver as an interface between kernel space & user space...! using the ioctl functionalities.....!

also by using the copy_from_user() & copy_to_user() functions we can copy just the pointer of the data & we can send it directly to kernel level & back to userlevel...!

we can reserve some buffer/page cache(doesnt make difference in linux 2.6)which wil actually contain the pointer information for the data accross the domain....!

we can write our own write "read" & "write" "lseek" system calls...
One copy in the kernel zone exchange cant b avoided...!
We can use the circular linked list buffer for reusability by overwriting the oldest one...!
We can use conventional approach to lock that particular buffer.....!
U can check IO-Lite Paper or beltway buffers concept for the same.....!

!....Bravo....!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.