[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Zero-copy transfer with kiobufs: URGENT
Hi Stuart -
Thanks for your excellent suggestion. I have a couple of comments.
* How can we deal with potentially large chunks of memory:
I thought we need vmalloc() to allocate large kernel chunks (e.g:
>= 10 MB)
* I'm concerned about memory limitations since the data
is still wired:
you're suggesting a mmap-based approach with the user having the
possibility to free up the memory with a close() call.
In our application, we intend to store each transferred chunk from the
kernel in a ring buffer. Thus there is a potential risk to consume all
the main memory with a mmap-based approach since the data is still
wired.
Ideas ?
Thanks
On Thu, 4 Oct 2001, Stuart Macdonald wrote:
> Hi,
>
> The following works for me:
>
> 1) User space calls kernel-based function which:
>
> a) creates a Virtual Memory Area of say 64KB. do_mmap_pgoff()
> returning address and then call find_vma() to get the actual vma.
>
> b) does a pvKernelMem = __get_free_pages(up to 128KB I believe) to
> allocate contiguous kernel pages. Note, kmalloc() does not always
> end up being page-aligned. Save pvKernelMem for kernel access to shared
> memory.
>
> c) Map the user VMA to the kernel pages using: set_page_reserved()
> on all pages then remap_page_range().
>
> d) return VMA->vm_start to the user to denote the beginning address
> of the shared memory.
>
> 2) Use memory. Suggest you specify "volatile" on variables utilizing such
> shared memory to avoid compiler optimization related
> issues.
>
> 3) Have a "Close" function unmap by using do_munmap() and free kernel pages.
>
>
> Stuart
>
>
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.kernelnewbies.org/