[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <200907252341.48526.laurent.pinchart@skynet.be>
Date: Sat, 25 Jul 2009 23:41:47 +0200
From: Laurent Pinchart <laurent.pinchart@...net.be>
To: linux-kernel@...r.kernel.org
Subject: Should I use kmap or kmap_atomic to map user pages that will be written in a loop ?
Hi everybody,
I'm trying to implement the USERPTR V4L2 streaming I/O method in the uvcvideo
driver. In a nutshell, that methods uses userspace-allocated buffers to
transfer video data from kernelspace to userspace. The buffers are reused
during the whole video stream in a circular fashion.
The kernel driver receives userspace pointers to those buffers, which can have
been allocated using different methods (malloc, Xv alloc, mmap() on a reserved
memory region, ...). I get the list of underlying pages using
get_user_pages(), and I then need to map those pages to the kernel virtual
address space.
Pages will be written to from the kernel in USB interrupt context. I can then
either kmap_atomic() pages before copying data and kunmap_atomic() them right
after, or kmap() them once at the beginning of the video stream and keep them
mapped until the end.
As I don't have much experience with the memory management subsystem, I'd
appreciate if someone could give me a few advices regarding the best way to
proceed. kmap() is expensive, but it would only be called once, while
kmap_atomic() would be called many times (4500 times per second for a 640x480
30fps video stream). On the other hand, I'm not sure how much pressure keeping
all those kmap() pages mapped into kernel virtual memory for a long time would
put on the memory subsystem.
Please CC me on answers.
Regards,
Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists