public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* VM_RESERVED and PG_reserved : Allocating memory for video buffers
@ 2005-12-15 19:09 Laurent Pinchart
  2005-12-16  1:27 ` Nick Piggin
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2005-12-15 19:09 UTC (permalink / raw)
  To: Linux Kernel Mailing List

Hi everybody,

I'm writing a Linux driver for a USB Video Class compliant USB device. I 
manage to understand pretty much everything on my own until the point where I 
have to allocate video buffers.

I read other drivers to understand how they proceed. Most of them used vmalloc 
with SetPageReserved and remap_pfn_range to map the memory to user space. I 
thought I understood that, when I noticed that vm_insert_page has been added 
in 2.6.15. I wasn't sure how to prevent pages from being swapped out, so I 
read the excellent "Understanding the Linux Virtual Memory Manager", but I'm 
still not sure to understand everything. This is where I ask for your help.

I need to allocate big buffers, so vmalloc is the way to go, as I don't need 
contiguous memory. I need to map those buffers to user space, and I 
understand that vm_insert_page will do the job nicely. My fears come from 
pages being swapped out. I suppose I need to prevent that, as a page fault in 
interrupt is a Bad Thing(TM). I'm not sure how PG_reserved and VM_RESERVED 
interract with eachother. Can kernel pages be swapped out if they are not 
mapped to user space ? Or does kswapd only walk VMAs when it tries to find 
pages that will be swapped out ? If the later is true, is it enough to set 
VM_RESERVED on the VMA in the mmap handler ?

Memory management is quite complex in the Linux kernel, and I definitely need 
some help to understand how all the magic is performed :-)

Best regards,

Laurent Pinchart

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

end of thread, other threads:[~2005-12-16 14:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-15 19:09 VM_RESERVED and PG_reserved : Allocating memory for video buffers Laurent Pinchart
2005-12-16  1:27 ` Nick Piggin
2005-12-16 11:33   ` Laurent Pinchart
2005-12-16 13:34     ` Nick Piggin
2005-12-16 14:10       ` Markus Rechberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox